aboutsummaryrefslogtreecommitdiff
path: root/server/config/paypal.js
blob: da6c2c3deac4a6ad60954b0f5846af2211c76296 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const paypal = require('@paypal/checkout-server-sdk');
const {paypalEnvironment, paypalClientId, paypalClientSecret} = require('./env');

function environment() {
  if (paypalEnvironment === 'live')
    return new paypal.core.LiveEnvironment(paypalClientId, paypalClientSecret);
  else
    return new paypal.core.SandboxEnvironment(paypalClientId, paypalClientSecret);
}

function client() {
  return new paypal.core.PayPalHttpClient(environment());
}

module.exports = client;