Skip to content

Commit

Permalink
Merge pull request #844 from recurly/venmo-device-data
Browse files Browse the repository at this point in the history
Expose Venmo Device Data
  • Loading branch information
douglaslise authored Aug 4, 2023
2 parents 7474270 + 08fb393 commit 0b94e67
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/recurly/venmo/strategy/braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
braintree.dataCollector.create({ client, paypal: true }, (error, collector) => {
if (error) return this.fail('venmo-braintree-api-error', { cause: error });
debug('Venmo client created');
this.venmo = venmo;
this.emit('ready');
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');
});
});
});
}
Expand All @@ -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 } },
Expand Down

0 comments on commit 0b94e67

Please sign in to comment.