diff --git a/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout.test.js b/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout.test.js index a0da70c4e4..253bd611ec 100644 --- a/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout.test.js +++ b/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout.test.js @@ -31,7 +31,7 @@ describe('payments : paypal #checkout', () => { balance: 2, }); - await user.get(endpoint); + await user.get(`${endpoint}?noRedirect=true`); expect(checkoutStub).to.be.calledOnce; expect(checkoutStub.args[0][0].gift).to.eql(undefined); diff --git a/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout_success.test.js b/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout_success.test.js index d42d66c9f8..14b83e55b1 100644 --- a/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout_success.test.js +++ b/test/api/v3/integration/payments/paypal/GET-payments_paypal_checkout_success.test.js @@ -53,7 +53,7 @@ describe('payments : paypal #checkoutSuccess', () => { balance: 2, }); - await user.get(`${endpoint}?PayerID=${customerId}&paymentId=${paymentId}`); + await user.get(`${endpoint}?PayerID=${customerId}&paymentId=${paymentId}&noRedirect=true`); expect(checkoutSuccessStub).to.be.calledOnce; diff --git a/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe.test.js b/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe.test.js index 48b4f4bcb0..20bf11b0f5 100644 --- a/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe.test.js +++ b/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe.test.js @@ -44,7 +44,7 @@ describe('payments : paypal #subscribe', () => { balance: 2, }); - await user.get(`${endpoint}?sub=${subKey}`); + await user.get(`${endpoint}?sub=${subKey}&noRedirect=true`); expect(subscribeStub).to.be.calledOnce; diff --git a/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_cancel.test.js b/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_cancel.test.js index d641d8d385..ef65e0a347 100644 --- a/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_cancel.test.js +++ b/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_cancel.test.js @@ -41,7 +41,7 @@ describe('payments : paypal #subscribeCancel', () => { balance: 2, }); - await user.get(endpoint); + await user.get(`${endpoint}?noRedirect=true`); expect(subscribeCancelStub).to.be.calledOnce; diff --git a/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_success.test.js b/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_success.test.js index bf0b564158..e730183127 100644 --- a/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_success.test.js +++ b/test/api/v3/integration/payments/paypal/GET-payments_paypal_subscribe_success.test.js @@ -42,7 +42,7 @@ describe('payments : paypal #subscribeSuccess', () => { balance: 2, }); - await user.get(`${endpoint}?token=${token}`); + await user.get(`${endpoint}?token=${token}&noRedirect=true`); expect(subscribeSuccessStub).to.be.calledOnce; diff --git a/website/server/controllers/top-level/payments/paypal.js b/website/server/controllers/top-level/payments/paypal.js index 6c3c110217..149f90d3b3 100644 --- a/website/server/controllers/top-level/payments/paypal.js +++ b/website/server/controllers/top-level/payments/paypal.js @@ -29,7 +29,11 @@ api.checkout = { let link = await paypalPayments.checkout({gift}); - res.redirect(link); + if (req.query.noRedirect) { + res.respond(200); + } else { + res.redirect(link); + } }, }; @@ -55,7 +59,11 @@ api.checkoutSuccess = { await paypalPayments.checkoutSuccess({user, gift, paymentId, customerId}); - res.redirect('/'); + if (req.query.noRedirect) { + res.respond(200); + } else { + res.redirect('/'); + } }, }; @@ -80,7 +88,11 @@ api.subscribe = { req.session.paypalBlock = req.query.sub; req.session.groupId = req.query.groupId; - res.redirect(link); + if (req.query.noRedirect) { + res.respond(200); + } else { + res.redirect(link); + } }, }; @@ -108,7 +120,11 @@ api.subscribeSuccess = { await paypalPayments.subscribeSuccess({user, block, groupId, token, headers: req.headers}); - res.redirect('/'); + if (req.query.noRedirect) { + res.respond(200); + } else { + res.redirect('/'); + } }, }; @@ -128,7 +144,11 @@ api.subscribeCancel = { await paypalPayments.subscribeCancel({user, groupId}); - res.redirect('/'); + if (req.query.noRedirect) { + res.respond(200); + } else { + res.redirect('/'); + } }, };