Skip to content

Commit

Permalink
Consolidate Braintree client version constants to a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasmiller committed Jul 17, 2023
1 parent 46ff06c commit 8824071
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/const/gateway-constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const BRAINTREE_CLIENT_VERSION = '3.96.0';
6 changes: 3 additions & 3 deletions lib/recurly/apple-pay/apple-pay.braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Promise from 'promise';
import { ApplePay } from './apple-pay';
import loadScriptPromise from '../../util/load-script-promise';
import Debug from 'debug';
import { BRAINTREE_CLIENT_VERSION } from '../../const/gateway-constants';

const debug = Debug('recurly:apple-pay:braintree');

const CLIENT_VERSION = '3.76.0';
const LIBS = {
client: 'client',
applePay: 'apple-pay',
Expand All @@ -14,7 +14,7 @@ const LIBS = {

const loadBraintree = (...libs) => {
const loadLib = lib => {
const isLibPresent = window.braintree?.client?.VERSION === CLIENT_VERSION &&
const isLibPresent = window.braintree?.client?.VERSION === BRAINTREE_CLIENT_VERSION &&
lib in window.braintree;

return isLibPresent
Expand All @@ -28,7 +28,7 @@ const loadBraintree = (...libs) => {

export class ApplePayBraintree extends ApplePay {
static libUrl (lib) {
return `https://js.braintreegateway.com/web/${CLIENT_VERSION}/js/${LIBS[lib]}.min.js`;
return `https://js.braintreegateway.com/web/${BRAINTREE_CLIENT_VERSION}/js/${LIBS[lib]}.min.js`;
}

configure (options) {
Expand Down
3 changes: 1 addition & 2 deletions lib/recurly/paypal/strategy/braintree.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import loadScript from 'load-script';
import after from '../../../util/after';
import { PayPalStrategy } from './index';
import { BRAINTREE_CLIENT_VERSION } from '../../../const/gateway-constants';

const debug = require('debug')('recurly:paypal:strategy:braintree');

export const BRAINTREE_CLIENT_VERSION = '3.96.0';

/**
* Braintree-specific PayPal handler
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/risk/three-d-secure/strategy/braintree.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import loadScript from 'load-script';
import Promise from 'promise';
import ThreeDSecureStrategy from './strategy';
import { BRAINTREE_CLIENT_VERSION } from '../../../../const/gateway-constants';

const debug = require('debug')('recurly:risk:three-d-secure:braintree');
const BRAINTREE_CLIENT_VERSION = '3.76.0';

export default class BraintreeStrategy extends ThreeDSecureStrategy {

Expand Down
3 changes: 1 addition & 2 deletions lib/recurly/venmo/strategy/braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import loadScript from 'load-script';
import after from '../../../util/after';
import { VenmoStrategy } from './index';
import { normalize } from '../../../util/normalize';

export const BRAINTREE_CLIENT_VERSION = '3.96.0';
import { BRAINTREE_CLIENT_VERSION } from '../../../const/gateway-constants';

const debug = require('debug')('recurly:paypal:strategy:braintree');

Expand Down
2 changes: 1 addition & 1 deletion test/unit/apple-pay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ApplePaySessionStub.canMakePayments = () => true;

const getBraintreeStub = () => ({
client: {
VERSION: '3.76.0',
VERSION: '3.96.0',
create: sinon.stub().resolves('CLIENT'),
},
dataCollector: {
Expand Down
3 changes: 2 additions & 1 deletion test/unit/support/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import bowser from 'bowser';
import merge from 'lodash.merge';
import { Recurly } from '../../../lib/recurly';
import { BRAINTREE_CLIENT_VERSION } from '../../../lib/recurly/paypal/strategy/braintree';
import { BRAINTREE_CLIENT_VERSION } from '../../../lib/const/gateway-constants';

import Promise from 'promise';

/**
Expand Down

0 comments on commit 8824071

Please sign in to comment.