Fix error in sources->retrieve when a stripeaccount is defined
This commit is contained in:
parent
22c6b596a7
commit
6afd4e67e9
@ -217,7 +217,7 @@ class Stripe extends CommonObject
|
|||||||
//$sql.= " AND sa.entity IN (".getEntity('societe').")";
|
//$sql.= " AND sa.entity IN (".getEntity('societe').")";
|
||||||
$sql.= " AND sa.type = 'card'";
|
$sql.= " AND sa.type = 'card'";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::fetch search stripe card id for paymentmode id=".$object->id, LOG_DEBUG);
|
dol_syslog(get_class($this) . "::fetch search stripe card id for paymentmode id=".$object->id.", stripeacc=".$stripeacc, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
@ -225,13 +225,15 @@ class Stripe extends CommonObject
|
|||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$cardref = $obj->stripe_card_ref;
|
$cardref = $obj->stripe_card_ref;
|
||||||
|
dol_syslog("*************".$cardref);
|
||||||
if ($cardref)
|
if ($cardref)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||||
$card = $cu->sources->retrieve($cardref);
|
$card = $cu->sources->retrieve($cardref);
|
||||||
} else {
|
} else {
|
||||||
$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc));
|
//$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided
|
||||||
|
$card = $cu->sources->retrieve($cardref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
|
|||||||
@ -271,6 +271,7 @@ if (empty($reshook))
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$facture = new Facture($db);
|
$facture = new Facture($db);
|
||||||
$facture->fetch($facid);
|
$facture->fetch($facid);
|
||||||
$facture->fetch_thirdparty();
|
$facture->fetch_thirdparty();
|
||||||
@ -302,12 +303,16 @@ $paiementcode ="CB";
|
|||||||
}
|
}
|
||||||
elseif (preg_match('/src_/i',$source))
|
elseif (preg_match('/src_/i',$source))
|
||||||
{
|
{
|
||||||
$customer2 = \Stripe\Customer::retrieve($customer->id,array("stripe_account" => $stripe->getStripeAccount($entity)));
|
$stripeacc = $stripe->getStripeAccount($entity);
|
||||||
|
$customer2 = \Stripe\Customer::retrieve($customer->id, array("stripe_account" => $stripeacc));
|
||||||
|
//$src = $customer2->sources->retrieve("$source", array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided
|
||||||
$src = $customer2->sources->retrieve("$source");
|
$src = $customer2->sources->retrieve("$source");
|
||||||
if ($src->type=='card'){
|
if ($src->type=='card')
|
||||||
|
{
|
||||||
$paiementcode ="CB";
|
$paiementcode ="CB";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$societe = new Societe($db);
|
$societe = new Societe($db);
|
||||||
$societe->fetch($facture->socid);
|
$societe->fetch($facture->socid);
|
||||||
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
|
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
|
||||||
@ -349,7 +354,6 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
|
|||||||
$ret = $facture->fetch($facid); // Reload to get new records
|
$ret = $facture->fetch($facid); // Reload to get new records
|
||||||
|
|
||||||
$facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -393,9 +397,10 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
|
|||||||
{
|
{
|
||||||
$loc = dol_buildpath('/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage().'', 1);
|
$loc = dol_buildpath('/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage().'', 1);
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
header('Location: '.$loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
header('Location: '.$loc);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user