solidusio-contrib / solidus_afterpay

Apache License 2.0
1 stars 1 forks source link

Fix the success method for Afterpay javascript #33

Closed garciajordy closed 3 years ago

garciajordy commented 3 years ago

image On the latest version of Solidus you should pass the success and error functions as parameters.

A solution would be: from

Spree.ajax({
          method: "POST",
          url: "/solidus_afterpay/checkouts.json",
          data: {
            order_number: orderNumber,
            payment_method_id: paymentMethodId,
          },
        })
          .success(function (response) {
            onSuccess(response);
          })
          .error(function (response) {
            onError(response);
          });

to

   Spree.ajax({
          method: "POST",
          url: "/solidus_afterpay/checkouts.json",
          data: {
            order_number: orderNumber,
            payment_method_id: paymentMethodId,
          },
          success: function (response) {
            onSuccess(response);
          },
          error: function (response) {
            onError(response);
          }
        });

The only question left is: Would this also work for older versions of solidus?

vassalloandrea commented 3 years ago

The only question left is: Would this also work for older versions of solidus?

Yes, the new syntax will work with jQuery 1 👍

vassalloandrea commented 3 years ago

Express checkout JS callbacks are still using the old version on JQuery syntax