From 37f58b9c4437957b44678c6ab64f941eb8c0ae5a Mon Sep 17 00:00:00 2001 From: Johann Laur Date: Fri, 18 Jun 2021 13:58:13 +0200 Subject: [PATCH] Add possibility to enable/disable payment options for issue #161 --- README.md | 1 + hooks/beforeRegistration.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c0826c..ada4f46 100755 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ $ git clone git@github.com:develodesign/vsf-payment-paypal.git ./vue-storefront/ ```json "paypal": { "clientId": "", + "disabledMethods": ["giropay", "sofort", "card", "credit", "mybank", "sepa"], "addJsToGlobalHead": true, "endpoint": { "complete": "/api/ext/paypal/complete", diff --git a/hooks/beforeRegistration.ts b/hooks/beforeRegistration.ts index 5954897..4bb72de 100755 --- a/hooks/beforeRegistration.ts +++ b/hooks/beforeRegistration.ts @@ -8,7 +8,8 @@ export function beforeRegistration(config, store) { const storeView = currentStoreView() const { currencyCode } = storeView.i18n const clientId = config.paypal.hasOwnProperty('clientId') ? config.paypal.clientId : '' - const sdkUrl = `https://www.paypal.com/sdk/js?client-id=${clientId}¤cy=${currencyCode}&disable-funding=card,credit,mybank,sofort` + const disabledPaymentOptions = config.paypal.disabledMethods ? config.paypal.disabledMethods.join(',') : 'card,credit,mybank,sofort' + const sdkUrl = `https://www.paypal.com/sdk/js?client-id=${clientId}¤cy=${currencyCode}&disable-funding=${disabledPaymentOptions}` var script = document.createElement('script') script.setAttribute('src', sdkUrl) document.head.appendChild(script)