#adil

1 messages · Page 1 of 1 (latest)

high flowerBOT
inner dust
#

Hi there!

#

How can I help?

inner walrus
#

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

inner dust
#

I'm sorry I don't understand your question.

#

Which Stripe integration are you using? Checkout Session, Payment Element + PaymentIntent, something else?

inner walrus
#

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?

inner dust
#

Can you answer my question above?

Which Stripe integration are you using? Checkout Session, Payment Element + PaymentIntent, something else?

inner walrus
#

I am using Custom payment flow

#

This was suggested yesterday by your colleauge

inner dust
#

I am using Custom payment flow
What is this? Can you share a documentation link or a screenshot?

inner walrus
inner dust
#

So you are using Payment Element + PaymentIntent.

inner walrus
#

Yes

inner dust
#

And when you create the PaymentIntent you can directly set the amount, no?

inner walrus
#

I cant No option available

#

I only want to give the amount of my choice

inner dust
#

How do you create the PaymentIntent now? Can you share your code?

inner walrus
#

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()]);
}

inner dust
#

Here is the amount:

'amount' => calculateOrderAmount($jsonObj->items),

inner walrus
#

What is this // The items the customer wants to buy
const items = [{ id: "xl-tshirt" }];

#

is it mandatory

inner dust
#

That's the card of the user, passed from the frontend to the backend. But you don't have to use this at all.

inner walrus
#

One more question can we prefill the email or can we make email optional

inner dust
inner walrus
#

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

inner dust
#

If you use email: 'never', then you need to do this part also:

pass the email when confirming the PaymentIntent

inner walrus
#

how I am not getting you

inner dust
#

You are missing step 2.

inner walrus
#

But I want to make email as optional

inner dust
#

You can't make it optional with the Payment Element

inner walrus
#

How to prefill email or make set default email please show me an example

inner dust
#

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:

  1. Set email: 'never'
  2. 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
inner walrus
#

but I am using PHP

inner dust
#

No for the Payment Element you are using JavaScript.

inner walrus
#

I could not locate confirmParams.payment_method_data.billing_details option

inner dust
#

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,
    },
  });
inner walrus
#

DO you have any integration available with laravel

#

I am confused this is so messy

#

documentation is not helpfull at all

marsh birch
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

inner walrus
#

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

marsh birch
#

What's the exact issue you're running into?

inner walrus
#

Customer location India is not available

marsh birch
#

What do you mean?

inner walrus
#

after follow steps to make email default it still shows email required

#

please help me out this is insane

#

Hello

#

please help me out

marsh birch
#

What do you mean "to make email default"?

inner walrus
#

I do not want to collect email from customer I want to email set s default

#

any update

#

I want email set default

marsh birch
inner walrus
#

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

marsh birch
#

I know, but you will have to create a Customer like this. Otherwise the email field will be empty.

marsh birch
#

The email field might be the Link Authrntication Element. What happens if you remove it?