@paydock/client-sdk 1.11.2-beta → 1.11.3-beta

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.
Files changed (43) hide show
  1. package/README.md +478 -2
  2. package/bundles/widget.umd.js +429 -0
  3. package/bundles/widget.umd.min.js +1 -1
  4. package/lib/api/api-internal.d.ts +2 -0
  5. package/lib/api/api-internal.js +4 -0
  6. package/lib/api/api-internal.js.map +1 -1
  7. package/lib/api/api-service-internal.d.ts +17 -0
  8. package/lib/api/api-service-internal.js +18 -0
  9. package/lib/api/api-service-internal.js.map +1 -0
  10. package/lib/components/iframe-event.d.ts +3 -0
  11. package/lib/components/iframe-event.js +2 -0
  12. package/lib/components/iframe-event.js.map +1 -1
  13. package/lib/components/link.d.ts +4 -2
  14. package/lib/components/link.js +4 -0
  15. package/lib/components/link.js.map +1 -1
  16. package/lib/components/param.d.ts +6 -0
  17. package/lib/components/param.js.map +1 -1
  18. package/lib/index.d.ts +1 -0
  19. package/lib/index.js +1 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/secure-remote-commerce/index.d.ts +1 -0
  22. package/lib/secure-remote-commerce/index.js +2 -0
  23. package/lib/secure-remote-commerce/index.js.map +1 -0
  24. package/lib/secure-remote-commerce/interfaces.d.ts +58 -0
  25. package/lib/secure-remote-commerce/interfaces.js +22 -0
  26. package/lib/secure-remote-commerce/interfaces.js.map +1 -0
  27. package/lib/secure-remote-commerce/providers/src-provider.d.ts +10 -0
  28. package/lib/secure-remote-commerce/providers/src-provider.js +1 -0
  29. package/lib/secure-remote-commerce/providers/src-provider.js.map +1 -0
  30. package/lib/secure-remote-commerce/providers/visa-src/index.d.ts +1 -0
  31. package/lib/secure-remote-commerce/providers/visa-src/index.js +2 -0
  32. package/lib/secure-remote-commerce/providers/visa-src/index.js.map +1 -0
  33. package/lib/secure-remote-commerce/providers/visa-src/visa-src.d.ts +27 -0
  34. package/lib/secure-remote-commerce/providers/visa-src/visa-src.js +100 -0
  35. package/lib/secure-remote-commerce/providers/visa-src/visa-src.js.map +1 -0
  36. package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.d.ts +8 -0
  37. package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.js +10 -0
  38. package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.js.map +1 -0
  39. package/lib/secure-remote-commerce/secure-remote-commerce.d.ts +148 -0
  40. package/lib/secure-remote-commerce/secure-remote-commerce.js +210 -0
  41. package/lib/secure-remote-commerce/secure-remote-commerce.js.map +1 -0
  42. package/package.json +1 -1
  43. package/slate.md +233 -3
