#Sarvesh
1 messages · Page 1 of 1 (latest)
Hi
I was doing payment from direct charges form is loaded from Stripe on my page. and I refresh / entered some wrong inputs and I can see many entries for same transaction was created in stripe side
how to avoid this or what could be the solutions to stick with single entry?
How do you accept payments with Stripe? Checkout Session, Payment Element + PaymentIntent, something else?
Payment Element + PaymentIntent by including <script src="https://js.stripe.com/v3/"></script> on page
Got it. Then every time you load the Payment Element, it's expected that you create a new PaymentIntent.
so there is no way, and it will auto generate new payment Intent? Can we pass earlier paymentIntent Id on refresh or on error something like?
Technically you could save the PaymentIntent, and reuse it yes. But you don't have to.
ok
what is the refund api to refund payment intent from stripe standard account
Undefined array key "charges". payment_response does not have "Charges" information
what is the refund api to refund payment intent from stripe standard account
Here: https://stripe.com/docs/api/refunds/create
Undefined array key "charges". payment_response does not have "Charges" information
What are you trying to do? Can you share your code?
$paymentData = json_decode($regEvent->payment_response, true);
if(!empty($paymentData) && $paymentData['account'] == $host->stripe_id) {
$connectedAccountId = $host->stripe_id; //
$chargeId = $paymentData['data']['object']['charges']['data'][0]['id'];
$totalRefund = $regEvent->event_fee*100;
$metaData = array('paymentIntentId' => $paymentIntentId, 'chargeId' => $chargeId, 'event_reg_id' => $regEvent->id, 'total_refund'=>$totalRefund);
try{
$refund = $stripe->refunds->create([
//'charge' => $chargeId,
'payment_intent' => $paymentIntentId,
"reason"=> "requested_by_customer",
"metadata" => $metaData,
'amount' => $totalRefund,
], ['stripe_account' => $connectedAccountId]);
Log::info("A refund request has been submitted. paymentIntentId: " .$paymentIntentId);
return back()->with('success', 'A refund request has been submitted. It may take 5-10 business days for funds to settle.');
} catch(Exception $e) {
Log::error("A refund failed. paymentIntentId: " .$paymentIntentId. " Error".$e->getMessage());
return back()->with('error', 'A refund request failed.');
}
$chargeId = $paymentData['data']['object']['charges']['data'][0]['id'];
here is getting error - Undefined array key "charges".
this was working before with Express account
What is $regEvent->payment_response?
now in payment response from standard account there is no charges as sub object
What is $regEvent->payment_response? If it's a PaymentIntent, can you share the PaymentIntent ID?
[id] => pi_3MJCmeEAjeNK9mUB1gnuqZ1x
And where is the payment_response coming from? What API request have you made to Stripe to get it?
POST /paymentintent
So you create the PaymentIntent, and in the reponse you get you are trying to retrieve the charge property?
which webhook event to subscribe to get refund reponse?