Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close button on the save credit card frame #105

Closed
jpissis opened this issue Sep 10, 2021 · 5 comments
Closed

Close button on the save credit card frame #105

jpissis opened this issue Sep 10, 2021 · 5 comments

Comments

@jpissis
Copy link

jpissis commented Sep 10, 2021

Thanks for this great plugin.
I implemented on IONIC application and it work perfectly.
However when i process a new payment with a credit card i registered before, and i change my mind and want to cancel, the button "close" launch payment anyway.

To Reproduce
Steps to reproduce the behavior:

  1. Process a payment and click to save the credit card
  2. Process another payment and click to the close button to cancel the payment.
@jpissis jpissis changed the title Close button on the credit save credit card frame Close button on the save credit card frame Sep 10, 2021
@rdlabo
Copy link
Member

rdlabo commented Sep 10, 2021

Thanks for issue.

The button "close" launch payment anyway.

This is unknown trouble. What is this platform? (iOS, Android, Web), and What is method??(PaymentSheet, PaymentFlow, GooglePay, ApplePay)

Thanks.

@jpissis
Copy link
Author

jpissis commented Sep 11, 2021

I use PaymentFlow method on Android device.

My StripeService :

export class StripeService {
    processFlow: 'willReady' | 'Ready' | 'canConfirm' = 'willReady';
    
    constructor(
        private paymentService: PaymentService
    ) {
    }

    async _initializer(): Promise<void> {
        Stripe.addListener(PaymentFlowEventsEnum.Loaded, () => {
            this.processFlow = 'Ready';
            console.log('PaymentFlowEventsEnum.Loaded');
        });

        Stripe.addListener(PaymentFlowEventsEnum.FailedToLoad, () => {
            console.log('PaymentFlowEventsEnum.FailedToLoad');
        });

        Stripe.addListener(PaymentFlowEventsEnum.Completed, () => {
            this.processFlow = 'willReady';
            console.log('PaymentFlowEventsEnum.Completed');
        });

        Stripe.addListener(PaymentFlowEventsEnum.Canceled, () => {
            this.processFlow = 'willReady';
            console.log('PaymentFlowEventsEnum.Canceled');
        });

        Stripe.addListener(PaymentFlowEventsEnum.Failed, () => {
            this.processFlow = 'willReady';
            console.log('PaymentFlowEventsEnum.Failed');
        });

        Stripe.addListener(PaymentFlowEventsEnum.Created, (info) => {
            console.log(info);
            this.processFlow = 'canConfirm';
        });

        await Stripe.initialize({
            publishableKey: environment.stripePK,
        });
    }

    async createPaymentFlow(firebaseId: string, productID: number): Promise<void> {
        const paymentSheetData = await
            this.paymentService
                .createStripePaymentFlow(firebaseId, productID);

        await Stripe.createPaymentFlow({
            paymentIntentClientSecret: paymentSheetData.paymentIntent,
            customerId: paymentSheetData.stripeCustomerID,
            customerEphemeralKeySecret: paymentSheetData.ephemeralKey,
            merchantDisplayName: 'Saveurs application mobile',
        });
    }

    async showCreditCardForm(): Promise<void> {
        await Stripe.presentPaymentFlow();
    }

    async confirmPaymentSuccess(): Promise<boolean> {
        const result = await Stripe.confirmPaymentFlow();

        console.log('===== 1 Confirm paymentFlow');
        console.log('===== 2 result paymentFlow => ' + JSON.stringify(result));

        return (result.paymentResult === 'paymentFlowCompleted');
    }
}

And the method of my angular component :

async subscriptionProcess() {

        await
            this.stripeService
                .createPaymentFlow(this.user.uid, environment.subscriptionProductID)
                .then(async () => {
                    await
                        this.stripeService
                            .showCreditCardForm()
                            .then(async () => {
                                await this.stripeService.confirmPaymentSuccess();
                            });
                });
    }

@rdlabo
Copy link
Member

rdlabo commented Sep 11, 2021

This is not plugin issue, your code issue. Stripe.presentPaymentFlow() return resolve always, when presented paymentSheet.

You must create flow:

  1. Stripe.presentPaymentFlow()
  2. check this.processFlow = 'canConfirm'
  3. App user click confirm payment button
  4. Stripe.confirmPaymentFlow()

Please check demo work . Thanks.

スクリーンショット 2021-09-11 午後4 24 24

@jpissis
Copy link
Author

jpissis commented Sep 11, 2021

Sorry it's my fault.
Many thanks for your return. It works.

@jpissis jpissis closed this as completed Sep 11, 2021
@rdlabo
Copy link
Member

rdlabo commented Jan 19, 2022

@jpissis Did you adapt this plugin for production? If yes, please tell us what app. Please help us to develop this plugin in 2022.
#145
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants