From 8c8f0ea2015baebb6544361b7e6e3f7da0bc12ba Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Thu, 22 Jun 2017 15:13:53 -0600 Subject: [PATCH] Used ajax when canceling from the website (#8697) * Used ajax when canceling from the website * Fixed grammar issue --- .../client-old/js/services/paymentServices.js | 18 +++++++++++++++--- website/common/locales/en/subscriber.json | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/website/client-old/js/services/paymentServices.js b/website/client-old/js/services/paymentServices.js index 1b657b6c63..d45d82250f 100644 --- a/website/client-old/js/services/paymentServices.js +++ b/website/client-old/js/services/paymentServices.js @@ -326,11 +326,23 @@ function($rootScope, User, $http, Content) { paymentMethod = paymentMethod.toLowerCase(); } - var cancelUrl = '/' + paymentMethod + '/subscribe/cancel?_id=' + User.user._id + '&apiToken=' + User.settings.auth.apiToken; + var queryParams = { + _id: User.user._id, + apiToken: User.settings.auth.apiToken, + noRedirect: true, + }; + if (group) { - cancelUrl += '&groupId=' + group._id; + queryParams.groupId = group._id; } - window.location.href = cancelUrl; + + var cancelUrl = '/' + paymentMethod + '/subscribe/cancel?' + $.param(queryParams); + + $http.get(cancelUrl) + .then(function (success) { + alert(window.evn.t('paypalCanceled')); + window.location.href = '/'; + }); } Payments.encodeGift = function(uuid, gift) { diff --git a/website/common/locales/en/subscriber.json b/website/common/locales/en/subscriber.json index 0c16fd4c8a..9db994bf96 100644 --- a/website/common/locales/en/subscriber.json +++ b/website/common/locales/en/subscriber.json @@ -170,5 +170,6 @@ "missingPaymentId": "Missing req.query.paymentId", "missingCustomerId": "Missing req.query.customerId", "missingPaypalBlock": "Missing req.session.paypalBlock", - "missingSubKey": "Missing req.query.sub" + "missingSubKey": "Missing req.query.sub", + "paypalCanceled": "Your subscription has been canceled" }