Closed ShwetaChauhan18 closed 2 years ago
Hi @ShwetaChauhan18 can you try adding
allowsDelayedPaymentMethods: true,
to your initPaymentSheet method?
I already did.
Here is my code,
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
// Enable custom flow
/*customFlow: true,*/
// Main params
merchantDisplayName: 'Flutter Stripe Store Demo',
/*paymentIntentClientSecret:
'pi_3LcR53GVrxoPH8K00Fk4j5F4_secret_WlGh0mFKYe2wlsImrzzZo3qfU',*/
setupIntentClientSecret: 'seti_1Lc0n9GVrxoPH8K03CeVt4ei_secret_MKg9rKCWv1FOJAEDZbmWOHTFapLJJtc',
/*data['paymentIntent'],*/
// Customer keys
/*customerEphemeralKeySecret: data['ephemeralKey'],*/
/*customerId: 'cus_MDbypsfwxoTP6q',*/
// Extra options
applePay: PaymentSheetApplePay(
merchantCountryCode: 'DE',
paymentSummaryItems: [
ApplePayCartSummaryItem.immediate(
label:
'ABC',
amount: "0.0",
),
],
),
googlePay: PaymentSheetGooglePay(merchantCountryCode: 'DE'),
style: ThemeMode.dark,
allowsDelayedPaymentMethods: true,
),
);
Anyone can answer?? I think it's with this flutter implementation because, in stripe dashboard, I am getting SEPA DD option in Checkout page.
Here is our server side code:
async createSubscription(payload: CreateSubscriptionDto): Promise<{
data: Stripe.Response<Stripe.Subscription> | null;
error: Stripe.Errors | null;
}> {
try {
const {
customerId,
priceId,
coupon = null,
trial_end = null,
metadata,
default_payment_method = null,
} = payload;
let payment_behaviour = payload.payment_behaviour;
const PAYMENT_BEHAVIOUR = Object.values(paymentBehaviour);
if (
!payment_behaviour ||
!PAYMENT_BEHAVIOUR.includes(payment_behaviour)
) {
payment_behaviour = paymentBehaviour.DEFAULT_INCOMPLETE;
}
let paymentMethodType: Stripe.Emptyable<
Stripe.SubscriptionCreateParams.PaymentSettings.PaymentMethodType[]
> = ['card'];
const priceInfo: Stripe.Response<Stripe.Price> =
await this.stripeClient.prices.retrieve(priceId);
if (priceInfo?.currency === 'eur') {
paymentMethodType = ['card', 'sepa_debit'];
}
const createSubscription: Stripe.SubscriptionCreateParams = {
customer: customerId,
items: [{ price: priceId }],
coupon,
payment_behavior: payment_behaviour,
expand: ['latest_invoice.payment_intent', 'pending_setup_intent'],
metadata,
payment_settings: {
payment_method_types: paymentMethodType,
},
};
if (trial_end) {
createSubscription.trial_end = trial_end;
createSubscription.payment_behavior = paymentBehaviour.ALLOW_INCOMPLETE;
}
if (default_payment_method) {
createSubscription.default_payment_method = default_payment_method;
}
const subscriptionInfo: Stripe.Response<Stripe.Subscription> =
await this.stripeClient.subscriptions.create(createSubscription);
if (!subscriptionInfo) {
return { data: null, error: null };
}
return { data: subscriptionInfo, error: null };
} catch (error) {
return { data: null, error: error };
}
}
Using this below is ClientSecret which I got and using that ClientSecret I open payment sheet.
{subscriptionId: sub_1Ld6I1GVrxoPH8K0AH6Alnuc, customerId: cus_MJcqkLF2BE29I1, payment_intent: {clientSecret: pi_3Ld6I2GVrxoPH8K02ceAEvai_secret_TFTa0uL1BJMk8G8ReTxlyhHti}, pending_setup_intent: {clientSecret: null}, prices: {price: 1000, currency: eur}, subscriptionStatus: incomplete}}
You can see in attached image, SEPA DD is not showing as payment option.
does it show up when you only enable sepa_debit as paymentMethodType? I tried it in our development (sync) branch and it showed up correctly.
Let me check with your development branch again.
Here is development(sync) branch output.
Here is initPaymentSheet code. (I tried with customFlow: true option also)
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
// Enable custom flow
/*customFlow: true,*/
// Main params
allowsDelayedPaymentMethods: true,
merchantDisplayName: 'Flutter Stripe Store Demo',
paymentIntentClientSecret: 'pi_3Ld6I2GVrxoPH8K02ceAEvai_secret_TFTa0uL1BJMk8G8ReTxlyhHti',
// Customer keys
/*customerEphemeralKeySecret: data['ephemeralKey'],*/
customerId: 'cus_MJcqkLF2BE29I1',
// Extra options
applePay: PaymentSheetApplePay(
merchantCountryCode: 'DE',
),
googlePay: PaymentSheetGooglePay(merchantCountryCode: 'DE'),
style: ThemeMode.dark,
),
);
@jonasbark: Any solution or anything which I missed from my side?? Can you please guide us?
with the latest Flutter Stripe 5.0.0 release, I was able to successfully show sepa_debit payment types in the payment sheet, using allowsDelayedPaymentMethods: true
and enabling sepa_debit in the backend as a singular supported payment type.
@jonasbark : What do you mean by "enabling sepa_debit in the backend as a singular supported payment type"
Can you please confirm, will it work in subscription or not?? Because I am still not getting in your demo.
@jonasbark : Can you please try using this paymentIntentClientSecret and customerID.
allowsDelayedPaymentMethods: true,
merchantDisplayName: 'Flutter Stripe Store Demo',
paymentIntentClientSecret: 'pi_3LeZNeGVrxoPH8K024F9PNkt_secret_TkcnsoHgrmgntO3Cmieyk1BCc',
customerId: 'cus_MJcqkLF2BE29I1',
See here, you can see SEPA DD is available and when I click on this link it will ask detail for SEPA DD: https://invoice.stripe.com/i/acct_1GkcatGVrxoPH8K0/test_YWNjdF8xR2tjYXRHVnJ4b1BIOEswLF9NTksxOVJIdndKWnpiam5Fa0RYenY0QTAzZnhqcUlYLDUyOTEwMDY402005u8UlzDK?s=db
In Mobile payment sheet, It will show error like this:
So, my concern is, will it work in PaymentSheet for subscription??? Just need confirmation.
Describe the bug When I try to create one time payment and using client secret if I open PaymentSheet I am able to get all payment method which is enable. e.g. Card, SEPA Debit Direct.
Now, when I try to do same thing for Subscription then not getting SEPA Direct Debit payment method.
To Reproduce Steps to reproduce the behavior:
Expected behavior All payment method which is enable should show in PaymentSheet for Subscription.
Smartphone / tablet
Some code
Create SetupIntent:
Response for SetupIntent: