From 373c8d83df1c50cea5270b126c35af984a1966ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Jan 2023 23:26:17 +0100 Subject: [PATCH] Doc --- htdocs/core/class/commoninvoice.class.php | 8 +++++--- htdocs/stripe/class/stripe.class.php | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 17c9c7deae3..cb737a8bdd4 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1079,10 +1079,12 @@ abstract class CommonInvoice extends CommonObject if ($companypaymentmode->type == 'ban') { $sepaMode = true; // Check into societe_rib if a payment mode for Stripe and ban payment exists + // To make a Stripe SEPA payment request, we must have the payment mode source already saved into societe_rib and retreived with ->sepaStripe + // The payment mode source is created when we create the bank account on Stripe with paymentmodes.php?action=create $stripecard = $stripe->sepaStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0); } - if ($stripecard) { // Can be src_... (for sepa). Note that card_... (old card mode) or pm_... (new card mode) should not happen here. + if ($stripecard) { // Can be src_... (for sepa) or pm_... (new card mode). Note that card_... (old card mode) should not happen here. $FULLTAG = 'INV=' . $this->id . '-CUS=' . $thirdparty->id; $description = 'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG . ' ref=' . $this->ref; @@ -1097,7 +1099,7 @@ abstract class CommonInvoice extends CommonObject $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); $charge = new stdClass(); - //erics add processing sepa is like success ? + if ($paymentintent->status === 'succeeded' || $paymentintent->status === 'processing') { $charge->status = 'ok'; $charge->id = $paymentintent->id; @@ -1185,7 +1187,7 @@ abstract class CommonInvoice extends CommonObject $description = 'Stripe payment request OK (' . $charge->id . ') from makeStripeSepaRequest: ' . $FULLTAG; - // TODO Save request to status pending. Done should be set with a webhook. + // @TODO LMR Save request to status pending instead of done. Done should be set with a webhook. $db = $this->db; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 6a6ad66a96a..bc98a085d08 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -1013,8 +1013,8 @@ class Stripe extends CommonObject $s = new \Stripe\StripeClient($stripeacc); - // TODO Deprecated with the new Stripe API and SCA. - // TODO Replace ->create() and ->createSource() and replace with ->getSetupIntent() to get a Payment mode with $payment_method = \Stripe\PaymentMethod::retrieve($setupintent->payment_method); ? + // TODO LMR Deprecated with the new Stripe API and SCA. + // TODO LMR Replace ->create() and ->createSource() and replace with ->getSetupIntent() to then, get the Payment mode with $payment_method = \Stripe\PaymentMethod::retrieve($setupintent->payment_method); ? $sepa = $s->sources->create($dataforcard); if (!$sepa) { $this->error = 'Creation of sepa_debit on Stripe has failed';