#Sandip Kundu - PM

1 messages · Page 1 of 1 (latest)

molten cypress
wraith musk
#

$paymentIntents = $stripe->paymentIntents->create([
'amount' => $_REQUEST['amount']*100,
'currency' => $_REQUEST['currency'],
'payment_method_types' => ['card_present'],
'description' => 'Software development services',
'customer' => 'cus_LKt18Gbx03ynVq',
'payment_method' => 'pm_1KeEPwSFxQJUWTjSBr8jk9mQ',
]);
print_r($paymentIntents);

#

this is my code !

#

payment method is already attached with customer but when i am giving payment method it returns status code 500 error

molten cypress
wraith musk
#

ok

#

searching

#

req_8RPgd96VQMPOYA here it is

molten cypress
#

This error is expected, you can only attach a payment method to a customer once.

wraith musk
#

i am trying to charge same customer

molten cypress
#

Also note that directly creating a payment method like this is not recommended. It looks like you are storing the card numbers on your own server which requires to be PCI compliant.

#

i am trying to charge same customer
If the payment method was already attached to the customer, it should work. Do you have a request ID where you tried this and it failed?

wraith musk
#

yes

#

it showing incomplete

#

but not fails.

#

req_EhXrcC3dRUJPrs this is the request id

wraith musk
molten cypress
#

The request you just shared is to retrieve a payment method. Can you share the request where you actually tried to make a payment?

wraith musk
#

req_V1RLkaXJ7QEi9L

molten cypress
#

No we never store cards into our system.
Maybe you don't store them, but it looks like your server process the raw card number, which is not allowed unless you are PCI compliant.

wraith musk
#

req_V1RLkaXJ7QEi9L this is the request id you are looking for

molten cypress
#

Thanks! In this request you forgot to set the payment_method .

#

You need to include both the customer and the payment_method when creating the PaymentIntent

wraith musk
#

when i set the payment method with payment intent then it will error.

#

but my question is payment method is already attached with the customer then why i need to attach the payment method again with payment intent ?

molten cypress
#

when i set the payment method with payment intent then it will error.
Can you share the request ID?

#

but my question is payment method is already attached with the customer then why i need to attach the payment method again with payment intent ?
No, if the payment method is already attached, you don't need to attach it again.

wraith musk
#

then why the payment status going incomplete due to payment method ?

#

In this reqyuest ( req_V1RLkaXJ7QEi9L ) , payment method is already attached with the customer then why i need to attach the payment method again with payment intent ?

molten cypress
#

why i need to attach the payment method again with payment intent ?
No, like I said multiple time, you only need to attach the payment method once.

#

In the request you just shared, you forgot to include the payment_method in the request.

#

You need to include both the customer and the payment_method when creating the PaymentIntent

#

To clarify: you attach the payment method to the customer once, but then for every PaymentIntent you create, you need to pass both the customer and the payment_method, otherwise it won't work.

wraith musk
#

can i use the same payment method which attached with the customer when creating PaymentIntent ?

molten cypress
#

I'm not sure I understand your question. Once you have a customer with a payment method attached, you can create multiple PaymentIntent for the existing customer and payment method.

wraith musk
#

yes ! right.

#

Now what should i do ?

molten cypress
#

The code you shared at the beginning should work, that why I asked you to give me a request ID to see the issue.

$paymentIntents = $stripe->paymentIntents->create([
'amount' => $_REQUEST['amount']*100,
'currency' => $_REQUEST['currency'],
'payment_method_types' => ['card_present'],
'description' => 'Software development services',
'customer' => 'cus_LKt18Gbx03ynVq',
'payment_method' => 'pm_1KeEPwSFxQJUWTjSBr8jk9mQ',
]);

wraith musk
molten cypress
#

So here the error is that the payment method you set in the request isn't attached to the customer. You need to:

  • Step 1: attach the payment method to the customer
  • Step 2: create a PaymentIntent for that customer and payment method
wraith musk
#

I have soved the issue ..

#

very very thank you ma'am.

#

for your valuable time to assist me. thanks alot.