Skip to content

Commit

Permalink
v1.3.2 - Added the Pre-Approval link prop to payer response objects
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarzon committed Mar 20, 2024
1 parent 22614fc commit f80d8ce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
5 changes: 5 additions & 0 deletions creates/payer_create.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const createPayer = (z, bundle) => {
return z.request(options).then((response) => {
response.throwForStatus();
const results = response.data;
if (results) {
// Setup the Pre-Approval link here so integrators don't have to build it themselves
results.preapprovalUrl = `https://app.getpinch.com/preapproval/${bundle.authData.merchant_id}/${results.id}`;
}
return results;
});
};
Expand Down Expand Up @@ -179,6 +183,7 @@ module.exports = {
{ key: 'companyName', label: 'Company Name' },
{ key: 'companyRegistrationNumber', label: 'Company Registration Number' },
{ key: 'metadata', label: 'Metadata' },
{ key: 'preapprovalUrl', label: 'Pre-Approval link'}
],
},
key: 'payer_create',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinch-payments",
"version": "1.3.1",
"version": "1.3.2",
"description": "Pinch is a PCI Compliant, Australian payments platform offering automated Bank Account Direct Debit and Credit Card payments for standard and repeating invoices or standalone transactions.",
"main": "index.js",
"scripts": {
Expand Down
17 changes: 15 additions & 2 deletions triggers/evt_payer_created.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ const perform = (z, bundle) => {
return z.request(options).then((response) => {
response.throwForStatus();
const results = response.data;
return results.data;

const eventPayers = results.data;

if (eventPayers && eventPayers.length > 0) {
eventPayers.forEach(eventPayer => {
if (eventPayer.data && eventPayer.data.payer) {
// Setup the Pre-Approval link here so integrators don't have to build it themselves
eventPayer.data.payer.preapprovalUrl = `https://app.getpinch.com/preapproval/${bundle.authData.merchant_id}/${eventPayer.data.payer.id}`;
}
});
}

return eventPayers;
});
};

Expand All @@ -42,7 +54,8 @@ module.exports = {
{ key: 'data__payer__firstName', type: 'string' },
{ key: 'data__payer__lastName', type: 'string' },
{ key: 'data__payer__emailAddress', type: 'string' },
{ key: 'data__payer__companyName', type: 'string' }
{ key: 'data__payer__companyName', type: 'string' },
{ key: 'data__payer__preapprovalUrl', type: 'string' }
],
},
key: 'evt_payer_created',
Expand Down
15 changes: 13 additions & 2 deletions triggers/evt_payer_updated.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ const perform = (z, bundle) => {
return z.request(options).then((response) => {
response.throwForStatus();
const results = response.data;
return results.data;
const eventPayers = results.data;

if (eventPayers && eventPayers.length > 0) {
eventPayers.forEach(eventPayer => {
if (eventPayer.data && eventPayer.data.payer) {
// Setup the Pre-Approval link here so integrators don't have to build it themselves
eventPayer.data.payer.preapprovalUrl = `https://app.getpinch.com/preapproval/${bundle.authData.merchant_id}/${eventPayer.data.payer.id}`;
}
});
}
return eventPayers;
});
};

Expand All @@ -42,7 +52,8 @@ module.exports = {
{ key: 'data__payer__firstName', type: 'string' },
{ key: 'data__payer__lastName', type: 'string' },
{ key: 'data__payer__emailAddress', type: 'string' },
{ key: 'data__payer__companyName', type: 'string' }
{ key: 'data__payer__companyName', type: 'string' },
{ key: 'data__payer__preapprovalUrl', type: 'string' }
],
},
key: 'evt_payer_updated',
Expand Down

0 comments on commit f80d8ce

Please sign in to comment.