commit
8d03d58d54
@ -42,11 +42,13 @@ if (isset($_GET['connect'])){
|
|||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY;
|
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY;
|
||||||
$service = 'StripeTest';
|
$service = 'StripeTest';
|
||||||
|
$servicestatus = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
|
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
|
||||||
$service = 'StripeLive';
|
$service = 'StripeLive';
|
||||||
|
$servicestatus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -54,11 +56,13 @@ else {
|
|||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
|
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
|
||||||
$service = 'StripeTest';
|
$service = 'StripeTest';
|
||||||
|
$servicestatus = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY;
|
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY;
|
||||||
$service = 'StripeLive';
|
$service = 'StripeLive';
|
||||||
|
$servicestatus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$payload = @file_get_contents("php://input");
|
$payload = @file_get_contents("php://input");
|
||||||
@ -227,19 +231,37 @@ elseif ($event->type == 'charge.failed') {
|
|||||||
}
|
}
|
||||||
elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) {
|
elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) {
|
||||||
|
|
||||||
$stripe=new Stripe($db);
|
$fulltag=$event->data->object->metadata->FULLTAG;
|
||||||
$charge=$stripe->CreatePaymentStripe($event->data->object->amount/100,$event->data->object->currency,$event->data->object->metadata->source,$event->data->object->metadata->idsource,$event->data->object->id,$event->data->object->metadata->customer,$stripe->getStripeAccount($service));
|
// Save into $tmptag all metadata
|
||||||
|
$tmptag=dolExplodeIntoArray($fulltag,'.','=');
|
||||||
|
|
||||||
|
if (! empty($tmptag['ORD'])){
|
||||||
|
$order=new Commande($db);
|
||||||
|
$order->fetch('',$tmptag['ORD']);
|
||||||
|
$origin='order';
|
||||||
|
$item=$order->id;
|
||||||
|
} elseif (! empty($tmptag['INV'])) {
|
||||||
|
$invoice = new Facture($db);
|
||||||
|
$invoice->fetch('',$tmptag['INV']);
|
||||||
|
$origin='invoice';
|
||||||
|
$item=$invoice->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stripe=new Stripe($db);
|
||||||
|
$stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here)
|
||||||
|
$stripecu = $stripe->getStripeCustomerAccount($tmptag['CUS'], $servicestatus); // Get thirdparty cu_...
|
||||||
|
$charge=$stripe->createPaymentStripe($event->data->object->amount/100,$event->data->object->currency,$origin,$item,$event->data->object->id,$stripecu,$stripeacc,$servicestatus);
|
||||||
|
|
||||||
if (isset($charge->id) && $charge->statut=='error'){
|
if (isset($charge->id) && $charge->statut=='error'){
|
||||||
$msg=$charge->message;
|
$msg=$charge->message;
|
||||||
$code=$charge->code;
|
$code=$charge->code;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
elseif (isset($charge->id) && $charge->statut=='success' && $event->data->object->metadata->source=='order') {
|
elseif (isset($charge->id) && $charge->statut=='success' && (! empty($tmptag['ORD']))) {
|
||||||
$order=new Commande($db);
|
//$order=new Commande($db);
|
||||||
$order->fetch($event->data->object->metadata->idsource);
|
//$order->fetch('',$tmptag['ORD']);
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$idinv=$invoice->createFromOrder($order);
|
$idinv=$invoice->createFromOrder($order,$user);
|
||||||
|
|
||||||
if ($idinv > 0)
|
if ($idinv > 0)
|
||||||
{
|
{
|
||||||
@ -265,7 +287,7 @@ elseif (($event->type == 'source.chargeable') && ($event->data->object->type ==
|
|||||||
|
|
||||||
if (!$error){
|
if (!$error){
|
||||||
$datepaye = dol_now();
|
$datepaye = dol_now();
|
||||||
$paiementcode ="CB";
|
$paymentType ="CB";
|
||||||
$amounts=array();
|
$amounts=array();
|
||||||
$amounts[$invoice->id] = $total;
|
$amounts[$invoice->id] = $total;
|
||||||
$multicurrency_amounts=array();
|
$multicurrency_amounts=array();
|
||||||
@ -274,7 +296,7 @@ elseif (($event->type == 'source.chargeable') && ($event->data->object->type ==
|
|||||||
$paiement->datepaye = $datepaye;
|
$paiement->datepaye = $datepaye;
|
||||||
$paiement->amounts = $amounts; // Array with all payments dispatching
|
$paiement->amounts = $amounts; // Array with all payments dispatching
|
||||||
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
||||||
$paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement');
|
$paiement->paiementid = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
|
||||||
$paiement->num_paiement = $charge->message;
|
$paiement->num_paiement = $charge->message;
|
||||||
$paiement->note = '';
|
$paiement->note = '';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user