#BidBird®
1 messages · Page 1 of 1 (latest)
I don't think I understand the question
ok, so, when we create a payment intent it generates a json object. Which is present on a page.
Then when a customer fills out their cc info I'm submitting the updated PI. When it's processed on the php server I'm unable to do $stripeIntent['id'] for instance as it's not a php array.
it's the structure of:
$stripeIntent['id']
vs.
'{'$stripeIntent.setup_future_usage'}',
I just don't know how to access the json object.
I'm not very savvy with PHP, but here's an example of retrieving a Payment Intent and printing paymentIntent[id]:
`$paymentIntent = $stripe->paymentIntents->retrieve(
'pi_1HruFYILwdSSnvJbjey4lywv',
[]
);
echo $paymentIntent->id;`
ok, May I step back one step?
public function charge($amount, $stripeIntent) {// try {
return new PaymentIntent([ 'setup_future_usage' => '{'$stripeIntent.setup_future_usage'}', 'amount' => $amount,
'id' => '{$stripeIntent.id}', 'payment_method' => '{$stripeIntent.payment_method}',
]); } catch (InvalidRequestException $e) { throw new PaymentFailedException; } }
Is the correct thing to do after a customer submits a cc charge? We update the stripeIntent?
Are you following a guide right now?
yes, was doing the upgrade guide from 2018 api
Can you post it?
yes, I'm trying to find it again.
$payment_method = \Stripe\PaymentMethod::retrieve('{{PAYMENT_METHOD_ID}}');
$payment_method->attach(['customer' => '{{CUSTOMER_ID}}']);
So the last stripe dev said if I create a customer prior to the PI this step would not be necessary.
In the previous API, the charge() method would create a stripe charge and return it.
Is it necessary to return a PI, as I've tried above? I guess I'm not sure when the PI must be updated.
What step are you on and where is it going wrong?
Okay, and what's going wrong?
so, according to step 2. after submitting the form I should retrieve:
No such PaymentMethod: '{{PAYMENT_METHOD_ID}}'
but get that error on this line:
$payment_method = \Stripe\PaymentMethod::retrieve('{{PAYMENT_METHOD_ID}}');
PaymentIntent json object has thus:
You need to replace {{PAYMENT_METHOD_ID}} with the actual Payment Method ID
"payment_method": null,
"payment_method_options": { "card": { "installments": null, "mandate_options": null, "network": null, "request_three_d_secure": "automatic" } }, "payment_method_types": [ "card" ],
Is it strange the PM does not have any more info above? That's related to this: pi_3MeRe0KT8fxib8XB1BmWzsxD I think I'm accessing the first payment intent not the amended one. That's what I was trying to do above, update the PI
ahh, I think this is where it's going not good:
public function update($amount){
$intent = \Stripe\PaymentIntent::update( '{{PAYMENT_INTENT_ID}}',
['amount' => $amount]
);
echo json_encode(array('status' => $intent->status));}
how will the PI id get submitted on the await js fetch()?
the fetch seems like it needs to post the PI id, and the get it? is that right?