Skip to content

Commit 94fd405

Browse files
authored
[React Native] CX-888: Verify address method (#112)
* CX-888: Verify address method * 3.0.10
1 parent 8c21b61 commit 94fd405

6 files changed

Lines changed: 57 additions & 3 deletions

File tree

__tests__/Lean.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,31 @@ describe('Lean SDK', () => {
255255
expect(initializationURL).toBe(expectedUrl);
256256
});
257257
});
258+
259+
describe('verifyAddress', () => {
260+
it('partial params: returns the correct URL', () => {
261+
const expectedUrl = `https://cdn.leantech.me/link/loader/prod/ae/latest/lean-sdk.html?implementation=webview-hosted-html&implementation_config=platform+mobile&implementation_config=sdk+react_native&implementation_config=os+ios&implementation_config=sdk_version+${pkg.version}&implementation_config=is_version_pinned+false&app_token=9fb9e934-9efb-4e7e-a508-de67c0839be0&sandbox=false&language=en&version=latest&country=ae&env=production&method=verifyAddress&customer_id=test-customer-id&customer_name=test-customer-name&permissions=identity`;
262+
263+
const initializationURL = lean.verifyAddress({
264+
customer_id: 'test-customer-id',
265+
customer_name: 'test-customer-name',
266+
permissions: ['identity'],
267+
});
268+
269+
expect(initializationURL).toBe(expectedUrl);
270+
});
271+
272+
it('all params: returns the correct URL', () => {
273+
const expectedUrl = `https://cdn.leantech.me/link/loader/prod/ae/latest/lean-sdk.html?implementation=webview-hosted-html&implementation_config=platform+mobile&implementation_config=sdk+react_native&implementation_config=os+ios&implementation_config=sdk_version+${pkg.version}&implementation_config=is_version_pinned+false&app_token=9fb9e934-9efb-4e7e-a508-de67c0839be0&sandbox=false&language=en&version=latest&country=ae&env=production&method=verifyAddress&customer_id=test-customer-id&customer_name=test-customer-name&permissions=identity&access_token=test-access-token`;
274+
275+
const initializationURL = lean.verifyAddress({
276+
customer_id: 'test-customer-id',
277+
customer_name: 'test-customer-name',
278+
permissions: ['identity'],
279+
access_token: 'test-access-token',
280+
});
281+
282+
expect(initializationURL).toBe(expectedUrl);
283+
});
284+
});
258285
});

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"main": "src/components/LinkSDK/index.js",
33
"name": "lean-react-native",
4-
"version": "3.0.9",
4+
"version": "3.0.10",
55
"description": "A React Native wrapper for Lean's LinkSDK",
66
"repository": {
77
"type": "git",

src/components/LinkSDK/Lean.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,27 @@ class Lean {
472472

473473
return initializationURL;
474474
}
475+
476+
verifyAddress({permissions, customer_id, customer_name, access_token}) {
477+
const permissionsParams = this.convertPermissionsToURLString(permissions);
478+
const customizationParams = this.convertCustomizationToURLString();
479+
480+
let initializationURL = this.baseUrl
481+
.concat(`&method=${Methods.VERIFY_ADDRESS}`)
482+
.concat(`&${Params.CUSTOMER_ID}=${customer_id}`)
483+
.concat(`&${Params.CUSTOMER_NAME}=${customer_name}`)
484+
.concat(permissionsParams)
485+
.concat(customizationParams);
486+
487+
// only include properties that are set
488+
if (access_token) {
489+
initializationURL = initializationURL.concat(
490+
`&${Params.ACCESS_TOKEN}=${access_token}`,
491+
);
492+
}
493+
494+
return initializationURL;
495+
}
475496
}
476497

477498
export default Lean;

src/components/LinkSDK/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const Params = {
3939
SHOW_BALANCES: 'show_balances',
4040
RECONNECT_ID: 'reconnect_id',
4141
CUSTOMER_ID: 'customer_id',
42+
CUSTOMER_NAME: 'customer_name',
4243
BANK_IDENTIFIER: 'bank_identifier',
4344
ACCOUNT_ID: 'account_id',
4445
PERMISSIONS: 'permissions',
@@ -63,4 +64,5 @@ export const Methods = {
6364
CREATE_BENEFICIARY: 'createBeneficiary',
6465
CREATE_PAYMENT_SOURCE: 'createPaymentSource',
6566
UPDATE_PAYMENT_SOURCE: 'updatePaymentSource',
67+
VERIFY_ADDRESS: 'verifyAddress',
6668
};

src/components/LinkSDK/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const LinkSDK = forwardRef((props, ref) => {
5252
setIsOpen(true);
5353
setInitializationURL(lean.pay(config));
5454
},
55+
verifyAddress: config => {
56+
setIsOpen(true);
57+
setInitializationURL(lean.verifyAddress(config));
58+
},
5559
}));
5660

5761
// The callback fired internally by the SDK to propagate to the user supplied callback and close the webview.

0 commit comments

Comments
 (0)