#dkmali3055

1 messages · Page 1 of 1 (latest)

wispy dirgeBOT
obsidian fox
#

Hi there, I don't think there's an option to pre-fill card details in PaymentSheet.

heady ridge
#

can we show pre filled cardField or cardForm using payment method id or card details ?

obsidian fox
#

Nope, I don't see options for passing in raw card details.

heady ridge
#

we have any option to use already added payment method or card details to specific user in his future checkout process in mobile application ?

obsidian fox
#

Sure, you can just pass in an Ephemeral key secret when calling initPaymentSheet, so that PaymentSheet will present the saved payment methods to your customer to choose.

heady ridge
#

i am creating Ephemeral key like this
const response = await this.stripe.ephemeralKeys.create(
{customer: customerId}, { apiVersion: '2020-08-27' }
);

in my node js backend code. is any improvement or changes to achieve my requirement ?

obsidian fox
#

Did you pass the Ephemeral key secret to initPaymentSheet ?

heady ridge
#

yes.

obsidian fox
#

OK, then the PaymentSheet should present with saved payment methods, if any.

heady ridge
#

Thank jack , i will try again.

#

it still not working
this is my backend code

let PaymentObj = {
amount : req.body.amount,
currency : req.body.currency || "INR",
customer : customer.stripeCustomerId,
payment_method_types: ["card"],
setup_future_usage : "off_session",
metadata : {
userId : customer._id.toString(),
productId : req.body.productId,
startDate : req.body.startDate,
endDate : req.body.endDate,
priceId,
productName : products.data.name
}
}

let ephemeralKey = await Stripe.createEphemeralKeys( customer.stripeCustomerId);
const paymentIntent = await Stripe.createPaymentIntent(PaymentObj)
obsidian fox
#

What's not working? can you tell me what you expect vs what you get?

heady ridge
#

and this is my react native code
const fetchPaymentSheetParams = async () => {

const { error } = await initPaymentSheet({
   "customer": "cus_OUPAq55nP4isOT",
  customerEphemeralKeySecret: data.ephemeralKey,
  paymentIntentClientSecret: data.paymentIntent,
  merchantDisplayName: 'Pangel',
  allowsDelayedPaymentMethods: true,
  defaultBillingDetails: {
    "name": "harry poter",
    "email": "harry010@yopmail.com"
  },
})
if (error) {
  setPop(true);
  setPopMessage(`Error code: ${error.code}`, error.message);
} else {
  const res = await presentPaymentSheet();
  console.log('res', res);

}
 }
 })
 .catch(async (err) => {
     setLoading(false)
    if (err.statusCode == 401) {
        await AsyncStorage.removeItem("userData");
         props.navigation.navigate('Login');
     } else {
         responseData = err;
     }
});
return responseData;

}

obsidian fox
#

Still waiting for your answer -> What's not working? can you tell me what you expect vs what you get?

heady ridge
#

i want something like this.

#

i got direct like this.

obsidian fox
#

Ok, does this customer has any payment methods attached to it?

heady ridge
#

yes this customer have payment method like this.

obsidian fox
#

What's the PaymentIntent ID?

heady ridge
#

"pi_3NhoFuSAuTvt6g5e0mxC1VJt_secret_PhykD0kyF6rbMByrmybrR3YcK",

#

sorry this is the client secret id.
payment intent id is : pi_3NhofvSAuTvt6g5e1TVidwc1

obsidian fox
#

Does initPaymentSheet return any error?

#

And also customerEphemeralKeySecret: data.ephemeralKey,, did you pass in the ephemeralKey? or ephemeralKey secret?

heady ridge
#

no i didn't get any error on initPaymentSheet. but i am passing
{
"id": "ephkey_1Nhok2SAuTvt6g5eb4loizLm",
"object": "ephemeral_key",
"associated_objects": [
{
"id": "cus_OUPAq55nP4isOT",
"type": "customer"
}
],
"created": 1692688266,
"expires": 1692691866,
"livemode": false,
"secret": "ek_test_YWNjdF8xTWlWUGhTQXVUdnQ2ZzVlLDVWOERtUHY2WHljR1dORmdpNGhnNjhwTU1pV2FNR3Q_00wPVfX9qC"
}
this secret in customerEphemeralKeySecret in initPaymentSheet.

obsidian fox
#

Can you confirm if you are passing ek_test_YWNjdF8xTWlWUGhTQXVUdnQ2ZzVlLDVWOERtUHY2WHljR1dORmdpNGhnNjhwTU1pV2FNR3Q_00wPVfX9qC to initPaymentSheet ?

heady ridge
#

yes

#

but i not get expected result.

#

can you help me please ?

obsidian fox
#

"customer": "cus_OUPAq55nP4isOT", -> I believe this should be customerId