#adil
1 messages · Page 1 of 1 (latest)
I want to capture payment in India
I do not have any items as you mentioned in the custom flow
I have dynamic payment amount
Yesterday your colleague suggested for custom payments but that is not working in my flow
I need to capture amount based on dynamic
Could you please helo me out? Thank You in advance.
How can we send dynamic amount instead of item ID in Custom payment flow
I'm sorry I don't understand your question.
Which Stripe integration are you using? Checkout Session, Payment Element + PaymentIntent, something else?
I only want to capture fee of students with my website but fee generated dynamically
I do not have any item I only have amount dynamic amount // The items the customer wants to buy
const items = [{ id: "xl-tshirt" }];
I only want to capture the amount any dynamic amount no items present did you get my question?
Can you answer my question above?
Which Stripe integration are you using? Checkout Session, Payment Element + PaymentIntent, something else?
I am using Custom payment flow
What is this? Can you share a documentation link or a screenshot?
So you are using Payment Element + PaymentIntent.
Yes
And when you create the PaymentIntent you can directly set the amount, no?
How do you create the PaymentIntent now? Can you share your code?
yes
wait
<?php
require_once '../vendor/autoload.php';
require_once '../secrets.php';
\Stripe\Stripe::setApiKey($stripeSecretKey);
function calculateOrderAmount(array $items): int {
// Replace this constant with a calculation of the order's amount
// Calculate the order total on the server to prevent
// people from directly manipulating the amount on the client
return 1400;
}
header('Content-Type: application/json');
try {
// retrieve JSON from POST body
$jsonStr = file_get_contents('php://input');
$jsonObj = json_decode($jsonStr);
// Create a PaymentIntent with amount and currency
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => calculateOrderAmount($jsonObj->items),
'currency' => 'inr',
'automatic_payment_methods' => [
'enabled' => true,
],
]);
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
echo json_encode($output);
} catch (Error $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
Here is the amount:
'amount' => calculateOrderAmount($jsonObj->items),
What is this // The items the customer wants to buy
const items = [{ id: "xl-tshirt" }];
is it mandatory
That's the card of the user, passed from the frontend to the backend. But you don't have to use this at all.
You can see a simpler example of the Payment Element + PaymentIntent, without this item: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
One more question can we prefill the email or can we make email optional
Yes you can with this to remove the field (but you'll have to pass the email when confirming the PaymentIntent): https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields
Or use this for a default value (which is simpler): https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-defaultValues
it is still shows Your email address is incomplete. after make email never
var paymentElement = elements.create('payment', {
fields: {
billingDetails: {
name: 'never',
email: 'never',
}
}
});
it still shows email required
If you use email: 'never', then you need to do this part also:
pass the email when confirming the PaymentIntent
how I am not getting you
It's a two step process:
- Set
email: 'never' - And also pass the email when you confirm the PaymentIntent in
confirmParams.payment_method_data.billing_details.email: "foo@bar.com"https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-payment_method_data-billing_details
You are missing step 2.
Or, the other option, is to prefill the email with this, which is simpler: <Or use this for a default value (which is simpler): https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-defaultValues>
But I want to make email as optional
You can't make it optional with the Payment Element
How to prefill email or make set default email please show me an example
I already answered both of these questions above.
How to prefill email
Or, the other option, is to prefill the email with this, which is simpler: https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-defaultValues>
or make set default email
It's a two step process:
- Set email: 'never'
- And also pass the email when you confirm the PaymentIntent in confirmParams.payment_method_data.billing_details.email: "foo@bar.com" https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-payment_method_data-billing_details
but I am using PHP
No for the Payment Element you are using JavaScript.
I could not locate confirmParams.payment_method_data.billing_details option
You need to add it when you confirm your PaymentIntent here:
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: "https://google.com",
receipt_email: emailAddress,
},
});
DO you have any integration available with laravel
I am confused this is so messy
documentation is not helpfull at all
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
I only want capture the dynamic payment in india and make emial default that is all I want
why it is so complex
please help me with the php integration dynamica
What's the exact issue you're running into?
Have you tried building this: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements&lang=php
Customer location India is not available
What do you mean?
after follow steps to make email default it still shows email required
please help me out this is insane
Hello
please help me out
What do you mean "to make email default"?
I do not want to collect email from customer I want to email set s default
any update
I want email set default
You can create/fetch a Customer first and add it to the PaymentIntent: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-customer
I do not have custoomer
only need to capture the payment
I have emails in my database
I want to set email from my side not from your side
I know, but you will have to create a Customer like this. Otherwise the email field will be empty.
The email field might be the Link Authrntication Element. What happens if you remove it?