#fazilhussain015
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- fazilhussain015, 1 minute ago, 5 messages
- fazilhussain015, 21 hours ago, 21 messages
- fazilhussain015, 1 day ago, 20 messages
- fazilhussain015, 1 day ago, 8 messages
- fazilhussain015, 4 days ago, 24 messages
Hey there
could you please help me with this
If you are confirming on your server then you can look at the payment_method_details of the Charge: https://stripe.com/docs/api/charges/object#charge_object-payment_method_details
If you confirm client-side, then you do want to use a Webhook
Well I thought that is what you said above
Mostly you don't want to confirm on your server
We recommend confirming client-side
look at my scenario
i want to allow customer to put there amount and than go with payment method for this
i created an intent with dummy amount and after this i send the payment request to my backend which create again intent with new amount provided by the customer.
when request submit to the backend i want to get the all data releated to the payment and than want to return to customer to return url
Yeah you shouldn't create a PaymentIntent with a "dummy amount"
You should use the deferred intent flow in this case: https://stripe.com/docs/payments/accept-a-payment-deferred
i think im using already defferred flow
const options = {
mode: 'payment',
amount: 1099,
currency: 'usd',
// Fully customizable with appearance API.
appearance: {/.../},
};
// Set up Stripe.js and Elements to use in checkout form
const elements = stripe.elements(options);
// Create and mount the Payment Element
const paymentElement = elements.create('payment');
paymentElement.mount('#payment-element');
i took this snippet from the differet flow page
here you can see that a intent is going to be created first to load the payment methods ui
after completing again
creating the intent in backedn code
here is the code snipet from your mentioned page
<?php
$stripe = new \Stripe\StripeClient("");
$intent = $stripe->paymentIntents->create(
[
'amount' => 1099,
'currency' => 'usd',
// In the latest version of the API, specifying the automatic_payment_methods parameter is optional because Stripe enables its functionality by default.
'automatic_payment_methods' => ['enabled' => true],
]
);
echo json_encode(array('client_secret' => $intent->client_secret));
?>
Oh then why are you creating a "dummy PaymentIntent"
And please redact your secret key above
Never share that -- even your test mode one
As it allows access to your account
yeah this key is already publicly open for the test in the stripe documentation
its not from my dashboard
Ah okay
could you please help me with this as i have provided you the complete scenario please read it carefully and suggest me what i need to do
To be clear... when you sign into your account, the docs populate with your key
surpirised
You want to use Webhooks here since you are confirming client-side
So you listen for payment_intent.succeeded
Then you can expand the latest_charge and look at the payment_method_details
That will give you all the data you want
okay if its possible within the payment creation that will be greate
That's only possible via a server-side confirmation -- which is this flow: https://stripe.com/docs/payments/finalize-payments-on-the-server
i think it will take lot of time to implement the the manual code as mentioned in the code
in the first case for the webhook
i created a webhok for the event payment.successed
in this im getting payment details but im unable to get the customer details such as card last 4 digit name and address could you please explain me how i can do this
as i ask this question above but you just send the document link and im unable to get my point from the document
When you receive the payment_intent.succeeded webhook you retrieve the PaymentIntent using https://stripe.com/docs/api/payment_intents/retrieve and when you do that you expand the latest_charge. Then in the response you can inspect the latest_charge.payment_method_details for the data you want.
If you aren't familiar with expansion, then you need to pause and read through https://stripe.com/docs/expand
okay one point more in the deferred intent flow
how many times we need to send the request to stripe ?
Send what request?
first we load the UI for the payment methods im right ?
to load the payment methods UI what we need to do is we need to run this code
const options = {
mode: 'payment',
amount: 1099,
currency: 'usd',
// Fully customizable with appearance API.
appearance: {/.../},
};
// Set up Stripe.js and Elements to use in checkout form
const elements = stripe.elements(options);
what this code does ?
Yes that creates your elements instance which is then used to render Payment Element
yes with amount option
again we send the request by using this code
<?php
$stripe = new \Stripe\StripeClient("sk_test_51NwYwSLYxS9gopqXCGqio9dk8QCOgBFoJ9E04mvi8rY1XE7tpPn1fVD1q3cqXGKC0pOTfNoIAw060kb1a258bEZA00KWS0yF5i");
$intent = $stripe->paymentIntents->create(
[
'amount' => 1099,
'currency' => 'usd',
// In the latest version of the API, specifying the automatic_payment_methods parameter is optional because Stripe enables its functionality by default.
'automatic_payment_methods' => ['enabled' => true],
]
);
echo json_encode(array('client_secret' => $intent->client_secret));
?>
That is how you create a PaymentIntent, yes.
okay as i sad i want to give option to the customer to decided for the payment so why we are provding amount in the options and again sedning it through backend code as mentioned in the last
The amount dictates which Payment Method Types would be supported
Some of them have limitations
could you please more elborate this point
as I'm deciding the payment after UI loaded its means im passsing the dummy amount in the options
It is required to pass currency/amount on the frontend so the correct payment method type options render in the UI
If you don't know the amount yet then yeah you could use a "dummy amount" and then you can update it when your customer indicates the amount.
Or, you can wait to render Payment Element until your customer indicates amount
okay
in this process webhook runs two time
when it calls api first time with dummy amount and second again when submit the customer request
because both time we are creating the request
so this issues with exact data fetching when it will runs two time webhook for one payment
Not sure what "runs two time" means... you want to only listen for payment_intent.succeeded -- are you also listening for payment_intent.created ?
for both times it runs an event with
payment_intent.succeeded
Are you sure you aren't creating a duplicate payment?
Do you have an example you can provide of 2 Event IDs that I can look at?
Okay so those are Events for two different PaymentIntents
So looks like you are creating and confirming two differnet PaymentIntents in your flow
Which means you have a bug somewhere
And you need to ensure that on each submission you only create/confirm a single PaymentIntent
okay can i share my code with you
You can but that really won't help. What you need to do is add logs throughout your code to see why your create endpoint server-side and your confirmPayment() method client-side are being called two times.