#andrej-bacs-future
1 messages · Page 1 of 1 (latest)
Hello, sorry, Discord is quite busy and I missed your thread, looking
@dawn scarab are you using the "defer intent" integration flow?
@astral vine hi, from what I can tell, no. I create the intent at the moment of rendering the <PaymentElement />, before I collect the details
Can you give me an example failed request of similar?
const handleSubmit = async () => {
if (!stripe || !elements) {
return;
}
const data = await stripe.confirmSetup({
elements,
confirmParams: {
return_url: window.location.href,
},
redirect: 'if_required',
});
if (data.error) {
throw new Error(data.error.message);
}
const source = data.setupIntent;
if (!source || !source.id) {
throw Error(i18next.t('error.general'));
}
const paymentMethod = source.payment_method;
if (!hasValue(paymentMethod)) {
throw Error(i18next.t('error.general'));
}
const paymentMethodId = typeof paymentMethod === 'string' ? paymentMethod : paymentMethod.id;
await billPayerMutations.savePaymentMethod({
variables: {paymentMethodId},
});
await refetchPaymentSources?.();
};
Here's the code that handles the submit.
The payment method is being saved, but when I try to pay I get the above error, that's the entire error message.
as I said, other payment methods like Card and ACH work like a charm.
ah wait
so taht entire code works totally fine and the error happens elsewhere?
Like you said "when I try to pay? So it is a completely separate code you never shared? Do you have an example request id I can look at?
Here's the params that I build for making the PaymentIntent when paying:
val baseParams =
paramsBuilder
.setAmount(StripeAccount.toUnits(transaction.cost.amountTotal, account.defaultCurrency))
.setCurrency(account.defaultCurrency.getCurrencyCode)
.setConfirmationMethod(PaymentIntentCreateParams.ConfirmationMethod.MANUAL)
.setOffSession(offSession) // Indicate whether it's off-session for verification/SCA purposes
.setConfirm(true) // Always attempt to confirm as soon as possible
.setStatementDescriptorSuffix(StripeAccount.createPaymentDescriptor(institution))
.addAllPaymentMethodType(paymentMethodTypes.toList.asJava)
.putMetadata("paymentId", transaction.paymentId.toString)
and then I call PaymentIntent.create(intentCreateParams, requestOptions) where requestOptions only has the API key