@@ -0,0 +1,148 @@
1
+ import { EventEmitter } from "../helper/event-emitter";
2
+ import { ApiInternal } from '../api/api-internal';
3
+ import { SRCProvider } from './providers/src-provider';
4
+ import { IVisaSRCMeta } from './interfaces';
5
+ /**
6
+ * Interface of data used for the Visa Checkout.
7
+ * @interface IVisaSRCMeta
8
+ *
9
+ * @type {object}
10
+ * @param {string} [srci_transaction_id] Used to identify the SRC Id.
11
+ * @param {object} [dpa_data] Object where the DPA creation data is stored.
12
+ * @param {string} [dpa_data.dpa_presentation_name] Name in which the DPA is presented in.
13
+ * @param {string} [dpa_data.dpa_uri] Used for indicating the DPA URI.
14
+ * @param {object} [dpa_transaction_options] Object that stores options for creating a trasaction with DPA.
15
+ * @param {string} [dpa_transaction_options.dpa_locale] DPA’s preferred locale, example en_US.
16
+ * @param {Array} [dpa_transaction_options.dpa_accepted_billing_countries] Used to indicate list of accepted billing countries for DPA.
17
+ * @param {Array} [dpa_transaction_options.dpa_accepted_shipping_countries] Used to indicate list of accepted shipping countries for DPA.
18
+ * @param {string} [dpa_transaction_options.dpa_billing_preference] Used for listing the enumeration for billing preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'.
19
+ * @param {string} [dpa_transaction_options.dpa_shipping_preference] Used for listing the enumeration for shipping preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'.
20
+ * @param {boolean} [dpa_transaction_options.consumer_name_requested] Used to check if the name of the consumer is needed.
21
+ * @param {boolean} [dpa_transaction_options.consumer_email_address_requested] Used to check if the email of the consumer is needed.
22
+ * @param {boolean} [dpa_transaction_options.consumer_phone_number_requested] Used to check if the phone number of the consumer is needed.
23
+ * @param {object} [dpa_transaction_options.payment_options] Object used to check the payment options that are included.
24
+ * @param {number} [dpa_transaction_options.payment_options.dpa_dynamic_data_ttl_minutes] The minimum requested validity period for the transaction credentials.
25
+ * @param {string} [dpa_transaction_options.payment_options.dynamic_data_type] Used for listing the enumeration for dynamic data types. Options are 'TAVV' and 'DTVV'.
26
+ * @param {boolean} [dpa_transaction_options.payment_options.dpa_pan_requested] Used to check if PAN number was requested.
27
+ * @param {string} [dpa_transaction_options.review_action] Used for listing the enumeration of review actions. Options are 'pay' and 'continue'.
28
+ * @param {string} [dpa_transaction_options.checkout_description] Used for indicating the description of the checkout.
29
+ * @param {string} [dpa_transaction_options.transaction_type] Used for listing the enumeration of the type of the transaction. 'PURCHASE', 'BILL_PAYMENT' and 'MONEY_TRANSFER'
30
+ * @param {string} [dpa_transaction_options.order_type] Used for listing the enumeration of the type of the order. Options are 'REAUTHORIZATION', 'RECURRING' and 'INSTALLMENT'.
31
+ * @param {object} [dpa_transaction_options.transaction_amount] Object used to describe the details of the transaction.
32
+ * @param {number} [dpa_transaction_options.transaction_amount.transaction_amount] Used to indicate the amount of the transaction.
33
+ * @param {string} [dpa_transaction_options.transaction_amount.transaction_currency_code] Used to indicate the currency code of the transaction. 3 letter ISO code format.
34
+ * @param {string} [dpa_transaction_options.merchant_order_id] Used to indicate the merchants order Id.
35
+ * @param {string} [dpa_transaction_options.merchant_category_code] Used to indicate the merchants category code.
36
+ * @param {string} [dpa_transaction_options.merchant_country_code] Used to indicate the merchants country code. 2 letter ISO code format.
37
+ * @param {object} [customer] Object where the customer data is stored to prefill in the checkout.
38
+ * @param {string} [customer.email] Customer email.
39
+ * @param {string} [customer.first_name] Customer first name.
40
+ * @param {string} [customer.last_name] Customer last name.
41
+ * @param {object} [customer.phone] Object where the customer phone is stored.
42
+ * @param {string} [customer.phone.country_code] Customer phone country code (example "1" for US).
43
+ * @param {string} [customer.phone.phone] Customer phone number.
44
+ * @param {object} [customer.payment_source] Object where the customer billing address data is stored.
45
+ * @param {string} [customer.payment_source.address_line1] Customer billing address line 1.
46
+ * @param {string} [customer.payment_source.address_line2] Customer billing address line 2.
47
+ * @param {string} [customer.payment_source.address_city] Customer billing address city.
48
+ * @param {string} [customer.payment_source.address_postcode] Customer billing address postcode.
49
+ * @param {string} [customer.payment_source.address_state] Customer billing address state code (if applicable for the country, example "FL" for Florida).
50
+ * @param {string} [customer.payment_source.address_country] Customer billing address country code (example "US").
51
+ *
52
+ */
53
+ /**
54
+ * Class SRC include methods for interacting with different secure remote commerce options such as Visa SRC
55
+ * @constructor
56
+ *
57
+ * @param {string} button_selector - Selector of html element. Container for SRC checkout button.
58
+ * @param {string} iframe_selector - Selector of html element. Container for SRC checkout iFrame.
59
+ * @param {string} service_id - Card Scheme Service ID
60
+ * @param {string} public_key - Paydock public key
61
+ * @param {IVisaSRCMeta} meta - Data that configures the SRC checkout
62
+ * @example
63
+ * var SRC = new SRC('#checkoutButton', '#checkoutIframe', 'service_id', 'public_key', {});
64
+ *
65
+ **/
66
+ export declare class SRC {
67
+ protected button_selector: string;
68
+ protected iframe_selector: string;
69
+ protected service_id: string;
70
+ protected public_key: string;
71
+ protected meta: IVisaSRCMeta;
72
+ protected eventEmitter: EventEmitter;
73
+ protected env: string;
74
+ protected alias: string;
75
+ protected api: ApiInternal;
76
+ protected provider: SRCProvider;
77
+ protected autoResize: boolean;
78
+ constructor(button_selector: string, iframe_selector: string, service_id: string, public_key: string, meta: IVisaSRCMeta);
79
+ /**
80
+ * The final method after configuring the SRC to start the load process of SRC checkout
81
+ *
82
+ */
83
+ load(): void;
84
+ /**
85
+ * Current method can change environment. By default environment = sandbox.
86
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
87
+ *
88
+ * @example
89
+ * SRC.setEnv('production');
90
+ * @param {string} env - sandbox, production
91
+ * @param {string} [alias] - Own domain alias
92
+ */
93
+ setEnv(env: string, alias?: string): void;
94
+ /**
95
+ * Method to read the current environment
96
+ *
97
+ * @example
98
+ * SRC.getEnv();
99
+ */
100
+ getEnv(): string;
101
+ on(eventName: string): Promise<any>;
102
+ on(eventName: string, cb: (data: any) => void): any;
103
+ /**
104
+ * Using this method you can hide button
105
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
106
+ *
107
+ * @example
108
+ * SRC.hideButton();
109
+ */
110
+ hideButton(saveSize: boolean): void;
111
+ /**
112
+ * Using this method you can show the SRC button after using hideButton method
113
+ *
114
+ * @example
115
+ * SRC.showButton();
116
+ */
117
+ showButton(): void;
118
+ /**
119
+ * Using this method you can hide checkout after load and button click
120
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
121
+ *
122
+ * @example
123
+ * SRC.hideCheckout();
124
+ */
125
+ hideCheckout(saveSize: boolean): void;
126
+ /**
127
+ * Using this method you can show checkout after using hideCheckout method
128
+ *
129
+ * @example
130
+ * SRC.showCheckout()
131
+ */
132
+ showCheckout(): void;
133
+ /**
134
+ * Using this method you can reload the whole checkout
135
+ *
136
+ * @example
137
+ * SRC.reload()
138
+ */
139
+ reload(): void;
140
+ /**
141
+ * Use this method for resize checkout iFrame according to content height, if applicable
142
+ *
143
+ * @example
144
+ * SRC.useAutoResize();
145
+ *
146
+ */
147
+ useAutoResize(): void;
148
+ }
@@ -0,0 +1,210 @@
1
+ import { API_AUTH_TYPE } from '../api/api-base';
2
+ import { CARD_SCHEME_SERVICE } from '../api/api-service-internal';
3
+ import { EventEmitter } from "../helper/event-emitter";
4
+ import { VisaSRC } from './providers/visa-src';
5
+ import { ApiInternal } from '../api/api-internal';
6
+ /**
7
+ * Interface of data used for the Visa Checkout.
8
+ * @interface IVisaSRCMeta
9
+ *
10
+ * @type {object}
11
+ * @param {string} [srci_transaction_id] Used to identify the SRC Id.
12
+ * @param {object} [dpa_data] Object where the DPA creation data is stored.
13
+ * @param {string} [dpa_data.dpa_presentation_name] Name in which the DPA is presented in.
14
+ * @param {string} [dpa_data.dpa_uri] Used for indicating the DPA URI.
15
+ * @param {object} [dpa_transaction_options] Object that stores options for creating a trasaction with DPA.
16
+ * @param {string} [dpa_transaction_options.dpa_locale] DPA’s preferred locale, example en_US.
17
+ * @param {Array} [dpa_transaction_options.dpa_accepted_billing_countries] Used to indicate list of accepted billing countries for DPA.
18
+ * @param {Array} [dpa_transaction_options.dpa_accepted_shipping_countries] Used to indicate list of accepted shipping countries for DPA.
19
+ * @param {string} [dpa_transaction_options.dpa_billing_preference] Used for listing the enumeration for billing preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'.
20
+ * @param {string} [dpa_transaction_options.dpa_shipping_preference] Used for listing the enumeration for shipping preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'.
21
+ * @param {boolean} [dpa_transaction_options.consumer_name_requested] Used to check if the name of the consumer is needed.
22
+ * @param {boolean} [dpa_transaction_options.consumer_email_address_requested] Used to check if the email of the consumer is needed.
23
+ * @param {boolean} [dpa_transaction_options.consumer_phone_number_requested] Used to check if the phone number of the consumer is needed.
24
+ * @param {object} [dpa_transaction_options.payment_options] Object used to check the payment options that are included.
25
+ * @param {number} [dpa_transaction_options.payment_options.dpa_dynamic_data_ttl_minutes] The minimum requested validity period for the transaction credentials.
26
+ * @param {string} [dpa_transaction_options.payment_options.dynamic_data_type] Used for listing the enumeration for dynamic data types. Options are 'TAVV' and 'DTVV'.
27
+ * @param {boolean} [dpa_transaction_options.payment_options.dpa_pan_requested] Used to check if PAN number was requested.
28
+ * @param {string} [dpa_transaction_options.review_action] Used for listing the enumeration of review actions. Options are 'pay' and 'continue'.
29
+ * @param {string} [dpa_transaction_options.checkout_description] Used for indicating the description of the checkout.
30
+ * @param {string} [dpa_transaction_options.transaction_type] Used for listing the enumeration of the type of the transaction. 'PURCHASE', 'BILL_PAYMENT' and 'MONEY_TRANSFER'
31
+ * @param {string} [dpa_transaction_options.order_type] Used for listing the enumeration of the type of the order. Options are 'REAUTHORIZATION', 'RECURRING' and 'INSTALLMENT'.
32
+ * @param {object} [dpa_transaction_options.transaction_amount] Object used to describe the details of the transaction.
33
+ * @param {number} [dpa_transaction_options.transaction_amount.transaction_amount] Used to indicate the amount of the transaction.
34
+ * @param {string} [dpa_transaction_options.transaction_amount.transaction_currency_code] Used to indicate the currency code of the transaction. 3 letter ISO code format.
35
+ * @param {string} [dpa_transaction_options.merchant_order_id] Used to indicate the merchants order Id.
36
+ * @param {string} [dpa_transaction_options.merchant_category_code] Used to indicate the merchants category code.
37
+ * @param {string} [dpa_transaction_options.merchant_country_code] Used to indicate the merchants country code. 2 letter ISO code format.
38
+ * @param {object} [customer] Object where the customer data is stored to prefill in the checkout.
39
+ * @param {string} [customer.email] Customer email.
40
+ * @param {string} [customer.first_name] Customer first name.
41
+ * @param {string} [customer.last_name] Customer last name.
42
+ * @param {object} [customer.phone] Object where the customer phone is stored.
43
+ * @param {string} [customer.phone.country_code] Customer phone country code (example "1" for US).
44
+ * @param {string} [customer.phone.phone] Customer phone number.
45
+ * @param {object} [customer.payment_source] Object where the customer billing address data is stored.
46
+ * @param {string} [customer.payment_source.address_line1] Customer billing address line 1.
47
+ * @param {string} [customer.payment_source.address_line2] Customer billing address line 2.
48
+ * @param {string} [customer.payment_source.address_city] Customer billing address city.
49
+ * @param {string} [customer.payment_source.address_postcode] Customer billing address postcode.
50
+ * @param {string} [customer.payment_source.address_state] Customer billing address state code (if applicable for the country, example "FL" for Florida).
51
+ * @param {string} [customer.payment_source.address_country] Customer billing address country code (example "US").
52
+ *
53
+ */
54
+ /**
55
+ * Class SRC include methods for interacting with different secure remote commerce options such as Visa SRC
56
+ * @constructor
57
+ *
58
+ * @param {string} button_selector - Selector of html element. Container for SRC checkout button.
59
+ * @param {string} iframe_selector - Selector of html element. Container for SRC checkout iFrame.
60
+ * @param {string} service_id - Card Scheme Service ID
61
+ * @param {string} public_key - Paydock public key
62
+ * @param {IVisaSRCMeta} meta - Data that configures the SRC checkout
63
+ * @example
64
+ * var SRC = new SRC('#checkoutButton', '#checkoutIframe', 'service_id', 'public_key', {});
65
+ *
66
+ **/
67
+ export class SRC {
68
+ constructor(button_selector, iframe_selector, service_id, public_key, meta) {
69
+ this.button_selector = button_selector;
70
+ this.iframe_selector = iframe_selector;
71
+ this.service_id = service_id;
72
+ this.public_key = public_key;
73
+ this.meta = meta;
74
+ this.autoResize = false;
75
+ this.api = new ApiInternal(public_key, API_AUTH_TYPE.PUBLIC_KEY);
76
+ this.eventEmitter = new EventEmitter();
77
+ }
78
+ /**
79
+ * The final method after configuring the SRC to start the load process of SRC checkout
80
+ *
81
+ */
82
+ load() {
83
+ if (this.provider)
84
+ return;
85
+ this.api.service().getConfig(this.service_id).then(({ type }) => {
86
+ switch (type) {
87
+ case CARD_SCHEME_SERVICE.VISA_SRC:
88
+ this.provider = new VisaSRC(this.button_selector, this.iframe_selector, this.service_id, this.public_key, this.meta, this.eventEmitter, this.autoResize, this.env, this.alias);
89
+ break;
90
+ }
91
+ ;
92
+ if (this.provider)
93
+ this.provider.load();
94
+ });
95
+ }
96
+ /**
97
+ * Current method can change environment. By default environment = sandbox.
98
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
99
+ *
100
+ * @example
101
+ * SRC.setEnv('production');
102
+ * @param {string} env - sandbox, production
103
+ * @param {string} [alias] - Own domain alias
104
+ */
105
+ setEnv(env, alias) {
106
+ if (this.provider)
107
+ return;
108
+ this.env = env;
109
+ this.alias = alias;
110
+ this.api.setEnv(env, alias);
111
+ }
112
+ /**
113
+ * Method to read the current environment
114
+ *
115
+ * @example
116
+ * SRC.getEnv();
117
+ */
118
+ getEnv() {
119
+ if (this.provider)
120
+ return this.provider.getEnv();
121
+ else
122
+ return this.env;
123
+ }
124
+ /**
125
+ * Listen to events of SRC
126
+ *
127
+ * @example
128
+ *
129
+ * SRC.on('checkoutCompleted', function (token) {
130
+ * console.log(token);
131
+ * });
132
+ * // or
133
+ * SRC.on('checkoutCompleted').then(function (token) {
134
+ * console.log(token);
135
+ * });
136
+ * @param {string} eventName - Available event names [EVENT]{@link EVENT}
137
+ * @param {listener} [cb]
138
+ * @return {Promise<any> | void}
139
+ */
140
+ on(eventName, cb) {
141
+ if (typeof cb === "function")
142
+ return this.eventEmitter.subscribe(eventName, cb);
143
+ return new Promise((resolve) => this.eventEmitter.subscribe(eventName, (res) => resolve(res)));
144
+ }
145
+ /**
146
+ * Using this method you can hide button
147
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
148
+ *
149
+ * @example
150
+ * SRC.hideButton();
151
+ */
152
+ hideButton(saveSize) {
153
+ if (this.provider && typeof this.provider.hideButton === 'function')
154
+ this.provider.hideButton(saveSize);
155
+ }
156
+ /**
157
+ * Using this method you can show the SRC button after using hideButton method
158
+ *
159
+ * @example
160
+ * SRC.showButton();
161
+ */
162
+ showButton() {
163
+ if (this.provider && typeof this.provider.showButton === 'function')
164
+ this.provider.showButton();
165
+ }
166
+ /**
167
+ * Using this method you can hide checkout after load and button click
168
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
169
+ *
170
+ * @example
171
+ * SRC.hideCheckout();
172
+ */
173
+ hideCheckout(saveSize) {
174
+ if (this.provider && typeof this.provider.hideCheckout === 'function')
175
+ this.provider.hideCheckout(saveSize);
176
+ }
177
+ /**
178
+ * Using this method you can show checkout after using hideCheckout method
179
+ *
180
+ * @example
181
+ * SRC.showCheckout()
182
+ */
183
+ showCheckout() {
184
+ if (this.provider && typeof this.provider.showCheckout === 'function')
185
+ this.provider.showCheckout();
186
+ }
187
+ /**
188
+ * Using this method you can reload the whole checkout
189
+ *
190
+ * @example
191
+ * SRC.reload()
192
+ */
193
+ reload() {
194
+ if (this.provider)
195
+ this.provider.reload();
196
+ }
197
+ /**
198
+ * Use this method for resize checkout iFrame according to content height, if applicable
199
+ *
200
+ * @example
201
+ * SRC.useAutoResize();
202
+ *
203
+ */
204
+ useAutoResize() {
205
+ this.autoResize = true;
206
+ if (this.provider && typeof this.provider.useAutoResize === 'function')
207
+ this.provider.useAutoResize();
208
+ }
209
+ }
210
+ //# sourceMappingURL=../../src/lib/secure-remote-commerce/secure-remote-commerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-remote-commerce.js","sourceRoot":"","sources":["../../secure-remote-commerce/secure-remote-commerce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH;;;;;;;;;;;;IAYI;AACJ,MAAM,OAAO,GAAG;IAWZ,YAAsB,eAAuB,EAAY,eAAuB,EAAY,UAAkB,EAAY,UAAkB,EAAY,IAAkB;QAApJ,oBAAe,GAAf,eAAe,CAAQ;QAAY,oBAAe,GAAf,eAAe,CAAQ;QAAY,eAAU,GAAV,UAAU,CAAQ;QAAY,eAAU,GAAV,UAAU,CAAQ;QAAY,SAAI,GAAJ,IAAI,CAAc;QAFhK,eAAU,GAAG,KAAK,CAAC;QAGzB,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,IAAI;QACP,IAAI,IAAI,CAAC,QAAQ;YACb,OAAO;QAEX,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,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package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@paydock/client-sdk",
3
3
  "description": "Paydock client sdk",
