@paydock/client-sdk 1.11.2-beta → 1.11.4
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/README.md +999 -474
- package/bundles/widget.umd.js +501 -1
- package/bundles/widget.umd.min.js +1 -1
- package/lib/api/api-internal.d.ts +2 -0
- package/lib/api/api-internal.js +4 -0
- package/lib/api/api-internal.js.map +1 -1
- package/lib/api/api-service-internal.d.ts +17 -0
- package/lib/api/api-service-internal.js +18 -0
- package/lib/api/api-service-internal.js.map +1 -0
- package/lib/canvas-3ds/services/gpayments-service.js +1 -1
- package/lib/canvas-3ds/services/gpayments-service.js.map +1 -1
- package/lib/components/iframe-event.d.ts +3 -0
- package/lib/components/iframe-event.js +2 -0
- package/lib/components/iframe-event.js.map +1 -1
- package/lib/components/link.d.ts +4 -2
- package/lib/components/link.js +4 -0
- package/lib/components/link.js.map +1 -1
- package/lib/components/param.d.ts +6 -0
- package/lib/components/param.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/secure-remote-commerce/index.d.ts +1 -0
- package/lib/secure-remote-commerce/index.js +2 -0
- package/lib/secure-remote-commerce/index.js.map +1 -0
- package/lib/secure-remote-commerce/interfaces.d.ts +71 -0
- package/lib/secure-remote-commerce/interfaces.js +28 -0
- package/lib/secure-remote-commerce/interfaces.js.map +1 -0
- package/lib/secure-remote-commerce/providers/src-provider.d.ts +10 -0
- package/lib/secure-remote-commerce/providers/src-provider.js +1 -0
- package/lib/secure-remote-commerce/providers/src-provider.js.map +1 -0
- package/lib/secure-remote-commerce/providers/visa-src/helper.d.ts +7 -0
- package/lib/secure-remote-commerce/providers/visa-src/helper.js +36 -0
- package/lib/secure-remote-commerce/providers/visa-src/helper.js.map +1 -0
- package/lib/secure-remote-commerce/providers/visa-src/index.d.ts +1 -0
- package/lib/secure-remote-commerce/providers/visa-src/index.js +2 -0
- package/lib/secure-remote-commerce/providers/visa-src/index.js.map +1 -0
- package/lib/secure-remote-commerce/providers/visa-src/visa-src.d.ts +27 -0
- package/lib/secure-remote-commerce/providers/visa-src/visa-src.js +106 -0
- package/lib/secure-remote-commerce/providers/visa-src/visa-src.js.map +1 -0
- package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.d.ts +8 -0
- package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.js +10 -0
- package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.js.map +1 -0
- package/lib/secure-remote-commerce/secure-remote-commerce.d.ts +162 -0
- package/lib/secure-remote-commerce/secure-remote-commerce.js +237 -0
- package/lib/secure-remote-commerce/secure-remote-commerce.js.map +1 -0
- package/package.json +1 -1
- package/slate.md +261 -3
package/README.md
CHANGED
|
@@ -4868,161 +4868,593 @@ The final method to beginning, the load process of widget to html
|
|
|
4868
4868
|
|
|
4869
4869
|
**Kind**: instance method of [<code>VaultDisplayWidget</code>](#VaultDisplayWidget)
|
|
4870
4870
|
|
|
4871
|
-
##
|
|
4871
|
+
## Wallet Buttons
|
|
4872
|
+
You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#wallet-buttons-simple-example)
|
|
4872
4873
|
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
<dd><p>Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)</p>
|
|
4876
|
-
</dd>
|
|
4877
|
-
</dl>
|
|
4874
|
+
Wallet Buttons allow you to easily integrate different E-Wallets into your checkout.
|
|
4875
|
+
Currently supports ApplePay, Google Pay and Apple Pay via Stripe, Flypay checkout and Paypal Smart Buttons Checkout.
|
|
4878
4876
|
|
|
4879
|
-
|
|
4877
|
+
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.
|
|
4880
4878
|
|
|
4881
|
-
|
|
4882
|
-
<dt><a href="#EVENT">EVENT</a> : <code>object</code></dt>
|
|
4883
|
-
<dd><p>List of available event's name in the wallet button lifecycle</p>
|
|
4884
|
-
</dd>
|
|
4885
|
-
</dl>
|
|
4879
|
+
## Wallet Buttons simple example
|
|
4886
4880
|
|
|
4887
|
-
|
|
4881
|
+
### Container
|
|
4888
4882
|
|
|
4889
|
-
|
|
4890
|
-
<
|
|
4891
|
-
|
|
4892
|
-
</dd>
|
|
4893
|
-
<dt><a href="#IApplePayShippingOption">IApplePayShippingOption</a> : <code>object</code></dt>
|
|
4894
|
-
<dd><p>Interface of Shipping Options for ApplePay</p>
|
|
4895
|
-
</dd>
|
|
4896
|
-
<dt><a href="#IGooglePayShippingOption">IGooglePayShippingOption</a> : <code>object</code></dt>
|
|
4897
|
-
<dd><p>Interface of Shipping Options for GooglePay</p>
|
|
4898
|
-
</dd>
|
|
4899
|
-
<dt><a href="#IPayPalShippingOption">IPayPalShippingOption</a> : <code>object</code></dt>
|
|
4900
|
-
<dd><p>Interface of Shipping Options for PayPal</p>
|
|
4901
|
-
</dd>
|
|
4902
|
-
</dl>
|
|
4883
|
+
```html
|
|
4884
|
+
<div id="widget"></div>
|
|
4885
|
+
```
|
|
4903
4886
|
|
|
4904
|
-
|
|
4887
|
+
You must create a container for the Wallet Buttons. Inside this tag, the button will be initialized.
|
|
4905
4888
|
|
|
4906
|
-
|
|
4907
|
-
Interface of data used by the wallet checkout and payment proccess.
|
|
4889
|
+
Before initializing the button, you must perform a POST request to `charges/wallet` from a secure environment like your server. This call will return a token that is required to load the button and securely complete the payment. You can find the documentation to this call in the PayDock API documentation.
|
|
4908
4890
|
|
|
4909
|
-
|
|
4891
|
+
### Initialization
|
|
4892
|
+
The following is the minimum required initialization parameters for Apple Pay and Google Pay via Stripe:
|
|
4893
|
+
```javascript
|
|
4894
|
+
let button = new paydock.WalletButtons(
|
|
4895
|
+
"#widget",
|
|
4896
|
+
token,
|
|
4897
|
+
{
|
|
4898
|
+
amount_label: "Total",
|
|
4899
|
+
country: "DE",
|
|
4900
|
+
}
|
|
4901
|
+
);
|
|
4902
|
+
button.load();
|
|
4903
|
+
```
|
|
4910
4904
|
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
| [country] | <code>string</code> | Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal]. |
|
|
4915
|
-
| [pay_later] | <code>string</code> | Used to enable Pay Later feature in PayPal Smart Checkout WalletButton integration when available. Optional for [PayPal]. N/A for other wallets. |
|
|
4916
|
-
| [show_billing_address] | <code>boolean</code> | Used to hide/show the billing address on ApplePay and GooglePay popups. Default value is false. Optional for [ApplePay, GooglePay]. N/A for other wallets. |
|
|
4917
|
-
| [request_payer_name] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
4918
|
-
| [request_payer_email] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
4919
|
-
| [request_payer_phone] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
4920
|
-
| [request_shipping] | <code>boolean</code> | Used to request or not shipping address in the Wallet checkout, being able to handle amount changes via the `update` event. Optional for [FlyPay, PayPal, ApplePay, GooglePay]. N/A for [Stripe]. |
|
|
4921
|
-
| [shipping_options] | [<code>Array.<IApplePayShippingOption></code>](#IApplePayShippingOption) \| [<code>Array.<IPayPalShippingOption></code>](#IPayPalShippingOption) | Used to provide available shipping options.(To use shipping_options the request_shipping flag should be true). Optional for [ApplePay]. N/A for the other wallets. |
|
|
4922
|
-
| [merchant_name] | <code>string</code> | Merchant Name used for GooglePay integration via MPGS. Required for [GooglePay]. N/A for other wallets. |
|
|
4923
|
-
| [raw_data_initialization] | <code>object</code> | Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets. |
|
|
4924
|
-
| [style] | <code>object</code> | Used to style PayPal buttons, check possible values at https://developer.paypal.com/docs/business/checkout/reference/style-guide. Also used at ApplePay to select button type. Optional for [PayPal, ApplePay]. N/A for [Stripe, FlyPay]. |
|
|
4925
|
-
| [style.button_type] | <code>object</code> | Used to select ApplePay button type (e.g: 'buy','donate', etc), check possible values at https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css. Optional for [ApplePay]. N/A for other wallets. |
|
|
4926
|
-
| [wallets] | <code>array</code> | By default if this is not sent or empty, we will try to show either Apple Pay or Google Pay buttons. This can be limited sending the following array in this field: ['apple','google]. Optional for [Stripe, ApplePay, GooglePay]. N/A for other wallets. |
|
|
4905
|
+
```javascript--es2015
|
|
4906
|
+
// ES2015 | TypeScript
|
|
4907
|
+
import { WalletButtons } from '@paydock/client-sdk';
|
|
4927
4908
|
|
|
4928
|
-
|
|
4909
|
+
var button = new WalletButtons(
|
|
4910
|
+
'#widget',
|
|
4911
|
+
token,
|
|
4912
|
+
{
|
|
4913
|
+
amount_label: 'Total',
|
|
4914
|
+
country: 'DE',
|
|
4915
|
+
}
|
|
4916
|
+
);
|
|
4917
|
+
button.load();
|
|
4918
|
+
```
|
|
4929
4919
|
|
|
4930
|
-
|
|
4931
|
-
|
|
4920
|
+
Flypay and Paypal wallets do not require any meta sent to the wallet, so the following is enough for initialization:
|
|
4921
|
+
```javascript
|
|
4922
|
+
let button = new paydock.WalletButtons(
|
|
4923
|
+
"#widget",
|
|
4924
|
+
token,
|
|
4925
|
+
{}
|
|
4926
|
+
);
|
|
4927
|
+
button.load();
|
|
4928
|
+
```
|
|
4932
4929
|
|
|
4933
|
-
|
|
4930
|
+
```javascript--es2015
|
|
4931
|
+
// ES2015 | TypeScript
|
|
4932
|
+
import { WalletButtons } from '@paydock/client-sdk';
|
|
4934
4933
|
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4934
|
+
var button = new WalletButtons(
|
|
4935
|
+
'#widget',
|
|
4936
|
+
token,
|
|
4937
|
+
{}
|
|
4938
|
+
);
|
|
4939
|
+
button.load();
|
|
4940
|
+
```
|
|
4941
|
+
### Setting environment
|
|
4942
4942
|
|
|
4943
|
-
|
|
4943
|
+
Current method can change environment. By default environment = sandbox.
|
|
4944
|
+
Bear in mind that you must set an environment before calling `button.load()`.
|
|
4944
4945
|
|
|
4945
|
-
|
|
4946
|
-
|
|
4946
|
+
```javascript
|
|
4947
|
+
button.setEnv('sandbox');
|
|
4948
|
+
```
|
|
4947
4949
|
|
|
4948
|
-
|
|
4950
|
+
### Full example
|
|
4949
4951
|
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4952
|
+
```html
|
|
4953
|
+
<!DOCTYPE html>
|
|
4954
|
+
<html lang="en">
|
|
4955
|
+
<head>
|
|
4956
|
+
<meta charset="UTF-8">
|
|
4957
|
+
<title>Title</title>
|
|
4958
|
+
</head>
|
|
4959
|
+
<body>
|
|
4960
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
4961
|
+
<div id="widget"></div>
|
|
4962
|
+
</body>
|
|
4963
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
4964
|
+
<script>
|
|
4965
|
+
let button = new paydock.WalletButtons(
|
|
4966
|
+
"#widget",
|
|
4967
|
+
token,
|
|
4968
|
+
{
|
|
4969
|
+
amount_label: "Total",
|
|
4970
|
+
country: "DE",
|
|
4971
|
+
}
|
|
4972
|
+
);
|
|
4973
|
+
button.load();
|
|
4974
|
+
</script>
|
|
4975
|
+
</html>
|
|
4976
|
+
```
|
|
4956
4977
|
|
|
4957
|
-
|
|
4978
|
+
## Wallet Buttons advanced example
|
|
4958
4979
|
|
|
4959
|
-
|
|
4960
|
-
Interface of Shipping Options for PayPal
|
|
4980
|
+
### Checking for button availability
|
|
4961
4981
|
|
|
4962
|
-
|
|
4982
|
+
If the customer's browser is not supported, or the customer does not have any card added to their Google Pay or Apple Pay wallets, the button will not load. In this case the callback onUnavailable() will be called. You can define the behavior of this function before loading the button.
|
|
4963
4983
|
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
| [label] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
4968
|
-
| [amount] | <code>string</code> | Amount of the Shipping Option. Required. |
|
|
4969
|
-
| [currency] | <code>string</code> | Currency of the Shipping Option. Required. |
|
|
4970
|
-
| [type] | <code>string</code> | Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required. |
|
|
4984
|
+
```javascript
|
|
4985
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
4986
|
+
```
|
|
4971
4987
|
|
|
4972
|
-
|
|
4988
|
+
### Forcibly closing the checkout
|
|
4973
4989
|
|
|
4974
|
-
|
|
4975
|
-
Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)
|
|
4990
|
+
In some situations you may want to forcibly close the checkout so that your user is back in your checkout screen, fow which you can use this method. Currently supported by Flypay wallet only.
|
|
4976
4991
|
|
|
4977
|
-
|
|
4992
|
+
```javascript
|
|
4993
|
+
button.close();
|
|
4994
|
+
```
|
|
4978
4995
|
|
|
4979
|
-
|
|
4980
|
-
* [new exports.WalletButtons(selector, chargeToken, object)](#new_WalletButtons_new)
|
|
4981
|
-
* [.load()](#WalletButtons+load)
|
|
4982
|
-
* [.update()](#WalletButtons+update)
|
|
4983
|
-
* [.setEnv(env, [alias])](#WalletButtons+setEnv)
|
|
4984
|
-
* [.close()](#WalletButtons+close)
|
|
4985
|
-
* [.on(eventName, [cb])](#WalletButtons+on) ⇒ <code>Promise.<IEventData></code> \| <code>void</code>
|
|
4986
|
-
* [.onUnavailable([handler])](#WalletButtons+onUnavailable)
|
|
4987
|
-
* [.onUpdate([handler])](#WalletButtons+onUpdate)
|
|
4988
|
-
* [.onPaymentSuccessful([handler])](#WalletButtons+onPaymentSuccessful)
|
|
4989
|
-
* [.onPaymentInReview([handler])](#WalletButtons+onPaymentInReview)
|
|
4990
|
-
* [.onPaymentError([handler])](#WalletButtons+onPaymentError)
|
|
4996
|
+
### Performing actions when shipping info is updated
|
|
4991
4997
|
|
|
4992
|
-
|
|
4998
|
+
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).
|
|
4993
4999
|
|
|
4994
|
-
|
|
5000
|
+
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.
|
|
4995
5001
|
|
|
4996
|
-
|
|
4997
|
-
| --- | --- | --- |
|
|
4998
|
-
| selector | <code>string</code> | Selector of html element. Container for the WalletButtons. |
|
|
4999
|
-
| chargeToken | <code>string</code> | token for the wallet transaction, created with a secure call to `POST charges/wallet`. |
|
|
5000
|
-
| object | [<code>IWalletMeta</code>](#IWalletMeta) | data that configures the E-Wallet, which can be shown on checkout page and configures required customer information. |
|
|
5002
|
+
After analyzing the new shipping information, and making the post with the updated charge and shipping amounts if necessary, the `button.update({ success: true/false })` wallet button method needs to be called to resume the interactions with the customer. Not calling this will result in unexpected behavior.
|
|
5001
5003
|
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5004
|
+
```javascript
|
|
5005
|
+
button.onUpdate((data) => {
|
|
5006
|
+
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5007
|
+
// call `POST charges/:id` to modify charge
|
|
5008
|
+
button.update({ success: true });
|
|
5009
|
+
});
|
|
5005
5010
|
```
|
|
5006
|
-
<a name="WalletButtons+load" id="WalletButtons+load"></a>
|
|
5007
5011
|
|
|
5008
|
-
|
|
5009
|
-
Initializes the availability checks and inserts the button if possible.
|
|
5010
|
-
Otherwise function onUnavailable(handler: VoidFunction) will be called.
|
|
5012
|
+
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)
|
|
5011
5013
|
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5014
|
+
```javascript
|
|
5015
|
+
button.onUpdate((data) => {
|
|
5016
|
+
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5017
|
+
// call `POST charges/:id` to modify charge
|
|
5018
|
+
button.update({
|
|
5019
|
+
success: true,
|
|
5020
|
+
body: {
|
|
5021
|
+
amount: 15,
|
|
5022
|
+
shipping_options: [
|
|
5023
|
+
{
|
|
5024
|
+
id: "NEW-FreeShip",
|
|
5025
|
+
label: "NEW - Free Shipping",
|
|
5026
|
+
detail: "Arrives in 3 to 5 days",
|
|
5027
|
+
amount: "0.00"
|
|
5028
|
+
},
|
|
5029
|
+
{
|
|
5030
|
+
id: "NEW - FastShip",
|
|
5031
|
+
label: "NEW - Fast Shipping",
|
|
5032
|
+
detail: "Arrives in less than 1 day",
|
|
5033
|
+
amount: "10.00"
|
|
5034
|
+
}
|
|
5035
|
+
]
|
|
5036
|
+
}
|
|
5037
|
+
});
|
|
5038
|
+
});
|
|
5024
5039
|
```
|
|
5025
|
-
|
|
5040
|
+
|
|
5041
|
+
### Performing actions after the payment is completed
|
|
5042
|
+
|
|
5043
|
+
After the payment is completed, the onPaymentSuccessful(data) will be called if the payment was successful. If the payment was not successful, the function onPaymentError(data) will be called. If fraud check is active for the gateway, a fraud body was sent in the wallet charge initialize call and the fraud service left the charge in review, then the onPaymentInReview(data) will be called.
|
|
5044
|
+
All three callbacks return relevant data according to each one of the scenarios.
|
|
5045
|
+
|
|
5046
|
+
```javascript
|
|
5047
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5048
|
+
```
|
|
5049
|
+
|
|
5050
|
+
```javascript
|
|
5051
|
+
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5052
|
+
```
|
|
5053
|
+
|
|
5054
|
+
```javascript
|
|
5055
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5056
|
+
```
|
|
5057
|
+
### Events
|
|
5058
|
+
The above events can be used in a more generic way via de `on` function, and making use
|
|
5059
|
+
of the corresponding event names.
|
|
5060
|
+
|
|
5061
|
+
```javascript
|
|
5062
|
+
button.on(EVENT.UNAVAILABLE, () => console.log("No wallet buttons available"));
|
|
5063
|
+
button.on(EVENT.UPDATE, (data) => console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5064
|
+
button.on(EVENT.PAYMENT_SUCCESSFUL, (data) => console.log("The payment was successful"));
|
|
5065
|
+
button.on(EVENT.PAYMENT_ERROR, (data) => console.log("The payment was not successful"));
|
|
5066
|
+
```
|
|
5067
|
+
|
|
5068
|
+
This example shows how to use these functions for **Apple and Google Pay via Stripe**:
|
|
5069
|
+
_(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `wallets`)_
|
|
5070
|
+
### Full example
|
|
5071
|
+
|
|
5072
|
+
```html
|
|
5073
|
+
<!DOCTYPE html>
|
|
5074
|
+
<html lang="en">
|
|
5075
|
+
<head>
|
|
5076
|
+
<meta charset="UTF-8">
|
|
5077
|
+
<title>Title</title>
|
|
5078
|
+
</head>
|
|
5079
|
+
<body>
|
|
5080
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5081
|
+
<div id="widget"></div>
|
|
5082
|
+
</body>
|
|
5083
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5084
|
+
<script>
|
|
5085
|
+
let button = new paydock.WalletButtons(
|
|
5086
|
+
"#widget",
|
|
5087
|
+
charge_token,
|
|
5088
|
+
{
|
|
5089
|
+
amount_label: "Total",
|
|
5090
|
+
country: "DE",
|
|
5091
|
+
wallets: ["google", "apple"],
|
|
5092
|
+
}
|
|
5093
|
+
);
|
|
5094
|
+
button.setEnv('sandbox');
|
|
5095
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5096
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5097
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5098
|
+
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5099
|
+
button.load();
|
|
5100
|
+
</script>
|
|
5101
|
+
</html>
|
|
5102
|
+
```
|
|
5103
|
+
|
|
5104
|
+
This example shows how to use these functions for **Paypal Smart Checkout Buttons**:
|
|
5105
|
+
_(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_later`, `style`)_
|
|
5106
|
+
### Full example
|
|
5107
|
+
```html
|
|
5108
|
+
<!DOCTYPE html>
|
|
5109
|
+
<html lang="en">
|
|
5110
|
+
<head>
|
|
5111
|
+
<meta charset="UTF-8">
|
|
5112
|
+
<title>Title</title>
|
|
5113
|
+
</head>
|
|
5114
|
+
<body>
|
|
5115
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5116
|
+
<div id="widget"></div>
|
|
5117
|
+
</body>
|
|
5118
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5119
|
+
<script>
|
|
5120
|
+
let button = new paydock.WalletButtons(
|
|
5121
|
+
"#widget",
|
|
5122
|
+
charge_token,
|
|
5123
|
+
{
|
|
5124
|
+
request_shipping: true,
|
|
5125
|
+
pay_later: true,
|
|
5126
|
+
style: {
|
|
5127
|
+
layout: 'horizontal',
|
|
5128
|
+
color: 'blue',
|
|
5129
|
+
shape: 'rect',
|
|
5130
|
+
label: 'paypal',
|
|
5131
|
+
},
|
|
5132
|
+
}
|
|
5133
|
+
);
|
|
5134
|
+
button.setEnv('sandbox');
|
|
5135
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5136
|
+
button.onUpdate((data) => {
|
|
5137
|
+
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5138
|
+
// call `POST charges/:id` to modify charge
|
|
5139
|
+
button.update({ success: true });
|
|
5140
|
+
});
|
|
5141
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5142
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5143
|
+
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5144
|
+
button.load();
|
|
5145
|
+
</script>
|
|
5146
|
+
</html>
|
|
5147
|
+
```
|
|
5148
|
+
|
|
5149
|
+
This example shows how to use these functions for **Flypay Checkout**.
|
|
5150
|
+
_(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_later`, `style`)_
|
|
5151
|
+
### Full example
|
|
5152
|
+
```html
|
|
5153
|
+
<!DOCTYPE html>
|
|
5154
|
+
<html lang="en">
|
|
5155
|
+
<head>
|
|
5156
|
+
<meta charset="UTF-8">
|
|
5157
|
+
<title>Title</title>
|
|
5158
|
+
</head>
|
|
5159
|
+
<body>
|
|
5160
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5161
|
+
<div id="widget"></div>
|
|
5162
|
+
</body>
|
|
5163
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5164
|
+
<script>
|
|
5165
|
+
let button = new paydock.WalletButtons(
|
|
5166
|
+
"#widget",
|
|
5167
|
+
charge_token,
|
|
5168
|
+
{
|
|
5169
|
+
request_shipping: true
|
|
5170
|
+
}
|
|
5171
|
+
);
|
|
5172
|
+
button.setEnv('sandbox');
|
|
5173
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5174
|
+
button.onUpdate((data) => {
|
|
5175
|
+
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5176
|
+
// call `POST charges/:id` to modify charge
|
|
5177
|
+
button.update({ success: true });
|
|
5178
|
+
});
|
|
5179
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5180
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5181
|
+
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5182
|
+
button.load();
|
|
5183
|
+
</script>
|
|
5184
|
+
</html>
|
|
5185
|
+
```
|
|
5186
|
+
|
|
5187
|
+
This example shows how to use these functions for **ApplePay via MPGS**:
|
|
5188
|
+
_(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`)_
|
|
5189
|
+
### Full example
|
|
5190
|
+
|
|
5191
|
+
```html
|
|
5192
|
+
<!DOCTYPE html>
|
|
5193
|
+
<html lang="en">
|
|
5194
|
+
<head>
|
|
5195
|
+
<meta charset="UTF-8">
|
|
5196
|
+
<title>Title</title>
|
|
5197
|
+
</head>
|
|
5198
|
+
<body>
|
|
5199
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5200
|
+
<div id="widget"></div>
|
|
5201
|
+
</body>
|
|
5202
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5203
|
+
<script>
|
|
5204
|
+
let button = new paydock.WalletButtons(
|
|
5205
|
+
"#widget",
|
|
5206
|
+
charge_token,
|
|
5207
|
+
{
|
|
5208
|
+
amount_label: "Total",
|
|
5209
|
+
country: 'DE',
|
|
5210
|
+
request_shipping: true,
|
|
5211
|
+
style: {
|
|
5212
|
+
button_type: 'buy',
|
|
5213
|
+
},
|
|
5214
|
+
shipping_options: [
|
|
5215
|
+
{
|
|
5216
|
+
id: "FreeShip",
|
|
5217
|
+
label: "Free Shipping",
|
|
5218
|
+
detail: "Arrives in 5 to 7 days",
|
|
5219
|
+
amount: "0.00"
|
|
5220
|
+
},
|
|
5221
|
+
{
|
|
5222
|
+
id: "FastShip",
|
|
5223
|
+
label: "Fast Shipping",
|
|
5224
|
+
detail: "Arrives in 1 day",
|
|
5225
|
+
amount: "10.00"
|
|
5226
|
+
}
|
|
5227
|
+
]
|
|
5228
|
+
}
|
|
5229
|
+
);
|
|
5230
|
+
button.setEnv('sandbox');
|
|
5231
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5232
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5233
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5234
|
+
button.load();
|
|
5235
|
+
</script>
|
|
5236
|
+
</html>
|
|
5237
|
+
```
|
|
5238
|
+
|
|
5239
|
+
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:
|
|
5240
|
+
|
|
5241
|
+
### Raw data initialization example
|
|
5242
|
+
|
|
5243
|
+
```html
|
|
5244
|
+
<!DOCTYPE html>
|
|
5245
|
+
<html lang="en">
|
|
5246
|
+
<head>
|
|
5247
|
+
<meta charset="UTF-8">
|
|
5248
|
+
<title>Title</title>
|
|
5249
|
+
</head>
|
|
5250
|
+
<body>
|
|
5251
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5252
|
+
<div id="widget"></div>
|
|
5253
|
+
</body>
|
|
5254
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5255
|
+
<script>
|
|
5256
|
+
let button = new paydock.WalletButtons(
|
|
5257
|
+
"#widget",
|
|
5258
|
+
charge_token,
|
|
5259
|
+
{
|
|
5260
|
+
raw_data_initialization: {
|
|
5261
|
+
countryCode: "AU",
|
|
5262
|
+
currencyCode: "AUD",
|
|
5263
|
+
merchantCapabilities: ["supports3DS","supportsCredit","supportsDebit"],
|
|
5264
|
+
supportedNetworks: ["visa","masterCard","amex","discover"],
|
|
5265
|
+
requiredBillingContactFields: ["name","postalAddress"],
|
|
5266
|
+
requiredShippingContactFields:["postalAddress","name","phone","email" ],
|
|
5267
|
+
total: {
|
|
5268
|
+
label: "Total",
|
|
5269
|
+
amount: "10",
|
|
5270
|
+
type: "final",
|
|
5271
|
+
}
|
|
5272
|
+
},
|
|
5273
|
+
amount_label: "Total",
|
|
5274
|
+
country: 'DE',
|
|
5275
|
+
request_shipping: true,
|
|
5276
|
+
style: {
|
|
5277
|
+
button_type: 'buy',
|
|
5278
|
+
},
|
|
5279
|
+
shipping_options: [
|
|
5280
|
+
{
|
|
5281
|
+
id: "FreeShip",
|
|
5282
|
+
label: "Free Shipping",
|
|
5283
|
+
detail: "Arrives in 5 to 7 days",
|
|
5284
|
+
amount: "0.00"
|
|
5285
|
+
},
|
|
5286
|
+
{
|
|
5287
|
+
id: "FastShip",
|
|
5288
|
+
label: "Fast Shipping",
|
|
5289
|
+
detail: "Arrives in 1 day",
|
|
5290
|
+
amount: "10.00"
|
|
5291
|
+
}
|
|
5292
|
+
]
|
|
5293
|
+
}
|
|
5294
|
+
);
|
|
5295
|
+
button.setEnv('sandbox');
|
|
5296
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5297
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5298
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5299
|
+
button.load();
|
|
5300
|
+
</script>
|
|
5301
|
+
</html>
|
|
5302
|
+
```
|
|
5303
|
+
## Classes
|
|
5304
|
+
|
|
5305
|
+
<dl>
|
|
5306
|
+
<dt><a href="#WalletButtons">WalletButtons</a></dt>
|
|
5307
|
+
<dd><p>Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)</p>
|
|
5308
|
+
</dd>
|
|
5309
|
+
</dl>
|
|
5310
|
+
|
|
5311
|
+
## Constants
|
|
5312
|
+
|
|
5313
|
+
<dl>
|
|
5314
|
+
<dt><a href="#EVENT">EVENT</a> : <code>object</code></dt>
|
|
5315
|
+
<dd><p>List of available event's name in the wallet button lifecycle</p>
|
|
5316
|
+
</dd>
|
|
5317
|
+
</dl>
|
|
5318
|
+
|
|
5319
|
+
## Interfaces
|
|
5320
|
+
|
|
5321
|
+
<dl>
|
|
5322
|
+
<dt><a href="#IWalletMeta">IWalletMeta</a> : <code>object</code></dt>
|
|
5323
|
+
<dd><p>Interface of data used by the wallet checkout and payment proccess.</p>
|
|
5324
|
+
</dd>
|
|
5325
|
+
<dt><a href="#IApplePayShippingOption">IApplePayShippingOption</a> : <code>object</code></dt>
|
|
5326
|
+
<dd><p>Interface of Shipping Options for ApplePay</p>
|
|
5327
|
+
</dd>
|
|
5328
|
+
<dt><a href="#IGooglePayShippingOption">IGooglePayShippingOption</a> : <code>object</code></dt>
|
|
5329
|
+
<dd><p>Interface of Shipping Options for GooglePay</p>
|
|
5330
|
+
</dd>
|
|
5331
|
+
<dt><a href="#IPayPalShippingOption">IPayPalShippingOption</a> : <code>object</code></dt>
|
|
5332
|
+
<dd><p>Interface of Shipping Options for PayPal</p>
|
|
5333
|
+
</dd>
|
|
5334
|
+
</dl>
|
|
5335
|
+
|
|
5336
|
+
<a name="IWalletMeta" id="IWalletMeta"></a>
|
|
5337
|
+
|
|
5338
|
+
## IWalletMeta : <code>object</code>
|
|
5339
|
+
Interface of data used by the wallet checkout and payment proccess.
|
|
5340
|
+
|
|
5341
|
+
**Kind**: global interface
|
|
5342
|
+
|
|
5343
|
+
| Param | Type | Description |
|
|
5344
|
+
| --- | --- | --- |
|
|
5345
|
+
| [amount_label] | <code>string</code> | Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal]. |
|
|
5346
|
+
| [country] | <code>string</code> | Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal]. |
|
|
5347
|
+
| [pay_later] | <code>string</code> | Used to enable Pay Later feature in PayPal Smart Checkout WalletButton integration when available. Optional for [PayPal]. N/A for other wallets. |
|
|
5348
|
+
| [show_billing_address] | <code>boolean</code> | Used to hide/show the billing address on ApplePay and GooglePay popups. Default value is false. Optional for [ApplePay, GooglePay]. N/A for other wallets. |
|
|
5349
|
+
| [request_payer_name] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
5350
|
+
| [request_payer_email] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
5351
|
+
| [request_payer_phone] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
5352
|
+
| [request_shipping] | <code>boolean</code> | Used to request or not shipping address in the Wallet checkout, being able to handle amount changes via the `update` event. Optional for [FlyPay, PayPal, ApplePay, GooglePay]. N/A for [Stripe]. |
|
|
5353
|
+
| [shipping_options] | [<code>Array.<IApplePayShippingOption></code>](#IApplePayShippingOption) \| [<code>Array.<IPayPalShippingOption></code>](#IPayPalShippingOption) | Used to provide available shipping options.(To use shipping_options the request_shipping flag should be true). Optional for [ApplePay]. N/A for the other wallets. |
|
|
5354
|
+
| [merchant_name] | <code>string</code> | Merchant Name used for GooglePay integration via MPGS. Required for [GooglePay]. N/A for other wallets. |
|
|
5355
|
+
| [raw_data_initialization] | <code>object</code> | Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets. |
|
|
5356
|
+
| [style] | <code>object</code> | Used to style PayPal buttons, check possible values at https://developer.paypal.com/docs/business/checkout/reference/style-guide. Also used at ApplePay to select button type. Optional for [PayPal, ApplePay]. N/A for [Stripe, FlyPay]. |
|
|
5357
|
+
| [style.button_type] | <code>object</code> | Used to select ApplePay button type (e.g: 'buy','donate', etc), check possible values at https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css. Optional for [ApplePay]. N/A for other wallets. |
|
|
5358
|
+
| [wallets] | <code>array</code> | By default if this is not sent or empty, we will try to show either Apple Pay or Google Pay buttons. This can be limited sending the following array in this field: ['apple','google]. Optional for [Stripe, ApplePay, GooglePay]. N/A for other wallets. |
|
|
5359
|
+
|
|
5360
|
+
<a name="IApplePayShippingOption" id="IApplePayShippingOption"></a>
|
|
5361
|
+
|
|
5362
|
+
## IApplePayShippingOption : <code>object</code>
|
|
5363
|
+
Interface of Shipping Options for ApplePay
|
|
5364
|
+
|
|
5365
|
+
**Kind**: global interface
|
|
5366
|
+
|
|
5367
|
+
| Param | Type | Description |
|
|
5368
|
+
| --- | --- | --- |
|
|
5369
|
+
| [id] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
5370
|
+
| [label] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
5371
|
+
| [amount] | <code>string</code> | Amount of the Shipping Option. Required. |
|
|
5372
|
+
| [detail] | <code>string</code> | Details of the Shipping Option. Required. |
|
|
5373
|
+
| [type] | <code>string</code> | Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional. |
|
|
5374
|
+
|
|
5375
|
+
<a name="IGooglePayShippingOption" id="IGooglePayShippingOption"></a>
|
|
5376
|
+
|
|
5377
|
+
## IGooglePayShippingOption : <code>object</code>
|
|
5378
|
+
Interface of Shipping Options for GooglePay
|
|
5379
|
+
|
|
5380
|
+
**Kind**: global interface
|
|
5381
|
+
|
|
5382
|
+
| Param | Type | Description |
|
|
5383
|
+
| --- | --- | --- |
|
|
5384
|
+
| [id] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
5385
|
+
| [label] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
5386
|
+
| [detail] | <code>string</code> | Details of the Shipping Option. Optional. |
|
|
5387
|
+
| [type] | <code>string</code> | Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional. |
|
|
5388
|
+
|
|
5389
|
+
<a name="IPayPalShippingOption" id="IPayPalShippingOption"></a>
|
|
5390
|
+
|
|
5391
|
+
## IPayPalShippingOption : <code>object</code>
|
|
5392
|
+
Interface of Shipping Options for PayPal
|
|
5393
|
+
|
|
5394
|
+
**Kind**: global interface
|
|
5395
|
+
|
|
5396
|
+
| Param | Type | Description |
|
|
5397
|
+
| --- | --- | --- |
|
|
5398
|
+
| [id] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
5399
|
+
| [label] | <code>string</code> | Identifier of the Shipping Option. Required. |
|
|
5400
|
+
| [amount] | <code>string</code> | Amount of the Shipping Option. Required. |
|
|
5401
|
+
| [currency] | <code>string</code> | Currency of the Shipping Option. Required. |
|
|
5402
|
+
| [type] | <code>string</code> | Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required. |
|
|
5403
|
+
|
|
5404
|
+
<a name="WalletButtons" id="WalletButtons"></a>
|
|
5405
|
+
|
|
5406
|
+
## WalletButtons
|
|
5407
|
+
Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)
|
|
5408
|
+
|
|
5409
|
+
**Kind**: global class
|
|
5410
|
+
|
|
5411
|
+
* [WalletButtons](#WalletButtons)
|
|
5412
|
+
* [new exports.WalletButtons(selector, chargeToken, object)](#new_WalletButtons_new)
|
|
5413
|
+
* [.load()](#WalletButtons+load)
|
|
5414
|
+
* [.update()](#WalletButtons+update)
|
|
5415
|
+
* [.setEnv(env, [alias])](#WalletButtons+setEnv)
|
|
5416
|
+
* [.close()](#WalletButtons+close)
|
|
5417
|
+
* [.on(eventName, [cb])](#WalletButtons+on) ⇒ <code>Promise.<IEventData></code> \| <code>void</code>
|
|
5418
|
+
* [.onUnavailable([handler])](#WalletButtons+onUnavailable)
|
|
5419
|
+
* [.onUpdate([handler])](#WalletButtons+onUpdate)
|
|
5420
|
+
* [.onPaymentSuccessful([handler])](#WalletButtons+onPaymentSuccessful)
|
|
5421
|
+
* [.onPaymentInReview([handler])](#WalletButtons+onPaymentInReview)
|
|
5422
|
+
* [.onPaymentError([handler])](#WalletButtons+onPaymentError)
|
|
5423
|
+
|
|
5424
|
+
<a name="new_WalletButtons_new" id="new_WalletButtons_new"></a>
|
|
5425
|
+
|
|
5426
|
+
### new exports.WalletButtons(selector, chargeToken, object)
|
|
5427
|
+
|
|
5428
|
+
| Param | Type | Description |
|
|
5429
|
+
| --- | --- | --- |
|
|
5430
|
+
| selector | <code>string</code> | Selector of html element. Container for the WalletButtons. |
|
|
5431
|
+
| chargeToken | <code>string</code> | token for the wallet transaction, created with a secure call to `POST charges/wallet`. |
|
|
5432
|
+
| object | [<code>IWalletMeta</code>](#IWalletMeta) | data that configures the E-Wallet, which can be shown on checkout page and configures required customer information. |
|
|
5433
|
+
|
|
5434
|
+
**Example**
|
|
5435
|
+
```js
|
|
5436
|
+
var button = new WalletButtons('#wallet-buttons', 'charge-token', { amount_label: 'Total', country: 'us' });
|
|
5437
|
+
```
|
|
5438
|
+
<a name="WalletButtons+load" id="WalletButtons+load"></a>
|
|
5439
|
+
|
|
5440
|
+
### walletButtons.load()
|
|
5441
|
+
Initializes the availability checks and inserts the button if possible.
|
|
5442
|
+
Otherwise function onUnavailable(handler: VoidFunction) will be called.
|
|
5443
|
+
|
|
5444
|
+
**Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
|
|
5445
|
+
**Example**
|
|
5446
|
+
```js
|
|
5447
|
+
var button = new WalletButtons(
|
|
5448
|
+
'#buttons',
|
|
5449
|
+
token,
|
|
5450
|
+
{
|
|
5451
|
+
amount_label: 'Total',
|
|
5452
|
+
country: 'DE',
|
|
5453
|
+
}
|
|
5454
|
+
);
|
|
5455
|
+
button.load();
|
|
5456
|
+
```
|
|
5457
|
+
<a name="WalletButtons+update" id="WalletButtons+update"></a>
|
|
5026
5458
|
|
|
5027
5459
|
### walletButtons.update()
|
|
5028
5460
|
Triggers the update process of the wallet, if available.
|
|
@@ -5264,85 +5696,124 @@ List of available event's name in the wallet button lifecycle
|
|
|
5264
5696
|
| PAYMENT_ERROR | <code>string</code> | <code>"paymentError"</code> |
|
|
5265
5697
|
|
|
5266
5698
|
|
|
5267
|
-
##
|
|
5268
|
-
You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#
|
|
5269
|
-
|
|
5270
|
-
Wallet Buttons allow you to easily integrate different E-Wallets into your checkout.
|
|
5271
|
-
Currently supports ApplePay, Google Pay and Apple Pay via Stripe, Flypay checkout and Paypal Smart Buttons Checkout.
|
|
5699
|
+
## Secure Remote Commerce
|
|
5700
|
+
You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#SRC).
|
|
5272
5701
|
|
|
5273
|
-
|
|
5702
|
+
This widget provides you with the ability to easily integrate with SRC providers. Currently Visa SRC is supported.
|
|
5274
5703
|
|
|
5275
|
-
##
|
|
5704
|
+
## SRC simple example
|
|
5276
5705
|
|
|
5277
5706
|
### Container
|
|
5278
5707
|
|
|
5279
5708
|
```html
|
|
5280
|
-
<div id="
|
|
5709
|
+
<div id="checkoutButton"></div>
|
|
5710
|
+
<div id="checkoutIframe"></div>
|
|
5281
5711
|
```
|
|
5282
5712
|
|
|
5283
|
-
You must create a container for the
|
|
5713
|
+
You must create a container for the initial checkout button, and a different one for the checkout iFrame. Inside the first tag the button will be initialized, and inside the second one the iFrame will be loaded once the button is clicked.
|
|
5284
5714
|
|
|
5285
|
-
Before initializing the button, you must perform a POST request to `charges/wallet` from a secure environment like your server. This call will return a token that is required to load the button and securely complete the payment. You can find the documentation to this call in the PayDock API documentation.
|
|
5286
5715
|
|
|
5287
5716
|
### Initialization
|
|
5288
|
-
The following is the minimum required initialization parameters for Apple Pay and Google Pay via Stripe:
|
|
5289
5717
|
```javascript
|
|
5290
|
-
|
|
5291
|
-
"#
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
}
|
|
5718
|
+
var src = new paydock.SRC(
|
|
5719
|
+
"#checkoutButton",
|
|
5720
|
+
"#checkoutIframe",
|
|
5721
|
+
"scheme_service_id",
|
|
5722
|
+
"paydock_public_key_or_access_token",
|
|
5723
|
+
{}, // meta
|
|
5297
5724
|
);
|
|
5298
|
-
|
|
5725
|
+
src.load();
|
|
5299
5726
|
```
|
|
5300
5727
|
|
|
5301
5728
|
```javascript--es2015
|
|
5302
5729
|
// ES2015 | TypeScript
|
|
5303
|
-
import { WalletButtons } from '@paydock/client-sdk/widget';
|
|
5304
5730
|
|
|
5305
|
-
|
|
5306
|
-
'#widget',
|
|
5307
|
-
token,
|
|
5308
|
-
{
|
|
5309
|
-
amount_label: 'Total',
|
|
5310
|
-
country: 'DE',
|
|
5311
|
-
}
|
|
5312
|
-
);
|
|
5313
|
-
button.load();
|
|
5314
|
-
```
|
|
5731
|
+
import { SRC } from '@paydock/client-sdk';
|
|
5315
5732
|
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
"
|
|
5320
|
-
|
|
5321
|
-
{}
|
|
5733
|
+
var src = new SRC(
|
|
5734
|
+
"#checkoutButton",
|
|
5735
|
+
"#checkoutIframe",
|
|
5736
|
+
"scheme_service_id",
|
|
5737
|
+
"paydock_public_key_or_access_token",
|
|
5738
|
+
{}, // meta
|
|
5322
5739
|
);
|
|
5323
|
-
|
|
5740
|
+
src.load();
|
|
5324
5741
|
```
|
|
5325
5742
|
|
|
5326
|
-
|
|
5327
|
-
// ES2015 | TypeScript
|
|
5328
|
-
import { WalletButtons } from '@paydock/client-sdk/widget';
|
|
5743
|
+
*NOTE:* it's highly recommended to use a Paydock Access Token instead of the public key for security reasons. When creating it, you will need to enable the `Secure Remote Commerce` and add a whiteliste for the domain of your checkout screen.
|
|
5329
5744
|
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5745
|
+
### Full example
|
|
5746
|
+
|
|
5747
|
+
```html
|
|
5748
|
+
<!DOCTYPE html>
|
|
5749
|
+
<html lang="en">
|
|
5750
|
+
<head>
|
|
5751
|
+
<meta charset="UTF-8">
|
|
5752
|
+
<title>Title</title>
|
|
5753
|
+
<style>iframe {border: 0;width: 40%;height: 300px;}</style>
|
|
5754
|
+
</head>
|
|
5755
|
+
<body>
|
|
5756
|
+
<div id="checkoutButton"></div>
|
|
5757
|
+
<div id="checkoutIframe"></div>
|
|
5758
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5759
|
+
<script>
|
|
5760
|
+
var src = new paydock.SRC(
|
|
5761
|
+
"#checkoutButton",
|
|
5762
|
+
"#checkoutIframe",
|
|
5763
|
+
"scheme_service_id",
|
|
5764
|
+
"paydock_public_key_or_access_token",
|
|
5765
|
+
{},
|
|
5766
|
+
);
|
|
5767
|
+
src.load();
|
|
5768
|
+
</script>
|
|
5769
|
+
</body>
|
|
5770
|
+
</html>
|
|
5336
5771
|
```
|
|
5337
|
-
### Setting environment
|
|
5338
5772
|
|
|
5339
|
-
|
|
5340
|
-
|
|
5773
|
+
|
|
5774
|
+
## SRC advanced example
|
|
5775
|
+
|
|
5776
|
+
### Settings
|
|
5341
5777
|
|
|
5342
5778
|
```javascript
|
|
5343
|
-
|
|
5779
|
+
|
|
5780
|
+
src.setEnv('sandbox'); // set enviroment
|
|
5781
|
+
|
|
5782
|
+
src.hideButton(); // hide button
|
|
5783
|
+
|
|
5784
|
+
src.showButton(); // show button
|
|
5785
|
+
|
|
5786
|
+
src.hideCheckout(); // hide checkout iframe
|
|
5787
|
+
|
|
5788
|
+
src.showCheckout(); // show checkout iframe
|
|
5789
|
+
|
|
5790
|
+
src.on('checkoutButtonLoaded', () => {
|
|
5791
|
+
console.log("Button loaded");
|
|
5792
|
+
});
|
|
5793
|
+
|
|
5794
|
+
src.on('checkoutButtonClicked', () => {
|
|
5795
|
+
console.log("Button clicked");
|
|
5796
|
+
});
|
|
5797
|
+
|
|
5798
|
+
src.on('iframeLoaded', () => {
|
|
5799
|
+
console.log("Initial iframe loaded");
|
|
5800
|
+
});
|
|
5801
|
+
|
|
5802
|
+
src.on('checkoutReady', () => {
|
|
5803
|
+
console.log("Checkout ready to be used");
|
|
5804
|
+
});
|
|
5805
|
+
|
|
5806
|
+
src.on('checkoutCompleted', (token) => {
|
|
5807
|
+
console.log(token);
|
|
5808
|
+
});
|
|
5809
|
+
|
|
5810
|
+
src.on('checkoutError', (error) => {
|
|
5811
|
+
console.log(error);
|
|
5812
|
+
});
|
|
5344
5813
|
```
|
|
5345
5814
|
|
|
5815
|
+
Here you can see how you can use this methods to customize your checkout experience
|
|
5816
|
+
|
|
5346
5817
|
### Full example
|
|
5347
5818
|
|
|
5348
5819
|
```html
|
|
@@ -5351,350 +5822,404 @@ button.setEnv('sandbox');
|
|
|
5351
5822
|
<head>
|
|
5352
5823
|
<meta charset="UTF-8">
|
|
5353
5824
|
<title>Title</title>
|
|
5825
|
+
<style>iframe {border: 0;width: 40%;height: 450px;}</style>
|
|
5354
5826
|
</head>
|
|
5355
5827
|
<body>
|
|
5356
|
-
<
|
|
5357
|
-
<div id="
|
|
5358
|
-
|
|
5359
|
-
<script
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
"#
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
country: "DE",
|
|
5367
|
-
}
|
|
5828
|
+
<div id="checkoutButton"></div>
|
|
5829
|
+
<div id="checkoutIframe"></div>
|
|
5830
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5831
|
+
<script>
|
|
5832
|
+
var src = new paydock.SRC(
|
|
5833
|
+
"#checkoutButton",
|
|
5834
|
+
"#checkoutIframe",
|
|
5835
|
+
"scheme_service_id",
|
|
5836
|
+
"paydock_public_key_or_access_token",
|
|
5837
|
+
{},
|
|
5368
5838
|
);
|
|
5369
|
-
|
|
5370
|
-
|
|
5839
|
+
|
|
5840
|
+
src.on('checkoutReady', () => {
|
|
5841
|
+
console.log("Checkout ready to be used");
|
|
5842
|
+
});
|
|
5843
|
+
|
|
5844
|
+
src.on('checkoutCompleted', (token) => {
|
|
5845
|
+
console.log(token);
|
|
5846
|
+
});
|
|
5847
|
+
src.load();
|
|
5848
|
+
</script>
|
|
5849
|
+
</body>
|
|
5371
5850
|
</html>
|
|
5372
5851
|
```
|
|
5373
5852
|
|
|
5374
|
-
##
|
|
5853
|
+
## Customization options for address fields
|
|
5854
|
+
### Shipping address:
|
|
5375
5855
|
|
|
5376
|
-
|
|
5856
|
+
To customize shipping address experience we use a flag that manages how VisaSRC requires or not shipping address to the customer. Options are NONE (default option), POSTAL_COUNTRY or ALL.
|
|
5377
5857
|
|
|
5378
|
-
|
|
5858
|
+
```
|
|
5859
|
+
var src = new paydock.SRC(
|
|
5860
|
+
"#checkoutButton",
|
|
5861
|
+
"#checkoutIframe",
|
|
5862
|
+
"scheme_service_id",
|
|
5863
|
+
"paydock_public_key_or_access_token",
|
|
5864
|
+
{
|
|
5865
|
+
"dpa_transaction_options": {
|
|
5866
|
+
"dpa_shipping_preference": "ALL"
|
|
5867
|
+
}
|
|
5868
|
+
},
|
|
5869
|
+
);
|
|
5870
|
+
```
|
|
5871
|
+
|
|
5872
|
+
With this the Visa popup requires the shipping address from consumer, and these information will be stored in the Paydock charge.
|
|
5873
|
+
|
|
5874
|
+
Another option is at time of creating the charge. Say that you have a different way of collecting the shipping address (outside Paydock checkout), you can then disable the shipping address on our SRC widget and send it when creating the charge creation after getting the One Time Token out of the SRC widget:
|
|
5379
5875
|
|
|
5380
|
-
```javascript
|
|
5381
|
-
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5382
5876
|
```
|
|
5877
|
+
POST v1/charges
|
|
5383
5878
|
|
|
5384
|
-
|
|
5879
|
+
{
|
|
5880
|
+
"amount": "10.00",
|
|
5881
|
+
"currency": "AUD",
|
|
5882
|
+
"token": "token",
|
|
5883
|
+
"customer": {
|
|
5884
|
+
"payment_source": {
|
|
5885
|
+
"gateway_id": "gateway_id"
|
|
5886
|
+
}
|
|
5887
|
+
},
|
|
5888
|
+
"shipping": {
|
|
5889
|
+
"address_line1": "address_line1",
|
|
5890
|
+
"address_line2": "address_line2",
|
|
5891
|
+
"address_line3": "address_line3",
|
|
5892
|
+
"address_city": "address_city",
|
|
5893
|
+
"address_postcode": "address_postcode",
|
|
5894
|
+
"address_state": "address_state",
|
|
5895
|
+
"address_country": "address_country"
|
|
5896
|
+
}
|
|
5897
|
+
}
|
|
5898
|
+
```
|
|
5385
5899
|
|
|
5386
|
-
|
|
5900
|
+
- Billing address:
|
|
5387
5901
|
|
|
5388
|
-
|
|
5389
|
-
|
|
5902
|
+
Billing address fields are always present on the checkout and required when adding a new credit card (or for new consumer checkout). You can send billing fields on the meta data to pre-fill these fields inside the customer object:
|
|
5903
|
+
|
|
5904
|
+
```
|
|
5905
|
+
var src = new paydock.SRC(
|
|
5906
|
+
"#checkoutButton",
|
|
5907
|
+
"#checkoutIframe",
|
|
5908
|
+
"scheme_service_id",
|
|
5909
|
+
"paydock_public_key_or_access_token",
|
|
5910
|
+
{
|
|
5911
|
+
"customer": {
|
|
5912
|
+
"email": "test@email.com",
|
|
5913
|
+
"first_name": "Name",
|
|
5914
|
+
"last_name": "Surname",
|
|
5915
|
+
"phone": {
|
|
5916
|
+
"country_code": "1",
|
|
5917
|
+
"phone": "2124567890"
|
|
5918
|
+
},
|
|
5919
|
+
"payment_source": {
|
|
5920
|
+
"address_line1": "Line 1",
|
|
5921
|
+
"address_line2": "Line 2",
|
|
5922
|
+
"address_city": "Miami",
|
|
5923
|
+
"address_postcode": "33126",
|
|
5924
|
+
"address_state": "FL",
|
|
5925
|
+
"address_country": "US"
|
|
5926
|
+
}
|
|
5927
|
+
}
|
|
5928
|
+
},
|
|
5929
|
+
);
|
|
5390
5930
|
```
|
|
5391
5931
|
|
|
5392
|
-
|
|
5932
|
+
## Personalization Styling
|
|
5393
5933
|
|
|
5394
|
-
|
|
5934
|
+
To improve the experience in the use of the widget, it is allowed to send props that customize the UI.
|
|
5395
5935
|
|
|
5396
|
-
|
|
5936
|
+
### Example code
|
|
5397
5937
|
|
|
5398
|
-
|
|
5938
|
+
```
|
|
5939
|
+
var src = new paydock.SRC(
|
|
5940
|
+
"#checkoutButton",
|
|
5941
|
+
"#checkoutIframe",
|
|
5942
|
+
"scheme_service_id",
|
|
5943
|
+
"paydock_public_key",
|
|
5944
|
+
);
|
|
5945
|
+
|
|
5946
|
+
button.setStyles({"primary_color":"#a83232","button_text_color":"#171e9c","font_family":"sans-serif"})
|
|
5399
5947
|
|
|
5400
|
-
```javascript
|
|
5401
|
-
button.onUpdate((data) => {
|
|
5402
|
-
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5403
|
-
// call `POST charges/:id` to modify charge
|
|
5404
|
-
button.update({ success: true });
|
|
5405
|
-
});
|
|
5406
5948
|
```
|
|
5949
|
+
## Event and Values
|
|
5407
5950
|
|
|
5408
|
-
|
|
5951
|
+
| Event Value | Type | Description |
|
|
5952
|
+
| ------------------- | ------------------- | -------------------------------------------------------------- |
|
|
5953
|
+
| primary_color | <code>string</code> | HEX color for the principal buttons, example : #32a852 |
|
|
5954
|
+
| button_text_color | <code>string</code> | HEX color for the text of the buttons, example : #32a852|
|
|
5955
|
+
| font_family | <code>string</code> | Look more [mozilla.org/color](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family)|
|
|
5956
|
+
| card_schemes | <code>[string] - array of string</code> | Possible values "visa", "mastercard", "amex" and "discover" - Default show all logos
|
|
5409
5957
|
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5958
|
+
## Classes
|
|
5959
|
+
|
|
5960
|
+
<dl>
|
|
5961
|
+
<dt><a href="#SRC">SRC</a></dt>
|
|
5962
|
+
<dd><p>Class SRC include methods for interacting with different secure remote commerce options such as Visa SRC</p>
|
|
5963
|
+
</dd>
|
|
5964
|
+
</dl>
|
|
5965
|
+
|
|
5966
|
+
## Interfaces
|
|
5967
|
+
|
|
5968
|
+
<dl>
|
|
5969
|
+
<dt><a href="#IVisaSRCMeta">IVisaSRCMeta</a> : <code>object</code></dt>
|
|
5970
|
+
<dd><p>Interface of data used for the Visa Checkout.</p>
|
|
5971
|
+
</dd>
|
|
5972
|
+
</dl>
|
|
5973
|
+
|
|
5974
|
+
<a name="IVisaSRCMeta" id="IVisaSRCMeta"></a>
|
|
5975
|
+
|
|
5976
|
+
## IVisaSRCMeta : <code>object</code>
|
|
5977
|
+
Interface of data used for the Visa Checkout.
|
|
5978
|
+
|
|
5979
|
+
**Kind**: global interface
|
|
5980
|
+
|
|
5981
|
+
| Param | Type | Description |
|
|
5982
|
+
| --- | --- | --- |
|
|
5983
|
+
| [srci_transaction_id] | <code>string</code> | Used to identify the SRC Id. |
|
|
5984
|
+
| [dpa_data] | <code>object</code> | Object where the DPA creation data is stored. |
|
|
5985
|
+
| [dpa_data.dpa_presentation_name] | <code>string</code> | Name in which the DPA is presented in. |
|
|
5986
|
+
| [dpa_data.dpa_uri] | <code>string</code> | Used for indicating the DPA URI. |
|
|
5987
|
+
| [dpa_transaction_options] | <code>object</code> | Object that stores options for creating a trasaction with DPA. |
|
|
5988
|
+
| [dpa_transaction_options.dpa_locale] | <code>string</code> | DPA’s preferred locale, example en_US. |
|
|
5989
|
+
| [dpa_transaction_options.dpa_accepted_billing_countries] | <code>Array</code> | Used to indicate list of accepted billing countries for DPA. |
|
|
5990
|
+
| [dpa_transaction_options.dpa_accepted_shipping_countries] | <code>Array</code> | Used to indicate list of accepted shipping countries for DPA. |
|
|
5991
|
+
| [dpa_transaction_options.dpa_billing_preference] | <code>string</code> | Used for listing the enumeration for billing preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'. |
|
|
5992
|
+
| [dpa_transaction_options.dpa_shipping_preference] | <code>string</code> | Used for listing the enumeration for shipping preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'. |
|
|
5993
|
+
| [dpa_transaction_options.consumer_name_requested] | <code>boolean</code> | Used to check if the name of the consumer is needed. |
|
|
5994
|
+
| [dpa_transaction_options.consumer_email_address_requested] | <code>boolean</code> | Used to check if the email of the consumer is needed. |
|
|
5995
|
+
| [dpa_transaction_options.consumer_phone_number_requested] | <code>boolean</code> | Used to check if the phone number of the consumer is needed. |
|
|
5996
|
+
| [dpa_transaction_options.payment_options] | <code>object</code> | Object used to check the payment options that are included. |
|
|
5997
|
+
| [dpa_transaction_options.payment_options.dpa_dynamic_data_ttl_minutes] | <code>number</code> | The minimum requested validity period for the transaction credentials. |
|
|
5998
|
+
| [dpa_transaction_options.payment_options.dynamic_data_type] | <code>string</code> | Used for listing the enumeration for dynamic data types. Options are 'TAVV' and 'DTVV'. |
|
|
5999
|
+
| [dpa_transaction_options.payment_options.dpa_pan_requested] | <code>boolean</code> | Used to check if PAN number was requested. |
|
|
6000
|
+
| [dpa_transaction_options.review_action] | <code>string</code> | Used for listing the enumeration of review actions. Options are 'pay' and 'continue'. |
|
|
6001
|
+
| [dpa_transaction_options.checkout_description] | <code>string</code> | Used for indicating the description of the checkout. |
|
|
6002
|
+
| [dpa_transaction_options.transaction_type] | <code>string</code> | Used for listing the enumeration of the type of the transaction. 'PURCHASE', 'BILL_PAYMENT' and 'MONEY_TRANSFER' |
|
|
6003
|
+
| [dpa_transaction_options.order_type] | <code>string</code> | Used for listing the enumeration of the type of the order. Options are 'REAUTHORIZATION', 'RECURRING' and 'INSTALLMENT'. |
|
|
6004
|
+
| [dpa_transaction_options.transaction_amount] | <code>object</code> | Object used to describe the details of the transaction. |
|
|
6005
|
+
| [dpa_transaction_options.transaction_amount.transaction_amount] | <code>number</code> | Used to indicate the amount of the transaction. |
|
|
6006
|
+
| [dpa_transaction_options.transaction_amount.transaction_currency_code] | <code>string</code> | Used to indicate the currency code of the transaction. 3 letter ISO code format. |
|
|
6007
|
+
| [dpa_transaction_options.merchant_order_id] | <code>string</code> | Used to indicate the merchants order Id. |
|
|
6008
|
+
| [dpa_transaction_options.merchant_category_code] | <code>string</code> | Used to indicate the merchants category code. |
|
|
6009
|
+
| [dpa_transaction_options.merchant_country_code] | <code>string</code> | Used to indicate the merchants country code. 2 letter ISO code format. |
|
|
6010
|
+
| [customer] | <code>object</code> | Object where the customer data is stored to prefill in the checkout. |
|
|
6011
|
+
| [customer.email] | <code>string</code> | Customer email. |
|
|
6012
|
+
| [customer.first_name] | <code>string</code> | Customer first name. |
|
|
6013
|
+
| [customer.last_name] | <code>string</code> | Customer last name. |
|
|
6014
|
+
| [customer.phone] | <code>object</code> | Object where the customer phone is stored. |
|
|
6015
|
+
| [customer.phone.country_code] | <code>string</code> | Customer phone country code (example "1" for US). |
|
|
6016
|
+
| [customer.phone.phone] | <code>string</code> | Customer phone number. |
|
|
6017
|
+
| [customer.payment_source] | <code>object</code> | Object where the customer billing address data is stored. |
|
|
6018
|
+
| [customer.payment_source.address_line1] | <code>string</code> | Customer billing address line 1. |
|
|
6019
|
+
| [customer.payment_source.address_line2] | <code>string</code> | Customer billing address line 2. |
|
|
6020
|
+
| [customer.payment_source.address_city] | <code>string</code> | Customer billing address city. |
|
|
6021
|
+
| [customer.payment_source.address_postcode] | <code>string</code> | Customer billing address postcode. |
|
|
6022
|
+
| [customer.payment_source.address_state] | <code>string</code> | Customer billing address state code (if applicable for the country, example "FL" for Florida). |
|
|
6023
|
+
| [customer.payment_source.address_country] | <code>string</code> | Customer billing address country code (example "US"). |
|
|
6024
|
+
|
|
6025
|
+
<a name="SRC" id="SRC"></a>
|
|
6026
|
+
|
|
6027
|
+
## SRC
|
|
6028
|
+
Class SRC include methods for interacting with different secure remote commerce options such as Visa SRC
|
|
6029
|
+
|
|
6030
|
+
**Kind**: global class
|
|
6031
|
+
|
|
6032
|
+
* [SRC](#SRC)
|
|
6033
|
+
* [new exports.SRC(button_selector, iframe_selector, service_id, public_key_or_access_token, meta)](#new_SRC_new)
|
|
6034
|
+
* [.setStyles(fields)](#SRC+setStyles)
|
|
6035
|
+
* [.load()](#SRC+load)
|
|
6036
|
+
* [.setEnv(env, [alias])](#SRC+setEnv)
|
|
6037
|
+
* [.getEnv()](#SRC+getEnv)
|
|
6038
|
+
* [.on(eventName, [cb])](#SRC+on) ⇒ <code>Promise.<any></code> \| <code>void</code>
|
|
6039
|
+
* [.hideButton([saveSize])](#SRC+hideButton)
|
|
6040
|
+
* [.showButton()](#SRC+showButton)
|
|
6041
|
+
* [.hideCheckout([saveSize])](#SRC+hideCheckout)
|
|
6042
|
+
* [.showCheckout()](#SRC+showCheckout)
|
|
6043
|
+
* [.reload()](#SRC+reload)
|
|
6044
|
+
* [.useAutoResize()](#SRC+useAutoResize)
|
|
6045
|
+
|
|
6046
|
+
<a name="new_SRC_new" id="new_SRC_new"></a>
|
|
6047
|
+
|
|
6048
|
+
### new exports.SRC(button_selector, iframe_selector, service_id, public_key_or_access_token, meta)
|
|
6049
|
+
|
|
6050
|
+
| Param | Type | Description |
|
|
6051
|
+
| --- | --- | --- |
|
|
6052
|
+
| button_selector | <code>string</code> | Selector of html element. Container for SRC checkout button. |
|
|
6053
|
+
| iframe_selector | <code>string</code> | Selector of html element. Container for SRC checkout iFrame. |
|
|
6054
|
+
| service_id | <code>string</code> | Card Scheme Service ID |
|
|
6055
|
+
| public_key_or_access_token | <code>string</code> | Paydock public key or Access Token |
|
|
6056
|
+
| meta | [<code>IVisaSRCMeta</code>](#IVisaSRCMeta) | Data that configures the SRC checkout |
|
|
6057
|
+
|
|
6058
|
+
**Example**
|
|
6059
|
+
```js
|
|
6060
|
+
var SRC = new SRC('#checkoutButton', '#checkoutIframe', 'service_id', 'public_key', {});
|
|
6061
|
+
```
|
|
6062
|
+
<a name="SRC+setStyles" id="SRC+setStyles"></a>
|
|
6063
|
+
|
|
6064
|
+
### srC.setStyles(fields)
|
|
6065
|
+
Object contain styles for widget - call before `.load()`.
|
|
6066
|
+
|
|
6067
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6068
|
+
|
|
6069
|
+
| Param | Type | Description |
|
|
6070
|
+
| --- | --- | --- |
|
|
6071
|
+
| fields | <code>IStyles</code> | name of styles which can be shown in widget [STYLE](STYLE) |
|
|
6072
|
+
|
|
6073
|
+
**Example**
|
|
6074
|
+
```js
|
|
6075
|
+
widget.setStyles({
|
|
6076
|
+
button_text_color: '#32a852',
|
|
6077
|
+
primary_color: '#32a852',
|
|
6078
|
+
font_family: 'sans-serif',
|
|
6079
|
+
card_schemes: ['visa']
|
|
6080
|
+
});
|
|
6081
|
+
```
|
|
6082
|
+
<a name="SRC+load" id="SRC+load"></a>
|
|
6083
|
+
|
|
6084
|
+
### srC.load()
|
|
6085
|
+
The final method after configuring the SRC to start the load process of SRC checkout
|
|
6086
|
+
|
|
6087
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6088
|
+
<a name="SRC+setEnv" id="SRC+setEnv"></a>
|
|
6089
|
+
|
|
6090
|
+
### srC.setEnv(env, [alias])
|
|
6091
|
+
Current method can change environment. By default environment = sandbox.
|
|
6092
|
+
Also we can change domain alias for this environment. By default domain_alias = paydock.com
|
|
6093
|
+
|
|
6094
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6095
|
+
|
|
6096
|
+
| Param | Type | Description |
|
|
6097
|
+
| --- | --- | --- |
|
|
6098
|
+
| env | <code>string</code> | sandbox, production |
|
|
6099
|
+
| [alias] | <code>string</code> | Own domain alias |
|
|
6100
|
+
|
|
6101
|
+
**Example**
|
|
6102
|
+
```js
|
|
6103
|
+
SRC.setEnv('production');
|
|
6104
|
+
```
|
|
6105
|
+
<a name="SRC+getEnv" id="SRC+getEnv"></a>
|
|
6106
|
+
|
|
6107
|
+
### srC.getEnv()
|
|
6108
|
+
Method to read the current environment
|
|
6109
|
+
|
|
6110
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6111
|
+
**Example**
|
|
6112
|
+
```js
|
|
6113
|
+
SRC.getEnv();
|
|
6114
|
+
```
|
|
6115
|
+
<a name="SRC+on" id="SRC+on"></a>
|
|
6116
|
+
|
|
6117
|
+
### srC.on(eventName, [cb]) ⇒ <code>Promise.<any></code> \| <code>void</code>
|
|
6118
|
+
Listen to events of SRC
|
|
6119
|
+
|
|
6120
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6121
|
+
|
|
6122
|
+
| Param | Type | Description |
|
|
6123
|
+
| --- | --- | --- |
|
|
6124
|
+
| eventName | <code>string</code> | Available event names [EVENT](#EVENT) |
|
|
6125
|
+
| [cb] | <code>listener</code> | |
|
|
6126
|
+
|
|
6127
|
+
**Example**
|
|
6128
|
+
```js
|
|
6129
|
+
SRC.on('checkoutCompleted', function (token) {
|
|
6130
|
+
console.log(token);
|
|
6131
|
+
});
|
|
6132
|
+
// or
|
|
6133
|
+
SRC.on('checkoutCompleted').then(function (token) {
|
|
6134
|
+
console.log(token);
|
|
5434
6135
|
});
|
|
5435
6136
|
```
|
|
6137
|
+
<a name="SRC+hideButton" id="SRC+hideButton"></a>
|
|
5436
6138
|
|
|
5437
|
-
###
|
|
6139
|
+
### srC.hideButton([saveSize])
|
|
6140
|
+
Using this method you can hide button
|
|
6141
|
+
|
|
6142
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6143
|
+
|
|
6144
|
+
| Param | Type | Default | Description |
|
|
6145
|
+
| --- | --- | --- | --- |
|
|
6146
|
+
| [saveSize] | <code>boolean</code> | <code>false</code> | using this param you can save iframe's size (if applicable) |
|
|
6147
|
+
|
|
6148
|
+
**Example**
|
|
6149
|
+
```js
|
|
6150
|
+
SRC.hideButton();
|
|
6151
|
+
```
|
|
6152
|
+
<a name="SRC+showButton" id="SRC+showButton"></a>
|
|
6153
|
+
|
|
6154
|
+
### srC.showButton()
|
|
6155
|
+
Using this method you can show the SRC button after using hideButton method
|
|
6156
|
+
|
|
6157
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6158
|
+
**Example**
|
|
6159
|
+
```js
|
|
6160
|
+
SRC.showButton();
|
|
6161
|
+
```
|
|
6162
|
+
<a name="SRC+hideCheckout" id="SRC+hideCheckout"></a>
|
|
6163
|
+
|
|
6164
|
+
### srC.hideCheckout([saveSize])
|
|
6165
|
+
Using this method you can hide checkout after load and button click
|
|
5438
6166
|
|
|
5439
|
-
|
|
5440
|
-
All three callbacks return relevant data according to each one of the scenarios.
|
|
6167
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
5441
6168
|
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
6169
|
+
| Param | Type | Default | Description |
|
|
6170
|
+
| --- | --- | --- | --- |
|
|
6171
|
+
| [saveSize] | <code>boolean</code> | <code>false</code> | using this param you can save iframe's size (if applicable) |
|
|
5445
6172
|
|
|
5446
|
-
|
|
5447
|
-
|
|
6173
|
+
**Example**
|
|
6174
|
+
```js
|
|
6175
|
+
SRC.hideCheckout();
|
|
5448
6176
|
```
|
|
6177
|
+
<a name="SRC+showCheckout" id="SRC+showCheckout"></a>
|
|
5449
6178
|
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
```
|
|
5453
|
-
### Events
|
|
5454
|
-
The above events can be used in a more generic way via de `on` function, and making use
|
|
5455
|
-
of the corresponding event names.
|
|
6179
|
+
### srC.showCheckout()
|
|
6180
|
+
Using this method you can show checkout after using hideCheckout method
|
|
5456
6181
|
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
button.on(EVENT.PAYMENT_ERROR, (data) => console.log("The payment was not successful"));
|
|
6182
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6183
|
+
**Example**
|
|
6184
|
+
```js
|
|
6185
|
+
SRC.showCheckout()
|
|
5462
6186
|
```
|
|
6187
|
+
<a name="SRC+reload" id="SRC+reload"></a>
|
|
5463
6188
|
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
### Full example
|
|
6189
|
+
### srC.reload()
|
|
6190
|
+
Using this method you can reload the whole checkout
|
|
5467
6191
|
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
<meta charset="UTF-8">
|
|
5473
|
-
<title>Title</title>
|
|
5474
|
-
</head>
|
|
5475
|
-
<body>
|
|
5476
|
-
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5477
|
-
<div id="widget"></div>
|
|
5478
|
-
</body>
|
|
5479
|
-
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5480
|
-
<script>
|
|
5481
|
-
let button = new paydock.WalletButtons(
|
|
5482
|
-
"#widget",
|
|
5483
|
-
charge_token,
|
|
5484
|
-
{
|
|
5485
|
-
amount_label: "Total",
|
|
5486
|
-
country: "DE",
|
|
5487
|
-
wallets: ["google", "apple"],
|
|
5488
|
-
}
|
|
5489
|
-
);
|
|
5490
|
-
button.setEnv('sandbox');
|
|
5491
|
-
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5492
|
-
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5493
|
-
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5494
|
-
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5495
|
-
button.load();
|
|
5496
|
-
</script>
|
|
5497
|
-
</html>
|
|
6192
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6193
|
+
**Example**
|
|
6194
|
+
```js
|
|
6195
|
+
SRC.reload()
|
|
5498
6196
|
```
|
|
6197
|
+
<a name="SRC+useAutoResize" id="SRC+useAutoResize"></a>
|
|
5499
6198
|
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
### Full example
|
|
5503
|
-
```html
|
|
5504
|
-
<!DOCTYPE html>
|
|
5505
|
-
<html lang="en">
|
|
5506
|
-
<head>
|
|
5507
|
-
<meta charset="UTF-8">
|
|
5508
|
-
<title>Title</title>
|
|
5509
|
-
</head>
|
|
5510
|
-
<body>
|
|
5511
|
-
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5512
|
-
<div id="widget"></div>
|
|
5513
|
-
</body>
|
|
5514
|
-
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5515
|
-
<script>
|
|
5516
|
-
let button = new paydock.WalletButtons(
|
|
5517
|
-
"#widget",
|
|
5518
|
-
charge_token,
|
|
5519
|
-
{
|
|
5520
|
-
request_shipping: true,
|
|
5521
|
-
pay_later: true,
|
|
5522
|
-
style: {
|
|
5523
|
-
layout: 'horizontal',
|
|
5524
|
-
color: 'blue',
|
|
5525
|
-
shape: 'rect',
|
|
5526
|
-
label: 'paypal',
|
|
5527
|
-
},
|
|
5528
|
-
}
|
|
5529
|
-
);
|
|
5530
|
-
button.setEnv('sandbox');
|
|
5531
|
-
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5532
|
-
button.onUpdate((data) => {
|
|
5533
|
-
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5534
|
-
// call `POST charges/:id` to modify charge
|
|
5535
|
-
button.update({ success: true });
|
|
5536
|
-
});
|
|
5537
|
-
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5538
|
-
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5539
|
-
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5540
|
-
button.load();
|
|
5541
|
-
</script>
|
|
5542
|
-
</html>
|
|
5543
|
-
```
|
|
6199
|
+
### srC.useAutoResize()
|
|
6200
|
+
Use this method for resize checkout iFrame according to content height, if applicable
|
|
5544
6201
|
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
<!DOCTYPE html>
|
|
5550
|
-
<html lang="en">
|
|
5551
|
-
<head>
|
|
5552
|
-
<meta charset="UTF-8">
|
|
5553
|
-
<title>Title</title>
|
|
5554
|
-
</head>
|
|
5555
|
-
<body>
|
|
5556
|
-
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5557
|
-
<div id="widget"></div>
|
|
5558
|
-
</body>
|
|
5559
|
-
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5560
|
-
<script>
|
|
5561
|
-
let button = new paydock.WalletButtons(
|
|
5562
|
-
"#widget",
|
|
5563
|
-
charge_token,
|
|
5564
|
-
{
|
|
5565
|
-
request_shipping: true
|
|
5566
|
-
}
|
|
5567
|
-
);
|
|
5568
|
-
button.setEnv('sandbox');
|
|
5569
|
-
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5570
|
-
button.onUpdate((data) => {
|
|
5571
|
-
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5572
|
-
// call `POST charges/:id` to modify charge
|
|
5573
|
-
button.update({ success: true });
|
|
5574
|
-
});
|
|
5575
|
-
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5576
|
-
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5577
|
-
button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
|
|
5578
|
-
button.load();
|
|
5579
|
-
</script>
|
|
5580
|
-
</html>
|
|
6202
|
+
**Kind**: instance method of [<code>SRC</code>](#SRC)
|
|
6203
|
+
**Example**
|
|
6204
|
+
```js
|
|
6205
|
+
SRC.useAutoResize();
|
|
5581
6206
|
```
|
|
6207
|
+
<a name="EVENT" id="EVENT"></a>
|
|
5582
6208
|
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
### Full example
|
|
6209
|
+
## EVENT : <code>enum</code>
|
|
6210
|
+
List of available event's name in the SRC checkout lifecycle
|
|
5586
6211
|
|
|
5587
|
-
|
|
5588
|
-
<!DOCTYPE html>
|
|
5589
|
-
<html lang="en">
|
|
5590
|
-
<head>
|
|
5591
|
-
<meta charset="UTF-8">
|
|
5592
|
-
<title>Title</title>
|
|
5593
|
-
</head>
|
|
5594
|
-
<body>
|
|
5595
|
-
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5596
|
-
<div id="widget"></div>
|
|
5597
|
-
</body>
|
|
5598
|
-
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5599
|
-
<script>
|
|
5600
|
-
let button = new paydock.WalletButtons(
|
|
5601
|
-
"#widget",
|
|
5602
|
-
charge_token,
|
|
5603
|
-
{
|
|
5604
|
-
amount_label: "Total",
|
|
5605
|
-
country: 'DE',
|
|
5606
|
-
request_shipping: true,
|
|
5607
|
-
style: {
|
|
5608
|
-
button_type: 'buy',
|
|
5609
|
-
},
|
|
5610
|
-
shipping_options: [
|
|
5611
|
-
{
|
|
5612
|
-
id: "FreeShip",
|
|
5613
|
-
label: "Free Shipping",
|
|
5614
|
-
detail: "Arrives in 5 to 7 days",
|
|
5615
|
-
amount: "0.00"
|
|
5616
|
-
},
|
|
5617
|
-
{
|
|
5618
|
-
id: "FastShip",
|
|
5619
|
-
label: "Fast Shipping",
|
|
5620
|
-
detail: "Arrives in 1 day",
|
|
5621
|
-
amount: "10.00"
|
|
5622
|
-
}
|
|
5623
|
-
]
|
|
5624
|
-
}
|
|
5625
|
-
);
|
|
5626
|
-
button.setEnv('sandbox');
|
|
5627
|
-
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5628
|
-
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5629
|
-
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5630
|
-
button.load();
|
|
5631
|
-
</script>
|
|
5632
|
-
</html>
|
|
5633
|
-
```
|
|
6212
|
+
**Kind**: global enum
|
|
5634
6213
|
|
|
5635
|
-
|
|
6214
|
+
| Param | Type | Default |
|
|
6215
|
+
| --- | --- | --- |
|
|
6216
|
+
| CHECKOUT_BUTTON_LOADED | <code>string</code> | <code>"checkoutButtonLoaded"</code> |
|
|
6217
|
+
| CHECKOUT_BUTTON_CLICKED | <code>string</code> | <code>"checkoutButtonClicked"</code> |
|
|
6218
|
+
| IFRAME_LOADED | <code>string</code> | <code>"iframeLoaded"</code> |
|
|
6219
|
+
| CHECKOUT_READY | <code>string</code> | <code>"checkoutReady"</code> |
|
|
6220
|
+
| CHECKOUT_COMPLETED | <code>string</code> | <code>"checkoutCompleted"</code> |
|
|
6221
|
+
| CHECKOUT_ERROR | <code>string</code> | <code>"checkoutError"</code> |
|
|
5636
6222
|
|
|
5637
|
-
### Raw data initialization example
|
|
5638
6223
|
|
|
5639
|
-
```html
|
|
5640
|
-
<!DOCTYPE html>
|
|
5641
|
-
<html lang="en">
|
|
5642
|
-
<head>
|
|
5643
|
-
<meta charset="UTF-8">
|
|
5644
|
-
<title>Title</title>
|
|
5645
|
-
</head>
|
|
5646
|
-
<body>
|
|
5647
|
-
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5648
|
-
<div id="widget"></div>
|
|
5649
|
-
</body>
|
|
5650
|
-
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5651
|
-
<script>
|
|
5652
|
-
let button = new paydock.WalletButtons(
|
|
5653
|
-
"#widget",
|
|
5654
|
-
charge_token,
|
|
5655
|
-
{
|
|
5656
|
-
raw_data_initialization: {
|
|
5657
|
-
countryCode: "AU",
|
|
5658
|
-
currencyCode: "AUD",
|
|
5659
|
-
merchantCapabilities: ["supports3DS","supportsCredit","supportsDebit"],
|
|
5660
|
-
supportedNetworks: ["visa","masterCard","amex","discover"],
|
|
5661
|
-
requiredBillingContactFields: ["name","postalAddress"],
|
|
5662
|
-
requiredShippingContactFields:["postalAddress","name","phone","email" ],
|
|
5663
|
-
total: {
|
|
5664
|
-
label: "Total",
|
|
5665
|
-
amount: "10",
|
|
5666
|
-
type: "final",
|
|
5667
|
-
}
|
|
5668
|
-
},
|
|
5669
|
-
amount_label: "Total",
|
|
5670
|
-
country: 'DE',
|
|
5671
|
-
request_shipping: true,
|
|
5672
|
-
style: {
|
|
5673
|
-
button_type: 'buy',
|
|
5674
|
-
},
|
|
5675
|
-
shipping_options: [
|
|
5676
|
-
{
|
|
5677
|
-
id: "FreeShip",
|
|
5678
|
-
label: "Free Shipping",
|
|
5679
|
-
detail: "Arrives in 5 to 7 days",
|
|
5680
|
-
amount: "0.00"
|
|
5681
|
-
},
|
|
5682
|
-
{
|
|
5683
|
-
id: "FastShip",
|
|
5684
|
-
label: "Fast Shipping",
|
|
5685
|
-
detail: "Arrives in 1 day",
|
|
5686
|
-
amount: "10.00"
|
|
5687
|
-
}
|
|
5688
|
-
]
|
|
5689
|
-
}
|
|
5690
|
-
);
|
|
5691
|
-
button.setEnv('sandbox');
|
|
5692
|
-
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5693
|
-
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5694
|
-
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5695
|
-
button.load();
|
|
5696
|
-
</script>
|
|
5697
|
-
</html>
|
|
5698
|
-
```
|
|
5699
6224
|
## License
|
|
5700
6225
|
Copyright (c) 2017 paydock
|