#xfechx

1 messages · Page 1 of 1 (latest)

steep otter
#

can I use this code successfully, or is the customer source required?

What are you trying to do with it, exactly? How is that customer configured?

#

I thought you were switching to use payment intents, too

round depot
#

I get this error:

#

Cannot charge a customer that has no active card

#

Yes, I will, but I have to test something beforehand

#

can I have the same link that karlleko shared before?

#

to charge using payment intent?

steep otter
#

What do you mean?

#

That error suggests the customer has no default source set up, but you dont want to go down that rabbit hole

#

you want ot get payment methods attached and use payment intents with those payment methods

round depot
#

because I just read this

#

so I need to use payment intent

#

can you help me on how to make a charge for a customer on the backend using payment intents?

#

when I already have the customer id

steep otter
round depot
#

Would this suffice?

#

$stripe->paymentIntents->create([ 'amount' => $amount * $percentage_fee, 'currency' => $currency, 'customer' => $external_customer, 'payment_method_types' => ['card'], 'description' => get_bloginfo('name') . ' Application Fees', 'metadata' => array( 'API'=> $api, 'Test'=> $test_mode, 'Link'=> get_bloginfo('url'), ) ]);

steep otter
#

You can create a payment intent that way, yes, but its not being confirm'd and you cannot do so without a payment method

round depot
#

ok, I already have the customer and payment source

#

so how can I modify it

steep otter
#

What are you trying to do, high level? Are you migrating from Charges? What has you stuck?

round depot
#

I am tyring to charge a customer when something else happens

#

an already saved customer and card

steep otter
#

What do you mean payment source? You have a payment collected already and attached ot the customer?

#

Can you share an example customer id i can look at?

round depot
#

cus_LmOwHcdASdzHbV

steep otter
#

ok, yep, so i see that customer and they have a PM attached

#

so in you code above, you'd want to add:

'payment_method' => 'pm_123_...',
        'off_session' => true,
        'confirm' => true,
#

Since you did setup the payment method for off session use

round depot
#

thanks and then that's it?

steep otter
#

Well, you might have to handle decline and authentication failure still, etc

#

but that's it for the basic happy path/testing

round depot
#

it says that I am missing a PM

#

You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method.

steep otter
round depot
#

ahh i didn't

#

but how can I retrieve the default payment method?

#

without directly putting it there?

#

programatically

#

rather than a constant

#

ok got it

#

$payment_method->data[0]->id

steep otter
#

There is no default - you must specify one from your customer

#

yea

round depot
#

can you tell me if this customer has a source attached?

#

cus_LZhfv2LXRuSRxO

#

I think so, but want to double check