@paydock/client-sdk 1.94.22 → 1.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/slate.md CHANGED
@@ -237,7 +237,7 @@ This example shows how you can use a lot of other methods to settings your form
237
237
  You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#payment-sources-simple-example)
238
238
 
239
239
  This widget provides a list of previously added (saved) payment-sources by customer_id or reference.
240
- The widget provides an opportunity to use events to track the process of selecting payment-sources and provide meta information about the payment-sources.
240
+ The widget provides an opportunity to use events to track the process of selecting payment-sources and provide meta information about the payment-sources.
241
241
 
242
242
  Payment-source requires a query_token that represents a pre-generated and secure token for limiting the list
243
243
  payment-sources, for a specific user or reference.
@@ -266,7 +266,7 @@ list.load();
266
266
  // ES2015 | TypeScript
267
267
 
268
268
  import { HtmlPaymentSourceWidget } from '@paydock/client-sdk/payment-source-widget';
269
-
269
+
270
270
  var list = new HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
271
271
  list.load();
272
272
  ```
@@ -274,7 +274,7 @@ list.load();
274
274
  Then write only need 2 lines of code in js to initialize widget
275
275
 
276
276
 
277
- ### Full example
277
+ ### Full example
278
278
 
279
279
  ```html
280
280
  <!DOCTYPE html>
@@ -286,7 +286,7 @@ Then write only need 2 lines of code in js to initialize widget
286
286
  </head>
287
287
  <body>
288
288
  <div id="list"></div>
289
- <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
289
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
290
290
  <script>
291
291
  var list = new paydock.HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
292
292
  list.load();
@@ -326,9 +326,9 @@ list.on('select', function(data) {
326
326
  });
327
327
  ```
328
328
 
329
- This example shows how you can use a lot of other methods to settings your form
329
+ This example shows how you can use a lot of other methods to settings your form
330
330
 
331
- ### Full example
331
+ ### Full example
332
332
 
333
333
  ```html
334
334
  <!DOCTYPE html>
@@ -341,7 +341,7 @@ This example shows how you can use a lot of other methods to settings your form
341
341
  <body>
342
342
  <div id="list"></div>
343
343
  <input type="text" name="ps_id" />
344
- <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
344
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
345
345
  <script>
346
346
  var list = new paydock.HtmlPaymentSourceWidget('#list', 'publicKey', 'queryToken');
347
347
  list.filterByTypes(['card', 'checkout']);
@@ -351,9 +351,9 @@ This example shows how you can use a lot of other methods to settings your form
351
351
  list.setStyles({
352
352
  icon_size: 'small'
353
353
  });
354
-
354
+
355
355
  list.load();
356
-
356
+
357
357
  list.onSelectInsert('input[name="ps_id"]', 'payment_source_id');
