diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c8135d8dc36..6bdaa92f508 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2025,7 +2025,7 @@ if (preg_match('/^dopayment/', $action)) postal_code: 'thirdparty->zip; ?>'} } /* TODO Add all other known data like emails, ... to be SCA compliant */ }, - save_payment_method: false + save_payment_method: true /* the card will be saved */ } ).then(function(result) { console.log(result); diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 24bdedc946f..e2175142dd4 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -810,7 +810,41 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' try { $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); if ($customerstripe->id) { - $listofsources=$customerstripe->sources->data; + + // When using the Charge API architecture + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $listofsources=$customerstripe->sources->data; + } + else + { + $service = 'StripeTest'; + $servicestatus = 0; + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } + + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); + + try { + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $paymentmethodobjs = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card")); + } else { + $paymentmethodobjs = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"), array("stripe_account" => $stripeacc)); + } + + $listofsources = $paymentmethodobjs->data; + } + catch(Exception $e) + { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } + } } } catch(Exception $e) @@ -1001,6 +1035,14 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { print ''; } + elseif ($src->object=='payment_method' && $src->type=='card') + { + print img_credit_card($src->card->brand); + } + elseif ($src->object=='payment_method' && $src->type=='sepa_debit') + { + print ''; + } print''; print '