Inchoo / magento2-Inchoo_Stripe

Stripe payment gateway Magento2 extension
56 stars 36 forks source link

JS errors on checkout while using stripe.js branch #13

Open magarence opened 8 years ago

magarence commented 8 years ago

Having troubles while using stripe.js branch - after filling out CC data and placing order, checkout process hangs, there is no order confirmation message (if test CC was valid, it goes through to Stripe, and in Magento backend order is made, complete with transaction), though if an invalid CC was picked (that would return card_declined message), process hangs and in console there are javascript errors:

jquery.js:9666 POST http://dev.dev.com/en/rest/en/V1/carts/mine/payment-information 400 (Bad Request)

error-processor.js:20 Uncaught TypeError: messageContainer.addErrorMessage is not a function

Is stripejs branch compatible with Magento 2.1 ?

magarence commented 8 years ago

Problem was with line:

placeOrder = placeOrderAction(self.getData(), self.redirectAfterPlaceOrder, self.messageContainer);

when it is changed to

placeOrder = placeOrderAction(self.getData(), self.messageContainer);

error messages work fine, though on no error checkout still hangs, because no redirect on success action was defined.

Fix:

define( [ 'jquery', 'Magento_Payment/js/view/payment/cc-form', 'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/model/full-screen-loader', **'Magento_Checkout/js/action/redirect-on-success',** 'Magento_Checkout/js/model/payment/additional-validators', 'Magento_Payment/js/model/credit-card-validation/validator', 'stripejs' ] ...

.done(
    function () {
        self.afterPlaceOrder();

        if (self.redirectAfterPlaceOrder) {
            redirectOnSuccessAction.execute();
        }
    }
)