#ziminny-cards
1 messages · Page 1 of 1 (latest)
hello @flat apex! can you provide the full code snippet where you're attempting to select the card? and what sdk are you using?
ok, i'm using react-native
0.1.4
--- > BACKEND
`router.post("/create-setup-intent", async (req, res) => {
const { customerId } = req.body
try {
// Cria um inteção de pagamento para o usuário logado
const { client_secret } = await stripe.setupIntents.create({
customer: customerId,
payment_method_types: ['card'] ,
});
const ephemeralKey = await stripe.ephemeralKeys.create(
{
customer:customerId
},
{
apiVersion:'2020-08-27'
}
)
return res.json( { client_secret,ephemeralKey:ephemeralKey.secret , customerId })
} catch (error) {
console.log(error);
return res.status(404).json({error:'stripe.messages.errorRetrieveSetupIntents'})
}
});`
-- >> FRONTEND
`export const addPaymentMethod = async (customerIdParam:string) => {
try {
const createSetupIntent = await api.post("/stripe-webhook/create-setup-intent",{
customerId:customerIdParam
})
const {client_secret , ephemeralKey , customerId} = createSetupIntent.data
const paymentMethod = await initPaymentSheet({
setupIntentClientSecret:client_secret,
customerEphemeralKeySecret:ephemeralKey,
customerId
})
if(paymentMethod.error) throw new Error("Error add paymenth method");
console.log(paymentMethod);
return { client_secret , ephemeralKey , customerId}
} catch (error) {
Alert.alert("Error","error add payment method")
}
}`
`export const showStripeModal = async (clientSecret?:string) => {
const present = await presentPaymentSheet({
clientSecret,
})
if(present.error) {
throw new Error(present.error.code);
}
console.log("PRESENT",present);
}`
const {client_secret} = await addPaymentMethod(user.stripe_customer_id) await showStripeModal(client_secret)
initPaymentSheet ->> "paymentOption": undefined,
AND
presentPaymentSheet ->> "paymentOption": undefined,
will take a look, it'll take a while since i'm currently tied up with something else at the moment
ok
heya @flat apex! can you share what is in present?
the customer's secret key
in the case only setupIntent
const present = await presentPaymentSheet({ clientSecret, })
Hello @flat apex
in both , actually there is no error , I would like to know if there is something inside this paymentOptions , I select the card and I would like to know which card was selected , I do not receive this information , or is there another way to know which card was selected ?
initPaymentSheet ->> "paymentOption": undefined,
AND
presentPaymentSheet ->> "paymentOption": undefined,
Is this insidepaymentMethodandpresent?
when the user selects the card , right after the modal lowers , I would like to know which card he selected , I thought he reordered in the paymentMethods list but that does not happen
yes
"expo": "~42.0.1"
"@stripe/stripe-react-native": "0.1.4"
Sorry I am slowly grasp the integration. Let me clarify a few more things
Was that object printed out on these lines?
if(paymentMethod.error) throw new Error("Error add paymenth method");
console.log(paymentMethod);
How was the paymentMethod.error?
Can you also log the paymentMethod.error?
And could you provide your account id as acct_xxx so we can check the log ?
Also from the presentPaymentSheet, could you log both error and present
const { error, paymentOption } = await initPaymentSheet({
// Log both error and paymentOption here
const { error, paymentOption } = await presentPaymentSheet({
// log both error and paymentOption here
Other question is, what do you plan to do with that paymentOption down on the road? That value doesn't contain much information, and it can change each time user switch UI. If you want to retrieve the final PaymentMethod object after user select the Card and confirm with server/Stripe, you might need a different path
Hi , I ended up going to sleep tomorrow I can give you the bill . when you say a different way what would it be? I didn't understand how to add a product that is not a subscription to be honest so I did it like this, I didn't find an example. I have two products that are not monthly as you can see. my idea would be that as soon as the user clicks on the button already make the payment. the problem is that I have a subscription of 95 and two products that are for consumption