1

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.

Mark David
  • 23
  • 5

1 Answers1

1

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

hanzo
  • 438
  • 2
  • 4
  • thanks for reply. i understand some part of the your answer that i have to create customer object. can you edit code and paste if that's easier for you? – Mark David Mar 30 '23 at 16:59
  • Regarding subscription, how shall i add subscription, do you mean manually login into stripe and do for any customer??? or this is something in the code i have to create other than paymentintents? – Mark David Mar 30 '23 at 17:01
  • The link I shared above (this one: https://stripe.com/docs/billing/subscriptions/build-subscriptions) goes over how you can do this via Checkout Session or the API directly – hanzo Mar 31 '23 at 21:07
  • thanks, that seems good information for subscriptions. i would go through it properly then will see, how it goes. do you also have info where i can add customer code in above my example? thanks – Mark David Apr 01 '23 at 00:23