#dkmali3055
1 messages · Page 1 of 1 (latest)
Hi there, I don't think there's an option to pre-fill card details in PaymentSheet.
can we show pre filled cardField or cardForm using payment method id or card details ?
Documentation for @stripe/stripe-react-native
Documentation for @stripe/stripe-react-native
Nope, I don't see options for passing in raw card details.
we have any option to use already added payment method or card details to specific user in his future checkout process in mobile application ?
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.
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 ?
Did you pass the Ephemeral key secret to initPaymentSheet ?
yes.
OK, then the PaymentSheet should present with saved payment methods, if any.
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)
What's not working? can you tell me what you expect vs what you get?
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;
}
Still waiting for your answer -> What's not working? can you tell me what you expect vs what you get?
Ok, does this customer has any payment methods attached to it?
yes this customer have payment method like this.
What's the PaymentIntent ID?
"pi_3NhoFuSAuTvt6g5e0mxC1VJt_secret_PhykD0kyF6rbMByrmybrR3YcK",
sorry this is the client secret id.
payment intent id is : pi_3NhofvSAuTvt6g5e1TVidwc1
Does initPaymentSheet return any error?
And also customerEphemeralKeySecret: data.ephemeralKey,, did you pass in the ephemeralKey? or ephemeralKey secret?
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.
Can you confirm if you are passing ek_test_YWNjdF8xTWlWUGhTQXVUdnQ2ZzVlLDVWOERtUHY2WHljR1dORmdpNGhnNjhwTU1pV2FNR3Q_00wPVfX9qC to initPaymentSheet ?
"customer": "cus_OUPAq55nP4isOT", -> I believe this should be customerId