#Hakan de Chargemap
1 messages · Page 1 of 1 (latest)
I can try, what's the specific question?
Hey, so we have this piece of code
$paymentIntent = $this->stripeFacade->createPaymentIntent([
'payment_method_types' => StripeFacade::getPaymentMethodFromCountryCode($user->getBillingAddress()->getCountryCode()),
'amount' => $payFromJwtRequest->getAmount(),
'currency' => 'eur',
'customer' => $stripeCustomerId,
'description' => $payFromJwtRequest->getLabel(),
'setup_future_usage' => 'off_session',
'metadata' => $metadata,
], $payFromJwtRequest->getUuid());
so we are using the PHP SDK
and using PaymentIntent::create method
as you may see we have the following keys set :
- payment_method_type
- amount
- currency
- customer
- description
- setup_future_usage
- metadata
this works fine and we do get a stripe ressource that we are able to display
however we would like to, when a user already have a payment method, set the payment in the parameters of the payment intent create request
the goal is to hide the credit card setup form
for this, we do set the "payment_method" property, with a value, for instance "card_1CIG51FigtNEoosZtwA8EuTf"
however, the form remains as is, meaning we still have all the fields that must be filled by the user
I think I'm missing something here
well if you are passing a payment_method then you need to change the code around this so that you're not even touching the frontend.
To charge the saved card you would pass payment_method and confirm=>true, that charges the saved card and then you can check immediately if it succeede
Hmmm we still would like to display a "pay" button so that the user actually do the payment
going for a lunch break but will be back in 1 hour or so
the thread will be closed by then
then for example you can set up your frontend so that you call https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-existing directly, withut needing to create the PaymentElement, if you already know the ID of the card to charge, you can send that to the frontend code and call that function directly when a button is pressed.