phpapistripe-paymentspayment-gatewaysubscription

Stripe monthly payment stripe API


In my stripe payment intent example, My code works fine with amount, currency and payment i can see received in stripe. please check my code below

    $paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $obj1,
'currency' => 'gbp',
'metadata' => [
'order_id' => $invID,
'name' => $name,
'email' => $email,

], ]);

But i want to add in my create file following fields so it means these variable should transfered to stripe plus recurring payment,

  1. name
  2. email
  3. address
  4. product title
  5. and monthly payment option (people who subscribe for monthly payment they would automatically be charged each month. )

can anyone please edit code and update it for me to make it work. I am not good in php coding and stuck from last few days. thanks in advance.


Solution

  • That's not how the Stripe APIs work though. PaymentIntents alone can't charge users on a monthly bases, you need to create a subscription for them instead.

    You also can't provide name, email, address and product title directly to the PaymentIntent object. You can however create a customer object and pass their ID in to customer parameter which allows you to associate the PaymentIntent to a customer.

    Customer object can store name, email and address. For product title, you can use PaymentIntent metadata property