#biswa-flutter-india

1 messages · Page 1 of 1 (latest)

velvet gullBOT
static blaze
golden wedge
#

i am using flutter stripe

static blaze
#

That is actually a third party library so we are less knowledgable about working with it. If you are writing your own Stripe.js code can you send me what code you currently have that is trying to handle this error?

golden wedge
#

is stripe provides a flutter libary>

#

router.post("/stripeInitiate", async function(req,res){
console.log(req.body);
try {
let customerId;

    //Gets the customer who's email id matches the one sent by the client
    const customerList = await stripe.customers.list({
        email: req.body.email,
        limit: 1
    });
    console.log(customerList.data[0]);
    //Checks the if the customer exists, if not creates a new customer
    if (customerList.data.length !== 0) {
        customerId = customerList.data[0].id;
    }
    else {
        const customer = await stripe.customers.create({
            name: req.body.name,
            email: req.body.email,
            address: {
                line1: '510 Townsend St',
                postal_code: '98140',
                city: 'San Francisco',
                state: 'CA',
                country: 'US',
              },
        });
        customerId = customer.data.id;
    }

    //Creates a temporary secret key linked with the customer 
    const ephemeralKey = await stripe.ephemeralKeys.create(
        { customer: customerId },
        { apiVersion: '2022-11-15' }
    );

    //Creates a new payment intent with amount passed in from the client
    const paymentIntent = await stripe.paymentIntents.create({
        amount: parseInt(req.body.amount),
        currency: req.body.currency,
        metadata : req.body.metadata,
        customer: customerId,
        automatic_payment_methods: {enabled: true},
        description: 'Software development services',
    })
    console.log(paymentIntent)
    res.status(200).send({
        paymentIntent: paymentIntent.client_secret,
        ephemeralKey: ephemeralKey.secret,
        customer: customerId,
        success: true,
    })
    
} catch (error) {
    res.status(404).send({ success: false})
}

});

#

This helps or should is send anything else

static blaze
#

So it is expected here because you are creating the intent without passing a pre-saved payment method ID in to the create call

#

So this isn't an error and your front end code should be able to provide the payment method in some way

golden wedge
#

but i am the displaymentsheet collect the card details

#

i mean display payment sheet collects the card data

#

and there is a pay button to

static blaze
#

Are you putting in the card details and submitting the payment?

golden wedge
#

yes

static blaze
#

Is the status staying requires_payment_method after you have submitted the card details?

golden wedge
#

this dialog is auto generated by stripe

#

after providing the payment inteny

static blaze
#

Right, that is expected. The payment intent's status won't move forward until you fill out all of those card details and submit them for payment

golden wedge
#

I filled out all the details with test data

static blaze
#

Did you hit continue and fully submit the payment?

golden wedge
#

yes

misty bobcat
#

Hi, stepping in here and catching up.

golden wedge
#

can you help me with payment integration in flutter

#

i am kind of stuck

austere crystal
#

@golden wedge no one on my team has ever used Flutter and we don't maintain that library so there isn't much we can do to help debug the issues if you don't have detailed information about what's blocking you exactly

golden wedge
#

After clicking on pay nothing happens

#

pi_3Mm1VmSED2Z7drmP0TzLX30n

austere crystal
#

you're an IN-based merchant right now and aren't meeting the requirements so you get an error on confirmation

#

biswa-flutter-india

#

you can see this error straight in the Dashboard if you look

  "id": "pi_3Mm1VmSED2Z7drmP0TzLX30n",
  "object": "payment_intent",
  "last_payment_error": {
    "message": "As per Indian regulations, export transactions require a customer name and address. More info here: https://stripe.com/docs/india-exports",
    "payment_method": {```
golden wedge
#

Okay let me try

austere crystal
#

I feel like the PI confirmation should fail here so that you get a clear error in the API. I'll flag internally