#Petr
1 messages · Page 1 of 1 (latest)
hi! can you use Checkout to start a Stripe Subscription? that would work.
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=checkout
I'm already using $stripe->checkout->sessions->create([]);
and get payment_intent after successful payment
how do I need to use payment_intent for auto payment: which method to use,
send data [
'line_items' => $this->order_send['items'],
"metadata" => ["order_id" => $this->order_id, "user_id" => $this->user['id'], 'email' => $this->user['email'],],
'client_reference_id' => $this->order_id,
'customer_email' => $this->user['email'],
'mode' => 'payment',
'success_url' => $this->payment['returnUrl'],
'cancel_url' => $this->payment['url'] . '?isError=true',
]
by "auto payment", do you mean, charging the card that the customer used, yourself later directly from your server?
I mean the algorithm
- the client paid for the membership and we received the payment_intent
- after a certain time, we send a request with payment_intent in the band and charge the amount of membership renewal or additional services
so again, you could use Checkout to create a Subscription if you want to do recurring payments, that's the easiest option
but otherwise, if you want to charge the card you would look at https://stripe.com/docs/payments/save-during-payment?platform=web#charge-saved-payment-method and create a new PaymentIntent using the PaymentMethod pm_xxxx and Customer ID cus_xxx from the original CheckoutSession.
note that you need to pass https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-setup_future_usage so that the card actually gets saved for future payments
i get payment_intent but don't get CUSTOMER_ID after payment
to get CUSTOMER_ID should i create it or is it not necessary? I can send mail or phone
you should use https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer_creation set to always, or you can pass in a Customer to the customer parameter
this
'customer_email' => $this->user['email'],
'customer_creation' => 'if_required',
'mode' => 'payment',
if_required won't do anything since you're using the payment mode that doesn't require one
check the docs :
that's why I said to use always 🙂
ok i will try