358
358
  list.on('select', function(data) {
359
359
  console.log(data);
@@ -1058,7 +1058,7 @@ This example shows how you can use a lot of other methods to settings your form
1058
1058
  You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#wallet-buttons-simple-example)
1059
1059
 
1060
1060
  Wallet Buttons allow you to easily integrate different E-Wallets into your checkout.
1061
- Currently supports ApplePay, Google Pay, Google Pay and Apple Pay via Stripe, Flypay checkout, Paypal Smart Buttons Checkout and Afterpay.
1061
+ Currently supports ApplePay, Google Pay, Google Pay and Apple Pay via Stripe, Flypay and Flypay V2 checkout, Paypal Smart Buttons Checkout and Afterpay.
1062
1062
 
1063
1063
  If available in your client environment, you will display a simple button that upon clicking it the user will follow the standard flow for the appropriate Wallet. If not available an event will be raised and no button will be displayed.
1064
1064
 
@@ -1103,7 +1103,7 @@ var button = new WalletButtons(
1103
1103
  button.load();
1104
1104
  ```
1105
1105
 
1106
- Flypay and Paypal wallets do not require any meta sent to the wallet, so the following is enough for initialization:
1106
+ Flypay, Flypay V2 and Paypal wallets do not require any meta sent to the wallet, so the following is enough for initialization:
1107
1107
  ```javascript
1108
1108
  let button = new paydock.WalletButtons(
1109
1109
  "#widget",
@@ -1208,7 +1208,7 @@ button.close();
1208
1208
 
1209
1209
  ### Performing actions when shipping info is updated
1210
1210
 
1211
- In Flypay, Paypal and ApplePay via MPGS integrations after each shipping info update the `onUpdate(data)` will be called with the selected shipping address information (plus selected shipping method for Paypal). Merchants should handle this callback, recalculate shipping costs in their server by analyzing the new data, and submit a backend to backend request to `POST charges/:id` with the new total amount and shipping amount (you can find the documentation of this call in the PayDock API documentation).
1211
+ In Flypay, Paypal, ApplePay via MPGS and GooglePay via MPGS integrations after each shipping info update the `onUpdate(data)` will be called with the selected shipping address information, plus selected shipping method when applicable for Paypal, ApplePay and GooglePay. Merchants should handle this callback, recalculate shipping costs in their server by analyzing the new data, and submit a backend to backend request to `POST charges/:id` with the new total amount and shipping amount (you can find the documentation of this call in the PayDock API documentation).
1212
1212
 
1213
1213
  For Paypal integration specifically, if shipping is enabled for the wallet button and different shipping methods were provided in the create wallet charge call, Merchants must ensure that the posted `shipping.amount` to `POST charges/:id` matches the selected shipping option amount (value sent in when initializing the wallet charge). In other words, when providing shipping methods the shipping amount is bound to being one of the provided shipping method amount necessarily. Bear in mind that the total charge amount must include the `shipping.amount`, since it represents the full amount to be charged to the customer.
1214
1214
 
@@ -1217,18 +1217,18 @@ After analyzing the new shipping information, and making the post with the updat
1217
1217
  ```javascript
1218
1218
  button.onUpdate((data) => {
1219
1219
  console.log("Updating amount via a backend to backend call to POST charges/:id");
1220
- // call `POST charges/:id` to modify charge
1221
- button.update({ success: true });
1220
+ // call `POST charges/:id` to modify charge
1221
+ button.update({ success: true });
1222
1222
  });
1223
1223
  ```
1224
1224
 
1225
- For ApplePay via MPGS integration specifically, you must return the new `amount` and new `shipping_options` If new options are needed based on the updated shipping data. Before the user authorizes the transaction with Touch ID, Face ID, or passcode, you receive redacted address information (address_country, address_city, address_state, address_postcode), this data can be used to recalculate the amount and new shipping options. (https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact)
1225
+ For ApplePay via MPGS and GooglePay via MPGS integrations, you can also return a new `amount` and new `shipping_options` in case new options are needed based on the updated shipping data. Before the user authorizes the transaction, you receive redacted address information (address_country, address_city, address_state, address_postcode), and this data can be used to recalculate the new amount and new shipping options.
1226
1226
 
1227
1227
  ```javascript
1228
1228
  button.onUpdate((data) => {
1229
1229
  console.log("Updating amount via a backend to backend call to POST charges/:id");
1230
- // call `POST charges/:id` to modify charge
1231
- button.update({
1230
+ // call `POST charges/:id` to modify charge
1231
+ button.update({
1232
1232
  success: true,
1233
1233
  body: {
1234
1234
  amount: 15,
@@ -1240,7 +1240,7 @@ button.onUpdate((data) => {
1240
1240
  amount: "0.00"
1241
1241
  },
1242
1242
  {
1243
- id: "NEW - FastShip",
1243
+ id: "NEW-FastShip",
1244
1244
  label: "NEW - Fast Shipping",
1245
1245
  detail: "Arrives in less than 1 day",
1246
1246
  amount: "10.00"
@@ -1282,7 +1282,7 @@ button.on(EVENT.PAYMENT_ERROR, (data) => console.log("The payment was not succes
1282
1282
 
1283
1283
  This example shows how to use these functions for **Apple and Google Pay via Stripe**:
1284
1284
  _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `wallets`)_
1285
- ### Full example
1285
+ ### Apple and Google Pay via Stripe Full example
1286
1286
 
1287
1287
  ```html
1288
1288
  <!DOCTYPE html>
@@ -1317,8 +1317,8 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `wa
1317
1317
  ```
1318
1318
 
1319
1319
  This example shows how to use these functions for **Paypal Smart Checkout Buttons**:
1320
- _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_later`, `style`)_
1321
- ### Full example
1320
+ _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_later`, `standalone`, `style`)_
1321
+ ### Paypal Smart Checkout Buttons Full example
1322
1322
  ```html
1323
1323
  <!DOCTYPE html>
1324
1324
  <html lang="en">
@@ -1333,26 +1333,27 @@ _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_l
1333
1333
  <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
1334
1334
  <script>
1335
1335
  let button = new paydock.WalletButtons(
1336
- "#widget",
1337
- charge_token,
1338
- {
1339
- request_shipping: true,
1340
- pay_later: true,
1341
- style: {
1342
- layout: 'horizontal',
1343
- color: 'blue',
1344
- shape: 'rect',
1345
- label: 'paypal',
1346
- },
1347
- }
1348
- );
1336
+ "#widget",
1337
+ charge_token,
1338
+ {
1339
+ request_shipping: true,
1340
+ pay_later: true,
1341
+ standalone: false,
1342
+ style: {
1343
+ layout: 'horizontal',
1344
+ color: 'blue',
1345
+ shape: 'rect',
1346
+ label: 'paypal',
1347
+ },
1348
+ }
1349
+ );
1349
1350
  button.setEnv('sandbox');
1350
1351
  button.onUnavailable(() => console.log("No wallet buttons available"));
1351
1352
  button.onUpdate((data) => {
1352
- console.log("Updating amount via a backend to backend call to POST charges/:id");
1353
- // call `POST charges/:id` to modify charge
1354
- button.update({ success: true });
1355
- });
1353
+ console.log("Updating amount via a backend to backend call to POST charges/:id");
1354
+ // call `POST charges/:id` to modify charge
1355
+ button.update({ success: true });
1356
+ });
1356
1357
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1357
1358
  button.onPaymentError((data) => console.log("The payment was not successful"));
1358
1359
  button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
@@ -1361,8 +1362,46 @@ _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_l
1361
1362
  </html>
1362
1363
  ```
1363
1364
 
1364
- This example shows how to use these functions for **Flypay Checkout**.
1365
+ This example shows how to use these functions for **Flypay v1 Wallet**.
1365
1366
  _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_later`, `style`)_
1367
+ ### Flypay Full example
1368
+ ```html
1369
+ <!DOCTYPE html>
1370
+ <html lang="en">
1371
+ <head>
1372
+ <meta charset="UTF-8">
1373
+ <title>Title</title>
1374
+ </head>
1375
+ <body>
1376
+ <h2>Payment using PayDock Wallet Button!</h2>
1377
+ <div id="widget"></div>
1378
+ </body>
1379
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
1380
+ <script>
1381
+ let button = new paydock.WalletButtons(
1382
+ "#widget",
1383
+ charge_token,
1384
+ {
1385
+ request_shipping: true
1386
+ }
1387
+ );
1388
+ button.setEnv('sandbox');
1389
+ button.onUnavailable(() => console.log("No wallet buttons available"));
1390
+ button.onUpdate((data) => {
1391
+ console.log("Updating amount via a backend to backend call to POST charges/:id");
1392
+ // call `POST charges/:id` to modify charge
1393
+ button.update({ success: true });
1394
+ });
1395
+ button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1396
+ button.onPaymentError((data) => console.log("The payment was not successful"));
1397
+ button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
1398
+ button.load();
1399
+ </script>
1400
+ </html>
1401
+ ```
1402
+
1403
+ This example shows how to use these functions for **Flypay v2 Wallet**.
1404
+ _(Required `meta` fields: - . Optional `meta` fields: -)_
1366
1405
  ### Full example
1367
1406
  ```html
1368
1407
  <!DOCTYPE html>
@@ -1380,28 +1419,21 @@ _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_l
1380
1419
  let button = new paydock.WalletButtons(
1381
1420
  "#widget",
1382
1421
  charge_token,
1383
- {
1384
- request_shipping: true
1385
- }
1422
+ {},
1386
1423
  );
1387
1424
  button.setEnv('sandbox');
1388
1425
  button.onUnavailable(() => console.log("No wallet buttons available"));
1389
- button.onUpdate((data) => {
1390
- console.log("Updating amount via a backend to backend call to POST charges/:id");
1391
- // call `POST charges/:id` to modify charge
1392
- button.update({ success: true });
1393
- });
1394
1426
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1395
1427
  button.onPaymentError((data) => console.log("The payment was not successful"));
1396
- button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
1397
1428
  button.load();
1398
1429
  </script>
1399
1430
  </html>
1400
1431
  ```
1401
1432
 
1402
- This example shows how to use these functions for **ApplePay via MPGS**:
1433
+ This example shows how to use these functions for **ApplePay via MPGS** and **GooglePay via MPGS**:
1434
+
1403
1435
  _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`)_
1404
- ### Full example
1436
+ ### ApplePay and GooglePay via MPGS Full example
1405
1437
 
1406
1438
  ```html
1407
1439
  <!DOCTYPE html>
@@ -1423,8 +1455,16 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `ra
1423
1455
  amount_label: "Total",
1424
1456
  country: 'DE',
1425
1457
  request_shipping: true,
1458
+ show_billing_address: true,
1426
1459
  style: {
1427
- button_type: 'buy',
1460
+ google: {
1461
+ button_type: 'buy',
1462
+ button_size_mode: 'static',
1463
+ button_color: 'white',
1464
+ },
1465
+ apple: {
1466
+ button_type: 'buy',
1467
+ },
1428
1468
  },
1429
1469
  shipping_options: [
1430
1470
  {
@@ -1446,14 +1486,40 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `ra
1446
1486
  button.onUnavailable(() => console.log("No wallet buttons available"));
1447
1487
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1448
1488
  button.onPaymentError((data) => console.log("The payment was not successful"));
1489
+ button.onUpdate((data) => {
1490
+ console.log("Updating amount via a backend to backend call to POST charges/:id");
1491
+ // call `POST charges/:id` to modify charge
1492
+ button.update({
1493
+ success: true,
1494
+ body: {
1495
+ amount: 15,
1496
+ shipping_options: [
1497
+ {
1498
+ id: "NEW-FreeShip",
1499
+ label: "NEW - Free Shipping",
1500
+ detail: "Arrives in 3 to 5 days",
1501
+ amount: "0.00"
1502
+ },
1503
+ {
1504
+ id: "NEW-FastShip",
1505
+ label: "NEW - Fast Shipping",
1506
+ detail: "Arrives in less than 1 day",
1507
+ amount: "10.00"
1508
+ }
1509
+ ]
1510
+ }
1511
+ });
1512
+ });
1449
1513
  button.load();
1450
1514
  </script>
1451
1515
  </html>
1452
1516
  ```
1453
1517
 
1454
- Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest` with your own values instead of using the default ones. Below you can see an example on how to initialize the `ApplePayPaymentRequest` with the `raw_data_initialization` meta field:
1518
+ Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest` with your own values instead of using the default ones. Below you can see an example on how to initialize the `ApplePayPaymentRequest` with the `raw_data_initialization` meta field.
1455
1519
 
1456
- ### Raw data initialization example
1520
+ Similarly, for **GooglePay via MPGS** you can initialize the `PaymentMethodSpecification` with your own values instead of using the default ones. Below you can see an example on how to initialize the `PaymentMethodSpecification` with the `raw_data_initialization` meta field.
1521
+
1522
+ ### ApplePay and GooglePay via MPGS Raw data initialization example
1457
1523
 
1458
1524
  ```html
1459
1525
  <!DOCTYPE html>
@@ -1473,23 +1539,48 @@ Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest`
1473
1539
  charge_token,
1474
1540
  {
1475
1541
  raw_data_initialization: {
1476
- countryCode: "AU",
1477
- currencyCode: "AUD",
1478
- merchantCapabilities: ["supports3DS","supportsCredit","supportsDebit"],
1479
- supportedNetworks: ["visa","masterCard","amex","discover"],
1480
- requiredBillingContactFields: ["name","postalAddress"],
1481
- requiredShippingContactFields:["postalAddress","name","phone","email" ],
1482
- total: {
1483
- label: "Total",
1484
- amount: "10",
1485
- type: "final",
1486
- }
1542
+ apple: {
1543
+ countryCode: "AU",
1544
+ currencyCode: "AUD",
1545
+ merchantCapabilities: ["supports3DS","supportsCredit","supportsDebit"],
1546
+ supportedNetworks: ["visa","masterCard","amex","discover"],
1547
+ requiredBillingContactFields: ["name","postalAddress"],
1548
+ requiredShippingContactFields:["postalAddress","name","phone","email" ],
1549
+ total: {
1550
+ label: "Total",
1551
+ amount: "10",
1552
+ type: "final",
1553
+ }
1554
+ },
1555
+ google: {
1556
+ type: "CARD",
1557
+ parameters: {
1558
+ allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
1559
+ allowedCardNetworks: [
1560
+ "AMEX",
1561
+ "DISCOVER",
1562
+ "INTERAC",
1563
+ "JCB",
1564
+ "MASTERCARD",
1565
+ "VISA",
1566
+ ],
1567
+ billingAddressRequired: true,
1568
+ },
1569
+ },
1487
1570
  },
1488
1571
  amount_label: "Total",
1489
1572
  country: 'DE',
1490
1573
  request_shipping: true,
1574
+ show_billing_address: true,
1491
1575
  style: {
1492
- button_type: 'buy',
1576
+ google: {
1577
+ button_type: 'buy',
1578
+ button_size_mode: 'static',
1579
+ button_color: 'white',
1580
+ },
1581
+ apple: {
1582
+ button_type: 'buy',
1583
+ },
1493
1584
  },
1494
1585
  shipping_options: [
1495
1586
  {
@@ -1511,6 +1602,30 @@ Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest`
1511
1602
  button.onUnavailable(() => console.log("No wallet buttons available"));
1512
1603
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1513
1604
  button.onPaymentError((data) => console.log("The payment was not successful"));
1605
+ button.onUpdate((data) => {
1606
+ console.log("Updating amount via a backend to backend call to POST charges/:id");
1607
+ // call `POST charges/:id` to modify charge
1608
+ button.update({
1609
+ success: true,
1610
+ body: {
1611
+ amount: 15,
1612
+ shipping_options: [
1613
+ {
1614
+ id: "NEW-FreeShip",
1615
+ label: "NEW - Free Shipping",
1616
+ detail: "Arrives in 3 to 5 days",
1617
+ amount: "0.00"
1618
+ },
1619
+ {
1620
+ id: "NEW-FastShip",
1621
+ label: "NEW - Fast Shipping",
1622
+ detail: "Arrives in less than 1 day",
1623
+ amount: "10.00"
1624
+ }
1625
+ ]
1626
+ }
1627
+ });
1628
+ });
1514
1629
  button.load();
1515
1630
  </script>
1516
1631
  </html>
@@ -0,0 +1,41 @@
1
+ declare module '@auspayplus/open-payments-checkout' {
2
+ // WindowFeatures type
3
+ type WindowFeatures = {
4
+ width?: number;
5
+ height?: number;
6
+ left?: number;
7
+ popup?: 'yes' | 'no' | '1' | '0';
8
+ resizable?: 'yes' | 'no' | '1' | '0';
9
+ top?: number;
10
+ };
11
+
12
+ // Callbacks type
13
+ interface ICheckoutCallback {
14
+ orderId: string;
15
+ error?: Error;
16
+ }
17
+
18
+ // Constructor options for Checkout
19
+ interface CheckoutOptions {
20
+ orderId: string;
21
+ url: string;
22
+ accessToken?: string;
23
+ refreshToken?: string;
24
+ clientId?: string;
25
+ onCheckoutClosed?: (callbackData: ICheckoutCallback) => void;
26
+ onError?: (callbackData: ICheckoutCallback) => void;
27
+ onPaymentSuccess?: (callbackData: ICheckoutCallback) => void;
28
+ onPaymentError?: (callbackData: ICheckoutCallback) => void;
29
+ onTokensChanged?: ({ accessToken, refreshToken }: { accessToken: string; refreshToken: string; }) => void;
30
+ windowFeatures?: WindowFeatures;
31
+ }
32
+
33
+ // Checkout class declaration
34
+ export class Checkout {
35
+ constructor(options: CheckoutOptions);
36
+ isCheckoutOpen(): boolean;
37
+ listenMessage(): void;
38
+ open(): void;
39
+ close(): void;
40
+ }
41
+ }
@@ -1,3 +1,4 @@
1
1
  /// <reference path="globals/jasmine-ajax/index.d.ts" />
2
2
  /// <reference path="globals/jasmine/index.d.ts" />
3
3
  /// <reference path="globals/jquery/index.d.ts" />
4
+ /// <reference path="globals/@auspayplus/open-payments-checkout/index.d.ts" />