From c7fbbad12f11d5af9435cb93374eed9238190608 Mon Sep 17 00:00:00 2001 From: Andi Zitney Date: Mon, 31 Jul 2023 14:23:01 -0700 Subject: [PATCH 1/2] Expose Venmo Device Data --- lib/recurly/venmo/strategy/braintree.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/recurly/venmo/strategy/braintree.js b/lib/recurly/venmo/strategy/braintree.js index 674f1ddff..e9a41d8ac 100644 --- a/lib/recurly/venmo/strategy/braintree.js +++ b/lib/recurly/venmo/strategy/braintree.js @@ -65,11 +65,16 @@ export class BraintreeStrategy extends VenmoStrategy { braintree.client.create({ authorization }, (error, client) => { if (error) return this.fail('venmo-braintree-api-error', { cause: error }); debug('Braintree client created'); - braintree.venmo.create({ client, allowDesktop: true }, (error, venmo) => { - if (error) return this.fail('venmo-braintree-api-error', { cause: error }); - debug('Venmo client created'); - this.venmo = venmo; - this.emit('ready'); + braintree.dataCollector.create({ client, paypal: true }, (error, collector) => { + if (error) return this.fail('venmo-braintree-api-error', { casue: error }); + debug('Device data collector created'); + this.deviceFingerprint = collector.deviceData; + braintree.venmo.create({ client, allowDesktop: true }, (error, venmo) => { + if (error) return this.fail('venmo-braintree-api-error', { cause: error }); + debug('Venmo client created'); + this.venmo = venmo; + this.emit('ready'); + }); }); }); } @@ -82,6 +87,11 @@ export class BraintreeStrategy extends VenmoStrategy { handleVenmoSuccess (payload) { const nameData = normalize(this.form, ['first_name', 'last_name']); + + if (this.deviceFingerprint) { + payload.deviceFingerprint = this.deviceFingerprint; + } + this.recurly.request.post({ route: '/venmo/token', data: { type: 'braintree', payload: { ...payload, values: nameData.values } }, From 08fb393e53b7959f5cbca624df46ec1dc39e0b2a Mon Sep 17 00:00:00 2001 From: Andi Zitney Date: Tue, 1 Aug 2023 09:41:43 -0700 Subject: [PATCH 2/2] typo --- lib/recurly/venmo/strategy/braintree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/recurly/venmo/strategy/braintree.js b/lib/recurly/venmo/strategy/braintree.js index e9a41d8ac..f95fb5b67 100644 --- a/lib/recurly/venmo/strategy/braintree.js +++ b/lib/recurly/venmo/strategy/braintree.js @@ -66,7 +66,7 @@ export class BraintreeStrategy extends VenmoStrategy { if (error) return this.fail('venmo-braintree-api-error', { cause: error }); debug('Braintree client created'); braintree.dataCollector.create({ client, paypal: true }, (error, collector) => { - if (error) return this.fail('venmo-braintree-api-error', { casue: error }); + if (error) return this.fail('venmo-braintree-api-error', { cause: error }); debug('Device data collector created'); this.deviceFingerprint = collector.deviceData; braintree.venmo.create({ client, allowDesktop: true }, (error, venmo) => {