Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Move payment method list into config.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten-stripe committed Feb 27, 2019
1 parent 2c22b7c commit 7df4c45
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion public/javascripts/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,8 @@
input.parentElement.classList.toggle(
'visible',
input.value === 'card' ||
(paymentMethods[input.value].countries.includes(country) &&
(config.paymentMethods.includes(input.value) &&
paymentMethods[input.value].countries.includes(country) &&
paymentMethods[input.value].currencies.includes(config.currency))
);
}
Expand Down
19 changes: 17 additions & 2 deletions server/node/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ module.exports = {
country: 'US',

// Store currency.
// Note: A few payment methods like iDEAL or SOFORT only work with euros,
// so it's a good common denominator to test both Elements and Sources.
currency: 'eur',

// Supported payment methods for the store.
// Some payment methods support only a subset of currencies.
// Make sure to check the docs: https://stripe.com/docs/sources
paymentMethods: [
// 'ach_credit_transfer', // usd (ACH Credit Transfer payments must be in U.S. Dollars)
'alipay', // Can be aud, cad, eur, gbp, hkd, jpy, nzd, sgd, or usd.
'bancontact', // eur (Bancontact must always use Euros)
'card', // many (https://stripe.com/docs/currencies#presentment-currencies)
'eps', // eur (EPS must always use Euros)
'ideal', // eur (iDEAL must always use Euros)
'giropay', // eur (Giropay must always use Euros)
'multibanco', // eur (Multibanco must always use Euros)
// 'sepa_debit', // Restricted. See docs for activation details: https://stripe.com/docs/sources/sepa-debit
'sofort', // eur (SOFORT must always use Euros)
'wechat', // Can be aud, cad, eur, gbp, hkd, jpy, sgd, or usd.
],

// Configuration for Stripe.
// API Keys: https://dashboard.stripe.com/account/apikeys
// Webhooks: https://dashboard.stripe.com/account/webhooks
Expand Down
15 changes: 2 additions & 13 deletions server/node/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,7 @@ router.post('/payment_intents', async (req, res, next) => {
const paymentIntent = await stripe.paymentIntents.create({
amount,
currency,
payment_method_types: [
// 'ach_credit_transfer', // throws: error: "Invalid currency: eur. The payment method `ach_credit_transfer` only supports the following currencies: usd."
'alipay',
'bancontact',
'card',
'eps',
'ideal',
'giropay',
'multibanco',
'sepa_debit',
'sofort',
'wechat',
], // TODO config & gating
payment_method_types: config.paymentMethods,
});
return res.status(200).json({paymentIntent});
} catch (err) {
Expand Down Expand Up @@ -177,6 +165,7 @@ router.get('/config', (req, res) => {
stripeCountry: config.stripe.country,
country: config.country,
currency: config.currency,
paymentMethods: config.paymentMethods,
});
});

Expand Down

0 comments on commit 7df4c45

Please sign in to comment.