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

paypalcommercecredit payment provider: click_initiate_payment_reject #1847

Open
fresh5447 opened this issue Feb 15, 2023 · 3 comments
Open

Comments

@fresh5447
Copy link
Contributor

I am successfully initializing the paypalcommercecredit payment option, however when I click the "Pay Later" button that is injected, the paypal modal opens and is stuck in a spinning state, and I receive the following error:

Screenshot 2023-02-15 at 3 24 27 PM

Here you can see the payment successfully injecting the pay later option:

Screenshot 2023-02-15 at 3 24 15 PM

This is what my initialization is:

                   const options = {
                        methodId: 'paypalcommercecredit',
                        paypalcommerce: {
                            container: '#checkoutButton--paypalcommercecredit',
                            clientId: clientId,
                            initializesOnCheckoutPage: true,
                            currencyCode: 'USD',
                            submitForm: () => {
                                console.log("paypalcommercecredit submitForm Triggered")
                                getRoot(self).setLoading(true)
                                // Example function
                                getRoot(self).service.submitOrder({payment: { methodId: 'paypalcommercecredit' }})
                                    .then(() => {
                                        return window.location.assign('/checkout/order-confirmation');
                                    }).catch((err) => {
                                        console.error("Order Submit Error", err)
                                        return window.location.assign('/cart.php');
                                    })
                            },
                            onComplete: () => console.log("On Complete Fired"),
                            onRenderButton: (resolve, reject) => {
                                console.log("paypalcommercecredit ON RENDER BUTTON??")
                                const hasError = getRoot(self).service.getState().errors.getInitializePaymentError();
                                if (hasError) {
                                    console.error("PayPal on onRenderButton:", getRoot(self).service.getState().errors.getInitializePaymentError())
                                } else {
                                    console.log("paypalcommercecredit  onRenderButton success")
                                }
                            },
                        },
                    }
                    
                    await service.initializePayment(options);

I have also ensured the PayLater option is enabled in BigCommerce

Screenshot 2023-02-15 at 3 28 58 PM

Currently running @bigcommerce/checkout-sdk" version": "1.183.0"

Any tips on debugging this would be great, thanks!

@animesh1987
Copy link
Contributor

Hey @serhii-tkachenko can your team please take a look at this query?

@serhii-tkachenko
Copy link
Contributor

serhii-tkachenko commented Feb 21, 2023

Hey @fresh5447 👋

As far as I see, this error occurred because onValidate callback is not provided. Also you have several options in paypal commerce object, that don't use in initializePayment method.

                   const options = {
                        methodId: 'paypalcommercecredit',
                        paypalcommerce: {
                            container: '#checkoutButton--paypalcommercecredit',
                            clientId: clientId,
                            submitForm: () => {
                                console.log("paypalcommercecredit submitForm Triggered")
                                getRoot(self).setLoading(true)
                                // Example function
                                getRoot(self).service.submitOrder({payment: { methodId: 'paypalcommercecredit' }})
                                    .then(() => {
                                        return window.location.assign('/checkout/order-confirmation');
                                    }).catch((err) => {
                                        console.error("Order Submit Error", err)
                                        return window.location.assign('/cart.php');
                                    })
                            },
                            onRenderButton: (resolve, reject) => {
                                console.log("paypalcommercecredit ON RENDER BUTTON??")
                                const hasError = getRoot(self).service.getState().errors.getInitializePaymentError();
                                if (hasError) {
                                    console.error("PayPal on onRenderButton:", getRoot(self).service.getState().errors.getInitializePaymentError())
                                } else {
                                    console.log("paypalcommercecredit  onRenderButton success")
                                }
                            },
                            onValidate: (resolve, reject) => {
                                // --- here is you validation code here
                            }
                        },
                    }
                    
                    await service.initializePayment(options);

I might recommend to check the initialization typescript interface for PayPalCommerce here: https://github.com/bigcommerce/checkout-sdk-js/blob/master/packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-payment-initialize-options.ts#L79

Please, let us know if it fixes the issue. Thanks!

@bc-0dp
Copy link
Collaborator

bc-0dp commented Feb 16, 2024

Hi @fresh5447 was this resolved?

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

No branches or pull requests

4 participants