From 653790fb5d0303236828f691eaaa13a1b27814c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Apr 2019 03:11:46 +0200 Subject: [PATCH] Clean code --- htdocs/public/payment/newpayment.php | 3 ++- htdocs/public/stripe/ipn.php | 1 - htdocs/stripe/class/stripe.class.php | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 2d579329274..69f2d96c8c2 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -395,7 +395,8 @@ if ($action == 'dopayment') } -// Called when choosing Stripe mode, after clicking the 'dopayment' +// Called when choosing Stripe mode, after clicking the 'dopayment' with the Charge API architecture. +// When using the PaymentItent architecture, we dont need this, the Stripe customer is created when creating PaymentItent when showing payment page. if ($action == 'charge' && ! empty($conf->stripe->enabled)) { $amountstripe = $amount; diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index d889041be60..17de701ac29 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -309,7 +309,6 @@ elseif (($event->type == 'source.chargeable') && ($event->data->object->type == // Save into $tmptag all metadata $tmptag=dolExplodeIntoArray($fulltag, '.', '='); - // TODO: Set $_POST var from $event->data and call newpayment.php with $action = 'charge' $stripe=new Stripe($db); /* $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index fd28cd94b8a..6a393e20b7a 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -238,7 +238,7 @@ class Stripe extends CommonObject } /** - * Get the Stripe payment intent + * Get the Stripe payment intent. Create it with confirm=false * * @param Societe $object Object to pay with Stripe * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() @@ -318,7 +318,9 @@ class Stripe extends CommonObject $description=$object->element.$object->id; $dataforintent = array( - "amount" => $stripeamount, + "confirm" => false, // Do not confirm immediatly during creation of intent + "confirmation_method" => $mode, + "amount" => $stripeamount, "currency" => $object->multicurrency_code, "customer" => $customer, "allowed_source_types" => ["card"],