4
- "version": "1.11.2-beta",
4
+ "version": "1.11.3-beta",
5
5
  "homepage": "https://paydock.com",
6
6
  "author": {},
7
7
  "bugs": {
package/slate.md CHANGED
@@ -1081,7 +1081,7 @@ button.load();
1081
1081
 
1082
1082
  ```javascript--es2015
1083
1083
  // ES2015 | TypeScript
1084
- import { WalletButtons } from '@paydock/client-sdk/widget';
1084
+ import { WalletButtons } from '@paydock/client-sdk';
1085
1085
 
1086
1086
  var button = new WalletButtons(
1087
1087
  '#widget',
@@ -1106,7 +1106,7 @@ button.load();
1106
1106
 
1107
1107
  ```javascript--es2015
1108
1108
  // ES2015 | TypeScript
1109
- import { WalletButtons } from '@paydock/client-sdk/widget';
1109
+ import { WalletButtons } from '@paydock/client-sdk';
1110
1110
 
1111
1111
  var button = new WalletButtons(
1112
1112
  '#widget',
@@ -1476,4 +1476,234 @@ Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest`
1476
1476
  button.load();
1477
1477
  </script>
1478
1478
  </html>
1479
- ```
1479
+ ```
1480
+ ## Secure Remote Commerce
1481
+ You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#secure-remote-commerce)
1482
+
1483
+ This widget provides you with the ability to easily integrate with SRC providers. Currently Visa SRC is supported.
1484
+
1485
+ ## SRC simple example
1486
+
1487
+ ### Container
1488
+
1489
+ ```html
1490
+ <div id="checkoutButton"></div>
1491
+ <div id="checkoutIframe"></div>
1492
+ ```
1493
+
1494
+ 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.
1495
+
1496
+
1497
+ ### Initialization
1498
+ ```javascript
1499
+ var src = new paydock.SRC(
1500
+ "#checkoutButton",
1501
+ "#checkoutIframe",
1502
+ "scheme_service_id",
1503
+ "paydock_public_key",
1504
+ {}, // meta
1505
+ );
1506
+ src.load();
1507
+ ```
1508
+
1509
+ ```javascript--es2015
1510
+ // ES2015 | TypeScript
1511
+
1512
+ import { SRC } from '@paydock/client-sdk';
1513
+
1514
+ var src = new SRC(
1515
+ "#checkoutButton",
1516
+ "#checkoutIframe",
1517
+ "scheme_service_id",
1518
+ "paydock_public_key",
1519
+ {}, // meta
1520
+ );
1521
+ src.load();
1522
+ ```
1523
+
1524
+ ### Full example
1525
+
1526
+ ```html
1527
+ <!DOCTYPE html>
1528
+ <html lang="en">
1529
+ <head>
1530
+ <meta charset="UTF-8">
1531
+ <title>Title</title>
1532
+ <style>iframe {border: 0;width: 40%;height: 300px;}</style>
1533
+ </head>
1534
+ <body>
1535
+ <div id="checkoutButton"></div>
1536
+ <div id="checkoutIframe"></div>
1537
+ <script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
1538
+ <script>
1539
+ var src = new paydock.SRC(
1540
+ "#checkoutButton",
1541
+ "#checkoutIframe",
1542
+ "scheme_service_id",
1543
+ "paydock_public_key",
1544
+ {},
1545
+ );
1546
+ src.load();
1547
+ </script>
1548
+ </body>
1549
+ </html>
1550
+ ```
1551
+
1552
+
1553
+ ## SRC advanced example
1554
+
1555
+ ### Settings
1556
+
1557
+ ```javascript
1558
+
1559
+ src.setEnv('sandbox'); // set enviroment
1560
+
1561
+ src.hideButton(); // hide button
1562
+
1563
+ src.showButton(); // show button
1564
+
1565
+ src.hideCheckout(); // hide checkout iframe
1566
+
1567
+ src.showCheckout(); // show checkout iframe
1568
+
1569
+ src.on('checkoutButtonLoaded', () => {
1570
+ console.log("Button loaded");
1571
+ });
1572
+
1573
+ src.on('checkoutButtonClicked', () => {
1574
+ console.log("Button clicked");
1575
+ });
1576
+
1577
+ src.on('iframeLoaded', () => {
1578
+ console.log("Initial iframe loaded");
1579
+ });
1580
+
1581
+ src.on('checkoutReady', () => {
1582
+ console.log("Checkout ready to be used");
1583
+ });
1584
+
1585
+ src.on('checkoutCompleted', (token) => {
1586
+ console.log(token);
1587
+ });
1588
+
1589
+ src.on('checkoutError', (error) => {
1590
+ console.log(error);
1591
+ });
1592
+ ```
1593
+
1594
+ Here you can see how you can use this methods to customize your checkout experience
1595
+
1596
+ ### Full example
1597
+
1598
+ ```html
1599
+ <!DOCTYPE html>
1600
+ <html lang="en">
1601
+ <head>
1602
+ <meta charset="UTF-8">
1603
+ <title>Title</title>
1604
+ <style>iframe {border: 0;width: 40%;height: 450px;}</style>
1605
+ </head>
1606
+ <body>
1607
+ <div id="checkoutButton"></div>
1608
+ <div id="checkoutIframe"></div>
1609
+ <script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
1610
+ <script>
1611
+ var src = new paydock.SRC(
1612
+ "#checkoutButton",
1613
+ "#checkoutIframe",
1614
+ "scheme_service_id",
1615
+ "paydock_public_key",
1616
+ {},
1617
+ );
1618
+
1619
+ src.on('checkoutReady', () => {
1620
+ console.log("Checkout ready to be used");
1621
+ });
1622
+
1623
+ src.on('checkoutCompleted', (token) => {
1624
+ console.log(token);
1625
+ });
1626
+ src.load();
1627
+ </script>
1628
+ </body>
1629
+ </html>
1630
+ ```
1631
+
1632
+ ## Customization options for address fields
1633
+ ### Shipping address:
1634
+
1635
+ 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.
1636
+
1637
+ ```
1638
+ var src = new paydock.SRC(
1639
+ "#checkoutButton",
1640
+ "#checkoutIframe",
1641
+ "scheme_service_id",
1642
+ "paydock_public_key",
1643
+ {
1644
+ "dpa_transaction_options": {
1645
+ "dpa_shipping_preference": "ALL"
1646
+ }
1647
+ },
1648
+ );
1649
+ ```
1650
+
1651
+ With this the Visa popup requires the shipping address from consumer, and these information will be stored in the Paydock charge.
1652
+
1653
+ 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:
1654
+
1655
+ ```
1656
+ POST v1/charges
1657
+
1658
+ {
1659
+ "amount": "10.00",
1660
+ "currency": "AUD",
1661
+ "token": "token",
1662
+ "customer": {
1663
+ "payment_source": {
1664
+ "gateway_id": "gateway_id"
1665
+ }
1666
+ },
1667
+ "shipping": {
1668
+ "address_line1": "address_line1",
1669
+ "address_line2": "address_line2",
1670
+ "address_line3": "address_line3",
1671
+ "address_city": "address_city",
1672
+ "address_postcode": "address_postcode",
1673
+ "address_state": "address_state",
1674
+ "address_country": "address_country"
1675
+ }
1676
+ }
1677
+ ```
1678
+
1679
+ - Billing address:
1680
+
1681
+ 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:
1682
+
1683
+ ```
1684
+ var src = new paydock.SRC(
1685
+ "#checkoutButton",
1686
+ "#checkoutIframe",
1687
+ "scheme_service_id",
1688
+ "paydock_public_key",
1689
+ {
1690
+ "customer": {
1691
+ "email": "test@email.com",
1692
+ "first_name": "Name",
1693
+ "last_name": "Surname",
1694
+ "phone": {
1695
+ "country_code": "1",
1696
+ "phone": "2124567890"
1697
+ },
1698
+ "payment_source": {
1699
+ "address_line1": "Line 1",
1700
+ "address_line2": "Line 2",
1701
+ "address_city": "Miami",
1702
+ "address_postcode": "33126",
1703
+ "address_state": "FL",
1704
+ "address_country": "US"
1705
+ }
1706
+ }
1707
+ },
1708
+ );
1709
+ ```