@lightspeed/online-payments-sdk 0.2.0 → 0.2.1
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/dist/cjs/v1/StripeWidget.js +11 -10
- package/dist/cjs/v1/widget.js +2 -2
- package/dist/v1/StripeWidget.d.ts +2 -2
- package/dist/v1/StripeWidget.js +11 -10
- package/dist/v1/common.d.ts +5 -1
- package/dist/v1/index.d.ts +1 -1
- package/dist/v1/widget.d.ts +3 -2
- package/dist/v1/widget.js +2 -2
- package/package.json +2 -1
|
@@ -70,7 +70,7 @@ function init(context) {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
function mount(mountElement, context, listeners) {
|
|
73
|
+
function mount(mountElement, context, listeners, defaultValues) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function () {
|
|
75
75
|
var _a, stripe, elements, paymentElement;
|
|
76
76
|
var _this = this;
|
|
@@ -79,17 +79,18 @@ function mount(mountElement, context, listeners) {
|
|
|
79
79
|
case 0: return [4 /*yield*/, init(context)];
|
|
80
80
|
case 1:
|
|
81
81
|
_a = _b.sent(), stripe = _a.stripe, elements = _a.elements;
|
|
82
|
-
paymentElement = elements.create('payment'
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
paymentElement = elements.create('payment', defaultValues
|
|
83
|
+
? {
|
|
84
|
+
defaultValues: {
|
|
85
|
+
billingDetails: {
|
|
86
|
+
address: {
|
|
87
|
+
country: defaultValues.country,
|
|
88
|
+
postal_code: defaultValues.postalCode,
|
|
89
|
+
},
|
|
89
90
|
},
|
|
90
91
|
},
|
|
91
|
-
}
|
|
92
|
-
|
|
92
|
+
}
|
|
93
|
+
: {});
|
|
93
94
|
paymentElement.mount(mountElement);
|
|
94
95
|
return [2 /*return*/, {
|
|
95
96
|
unmount: function () { return paymentElement.unmount(); },
|
package/dist/cjs/v1/widget.js
CHANGED
|
@@ -5,7 +5,7 @@ var AdyenWidget_1 = require("./AdyenWidget");
|
|
|
5
5
|
var errors_1 = require("./errors");
|
|
6
6
|
var StripeWidget_1 = require("./StripeWidget");
|
|
7
7
|
function mountPaymentWidget(session, _a) {
|
|
8
|
-
var mountPoint = _a.mountPoint, onComplete = _a.onComplete, onFail = _a.onFail;
|
|
8
|
+
var mountPoint = _a.mountPoint, onComplete = _a.onComplete, onFail = _a.onFail, defaultValues = _a.defaultValues;
|
|
9
9
|
var decodedSession = decodePaymentSessionToContext(session);
|
|
10
10
|
switch (decodedSession.psp) {
|
|
11
11
|
case 'ADYEN':
|
|
@@ -17,7 +17,7 @@ function mountPaymentWidget(session, _a) {
|
|
|
17
17
|
return StripeWidget_1.StripeWidget.mount(mountPoint, decodedSession.context, {
|
|
18
18
|
onComplete: onComplete,
|
|
19
19
|
onFail: onFail,
|
|
20
|
-
});
|
|
20
|
+
}, defaultValues);
|
|
21
21
|
default:
|
|
22
22
|
throw new errors_1.UnsupportedLocationError();
|
|
23
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SetupIntent, PaymentIntent } from '@stripe/stripe-js';
|
|
2
2
|
import { StripeContext } from 'src/StripeSession';
|
|
3
|
-
import { Callbacks, ResultCode, WidgetController, WidgetInterface } from './common';
|
|
3
|
+
import { Callbacks, DefaultValues, ResultCode, WidgetController, WidgetInterface } from './common';
|
|
4
4
|
export declare function mapStripeResultCode(code: SetupIntent.Status | PaymentIntent.Status): ResultCode;
|
|
5
|
-
export declare function mount(mountElement: HTMLElement, context: StripeContext, listeners: Callbacks): Promise<WidgetController>;
|
|
5
|
+
export declare function mount(mountElement: HTMLElement, context: StripeContext, listeners: Callbacks, defaultValues?: DefaultValues): Promise<WidgetController>;
|
|
6
6
|
export declare const StripeWidget: WidgetInterface<StripeContext>;
|
package/dist/v1/StripeWidget.js
CHANGED
|
@@ -66,7 +66,7 @@ function init(context) {
|
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
export function mount(mountElement, context, listeners) {
|
|
69
|
+
export function mount(mountElement, context, listeners, defaultValues) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
71
|
var _a, stripe, elements, paymentElement;
|
|
72
72
|
var _this = this;
|
|
@@ -75,17 +75,18 @@ export function mount(mountElement, context, listeners) {
|
|
|
75
75
|
case 0: return [4 /*yield*/, init(context)];
|
|
76
76
|
case 1:
|
|
77
77
|
_a = _b.sent(), stripe = _a.stripe, elements = _a.elements;
|
|
78
|
-
paymentElement = elements.create('payment'
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
paymentElement = elements.create('payment', defaultValues
|
|
79
|
+
? {
|
|
80
|
+
defaultValues: {
|
|
81
|
+
billingDetails: {
|
|
82
|
+
address: {
|
|
83
|
+
country: defaultValues.country,
|
|
84
|
+
postal_code: defaultValues.postalCode,
|
|
85
|
+
},
|
|
85
86
|
},
|
|
86
87
|
},
|
|
87
|
-
}
|
|
88
|
-
|
|
88
|
+
}
|
|
89
|
+
: {});
|
|
89
90
|
paymentElement.mount(mountElement);
|
|
90
91
|
return [2 /*return*/, {
|
|
91
92
|
unmount: function () { return paymentElement.unmount(); },
|
package/dist/v1/common.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type Callbacks = {
|
|
|
12
12
|
onComplete?(result: Result): void;
|
|
13
13
|
onFail?(result: Result): void;
|
|
14
14
|
};
|
|
15
|
+
export type DefaultValues = {
|
|
16
|
+
country?: string;
|
|
17
|
+
postalCode?: string;
|
|
18
|
+
};
|
|
15
19
|
export type WidgetInterface<T> = {
|
|
16
|
-
mount: (mountElement: HTMLElement, context: T, listeners: Callbacks) => Promise<WidgetController>;
|
|
20
|
+
mount: (mountElement: HTMLElement, context: T, listeners: Callbacks, defaultValues?: DefaultValues) => Promise<WidgetController>;
|
|
17
21
|
};
|
package/dist/v1/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export type LightspeedPaymentsV1 = {
|
|
|
15
15
|
* @param {string} session - The session ID for the payment session.
|
|
16
16
|
* @param {PaymentWidgetConfiguration} config - The configuration options for the payment widget.
|
|
17
17
|
*/
|
|
18
|
-
mountPaymentWidget(session: string, { mountPoint, onComplete, onFail }: PaymentWidgetConfiguration): Promise<WidgetController>;
|
|
18
|
+
mountPaymentWidget(session: string, { mountPoint, onComplete, onFail, defaultValues }: PaymentWidgetConfiguration): Promise<WidgetController>;
|
|
19
19
|
};
|
|
20
20
|
export declare const v1: LightspeedPaymentsV1;
|
package/dist/v1/widget.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { StripeSession } from 'src/StripeSession';
|
|
2
2
|
import { AdyenSession } from 'src/AdyenSession';
|
|
3
|
-
import { Callbacks, WidgetController } from 'src/v1/common';
|
|
3
|
+
import { Callbacks, WidgetController, DefaultValues } from 'src/v1/common';
|
|
4
4
|
type Session = {
|
|
5
5
|
metadata: Record<string, string>;
|
|
6
6
|
} & (AdyenSession | StripeSession);
|
|
7
7
|
export type PaymentWidgetConfiguration = {
|
|
8
8
|
mountPoint: HTMLElement;
|
|
9
|
+
defaultValues?: DefaultValues;
|
|
9
10
|
} & Callbacks;
|
|
10
|
-
export declare function mountPaymentWidget(session: string, { mountPoint, onComplete, onFail }: PaymentWidgetConfiguration): Promise<WidgetController>;
|
|
11
|
+
export declare function mountPaymentWidget(session: string, { mountPoint, onComplete, onFail, defaultValues }: PaymentWidgetConfiguration): Promise<WidgetController>;
|
|
11
12
|
export declare function decodePaymentSessionToContext(paymentSession: string): Session;
|
|
12
13
|
export declare function isTokenValid(token: unknown): token is Session;
|
|
13
14
|
export {};
|
package/dist/v1/widget.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AdyenWidget } from './AdyenWidget';
|
|
|
2
2
|
import { InvalidSessionError, InvalidSessionStructureError, UnsupportedLocationError, } from './errors';
|
|
3
3
|
import { StripeWidget } from './StripeWidget';
|
|
4
4
|
export function mountPaymentWidget(session, _a) {
|
|
5
|
-
var mountPoint = _a.mountPoint, onComplete = _a.onComplete, onFail = _a.onFail;
|
|
5
|
+
var mountPoint = _a.mountPoint, onComplete = _a.onComplete, onFail = _a.onFail, defaultValues = _a.defaultValues;
|
|
6
6
|
var decodedSession = decodePaymentSessionToContext(session);
|
|
7
7
|
switch (decodedSession.psp) {
|
|
8
8
|
case 'ADYEN':
|
|
@@ -14,7 +14,7 @@ export function mountPaymentWidget(session, _a) {
|
|
|
14
14
|
return StripeWidget.mount(mountPoint, decodedSession.context, {
|
|
15
15
|
onComplete: onComplete,
|
|
16
16
|
onFail: onFail,
|
|
17
|
-
});
|
|
17
|
+
}, defaultValues);
|
|
18
18
|
default:
|
|
19
19
|
throw new UnsupportedLocationError();
|
|
20
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightspeed/online-payments-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Process online-payments with Lightspeed Payments",
|
|
5
5
|
"author": "Lightspeed Commerce Inc.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"test": "jest --no-cache --detectOpenHandles",
|
|
20
20
|
"lint": "gts lint",
|
|
21
|
+
"fix": "gts fix",
|
|
21
22
|
"clean": "gts clean",
|
|
22
23
|
"typecheck": "tsc --noEmit",
|
|
23
24
|
"check-package-content": "npm pack --dry-run",
|