@one-payments/web-components 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +401 -150
- package/dist/one-payment.d.ts +296 -0
- package/dist/one-payment.d.ts.map +1 -1
- package/dist/one-payment.js +57 -3
- package/dist/one-payment.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const Bt = (t) => new ht(typeof t == "string" ? t : t + "", void 0, Ve), Ft = (t
|
|
|
45
45
|
* Copyright 2017 Google LLC
|
|
46
46
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
47
|
*/
|
|
48
|
-
const { is: Ut, defineProperty:
|
|
48
|
+
const { is: Ut, defineProperty: Ot, getOwnPropertyDescriptor: zt, getOwnPropertyNames: qt, getOwnPropertySymbols: Vt, getPrototypeOf: Ht } = Object, O = globalThis, Xe = O.trustedTypes, jt = Xe ? Xe.emptyScript : "", Ie = O.reactiveElementPolyfillSupport, ie = (t, e) => t, be = { toAttribute(t, e) {
|
|
49
49
|
switch (e) {
|
|
50
50
|
case Boolean:
|
|
51
51
|
t = t ? jt : null;
|
|
@@ -74,7 +74,7 @@ const { is: Ut, defineProperty: zt, getOwnPropertyDescriptor: Ot, getOwnProperty
|
|
|
74
74
|
}
|
|
75
75
|
return n;
|
|
76
76
|
} }, He = (t, e) => !Ut(t, e), et = { attribute: !0, type: String, converter: be, reflect: !1, useDefault: !1, hasChanged: He };
|
|
77
|
-
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")),
|
|
77
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), O.litPropertyMetadata ?? (O.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
78
78
|
let Q = class extends HTMLElement {
|
|
79
79
|
static addInitializer(e) {
|
|
80
80
|
this._$Ei(), (this.l ?? (this.l = [])).push(e);
|
|
@@ -85,11 +85,11 @@ let Q = class extends HTMLElement {
|
|
|
85
85
|
static createProperty(e, n = et) {
|
|
86
86
|
if (n.state && (n.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(e) && ((n = Object.create(n)).wrapped = !0), this.elementProperties.set(e, n), !n.noAccessor) {
|
|
87
87
|
const r = Symbol(), i = this.getPropertyDescriptor(e, r, n);
|
|
88
|
-
i !== void 0 &&
|
|
88
|
+
i !== void 0 && Ot(this.prototype, e, i);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
static getPropertyDescriptor(e, n, r) {
|
|
92
|
-
const { get: i, set: o } =
|
|
92
|
+
const { get: i, set: o } = zt(this.prototype, e) ?? { get() {
|
|
93
93
|
return this[n];
|
|
94
94
|
}, set(s) {
|
|
95
95
|
this[n] = s;
|
|
@@ -278,7 +278,7 @@ let Q = class extends HTMLElement {
|
|
|
278
278
|
firstUpdated(e) {
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
-
Q.elementStyles = [], Q.shadowRootOptions = { mode: "open" }, Q[ie("elementProperties")] = /* @__PURE__ */ new Map(), Q[ie("finalized")] = /* @__PURE__ */ new Map(), Ie == null || Ie({ ReactiveElement: Q }), (
|
|
281
|
+
Q.elementStyles = [], Q.shadowRootOptions = { mode: "open" }, Q[ie("elementProperties")] = /* @__PURE__ */ new Map(), Q[ie("finalized")] = /* @__PURE__ */ new Map(), Ie == null || Ie({ ReactiveElement: Q }), (O.reactiveElementVersions ?? (O.reactiveElementVersions = [])).push("2.1.1");
|
|
282
282
|
/**
|
|
283
283
|
* @license
|
|
284
284
|
* Copyright 2017 Google LLC
|
|
@@ -504,8 +504,8 @@ class en {
|
|
|
504
504
|
J(this, e);
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
const
|
|
508
|
-
|
|
507
|
+
const De = oe.litHtmlPolyfillSupport;
|
|
508
|
+
De == null || De(ce, he), (oe.litHtmlVersions ?? (oe.litHtmlVersions = [])).push("3.3.1");
|
|
509
509
|
const tn = (t, e, n) => {
|
|
510
510
|
const r = (n == null ? void 0 : n.renderBefore) ?? e;
|
|
511
511
|
let i = r._$litPart$;
|
|
@@ -548,8 +548,8 @@ class se extends Q {
|
|
|
548
548
|
}
|
|
549
549
|
var ut;
|
|
550
550
|
se._$litElement$ = !0, se.finalized = !0, (ut = j.litElementHydrateSupport) == null || ut.call(j, { LitElement: se });
|
|
551
|
-
const
|
|
552
|
-
|
|
551
|
+
const $e = j.litElementPolyfillSupport;
|
|
552
|
+
$e == null || $e({ LitElement: se });
|
|
553
553
|
(j.litElementVersions ?? (j.litElementVersions = [])).push("4.2.1");
|
|
554
554
|
/**
|
|
555
555
|
* @license
|
|
@@ -601,10 +601,13 @@ function M(t) {
|
|
|
601
601
|
function _(t) {
|
|
602
602
|
return M({ ...t, state: !0, attribute: !1 });
|
|
603
603
|
}
|
|
604
|
+
function sn(t) {
|
|
605
|
+
return t instanceof Error && ("response" in t && typeof t.response == "object" && t.response !== null || "data" in t && typeof t.data == "object" && t.data !== null);
|
|
606
|
+
}
|
|
604
607
|
var K = {
|
|
605
608
|
CARD: "card",
|
|
606
609
|
PAYNOW: "paynow"
|
|
607
|
-
},
|
|
610
|
+
}, $ = {
|
|
608
611
|
IDLE: "idle",
|
|
609
612
|
INITIALIZING: "initializing",
|
|
610
613
|
READY: "ready",
|
|
@@ -613,10 +616,10 @@ var K = {
|
|
|
613
616
|
SUCCEEDED: "succeeded",
|
|
614
617
|
FAILED: "failed"
|
|
615
618
|
};
|
|
616
|
-
function
|
|
619
|
+
function an(t) {
|
|
617
620
|
return t === "paid" ? "succeeded" : t;
|
|
618
621
|
}
|
|
619
|
-
var
|
|
622
|
+
var ln = class {
|
|
620
623
|
constructor(t, e, n, r, i = {}) {
|
|
621
624
|
this.isPolling = !1, this.attempts = 0, this.startTime = 0, this.pollTimeoutId = null, this.adapters = t, this.baseUrl = e, this.token = n, this.onStatusUpdate = r, this.config = {
|
|
622
625
|
interval: i.interval ?? 3e3,
|
|
@@ -698,10 +701,13 @@ var an = class {
|
|
|
698
701
|
if (this.isPolling) {
|
|
699
702
|
this.attempts++;
|
|
700
703
|
try {
|
|
701
|
-
const t = await this.adapters.http.get(
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
704
|
+
const t = await this.adapters.http.get(
|
|
705
|
+
`${this.baseUrl}/payment-intent/get-payment-data`,
|
|
706
|
+
{
|
|
707
|
+
"x-token": this.token
|
|
708
|
+
}
|
|
709
|
+
), e = {
|
|
710
|
+
status: an(t.result.status),
|
|
705
711
|
// Map "paid" to "succeeded"
|
|
706
712
|
paymentIntentId: t.result.paymentIntentId || "",
|
|
707
713
|
...t.result.amount !== void 0 && { amount: t.result.amount },
|
|
@@ -737,7 +743,7 @@ var an = class {
|
|
|
737
743
|
}
|
|
738
744
|
}
|
|
739
745
|
};
|
|
740
|
-
function
|
|
746
|
+
function dn(t) {
|
|
741
747
|
switch (t) {
|
|
742
748
|
case "prod":
|
|
743
749
|
return "https://public.one.ooo";
|
|
@@ -749,26 +755,75 @@ function ln(t) {
|
|
|
749
755
|
return "https://public.dev.one.ooo";
|
|
750
756
|
}
|
|
751
757
|
}
|
|
752
|
-
var
|
|
758
|
+
var cn = class {
|
|
753
759
|
// Flag to ignore qrCode after user scans it
|
|
754
760
|
constructor(t, e) {
|
|
755
|
-
this.state = { status:
|
|
761
|
+
this.state = { status: $.IDLE }, this.subscribers = /* @__PURE__ */ new Set(), this.eventListeners = {}, this.paymentToken = null, this.paymentIntentId = null, this.pollingService = null, this.ignore3DSInPolling = !1, this.ignoreQRInPolling = !1, this.config = t, this.adapters = e;
|
|
756
762
|
}
|
|
757
763
|
/**
|
|
758
764
|
* Get the API base URL - uses apiBaseUrl if provided, otherwise derives from environment
|
|
759
765
|
*/
|
|
760
766
|
getApiBaseUrl() {
|
|
761
|
-
return this.config.apiBaseUrl ??
|
|
767
|
+
return this.config.apiBaseUrl ?? dn(this.config.environment);
|
|
762
768
|
}
|
|
763
769
|
/**
|
|
764
|
-
* Get current state
|
|
770
|
+
* Get the current payment state
|
|
771
|
+
*
|
|
772
|
+
* Returns an immutable snapshot of the current SDK state. The state follows a discriminated
|
|
773
|
+
* union pattern, where the `status` field determines which additional fields are available.
|
|
774
|
+
*
|
|
775
|
+
* @returns The current state object (readonly)
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```typescript
|
|
779
|
+
* const state = sdk.getState();
|
|
780
|
+
*
|
|
781
|
+
* if (state.status === 'ready') {
|
|
782
|
+
* console.log('Available methods:', state.availableMethods);
|
|
783
|
+
* console.log('Payment intent:', state.paymentIntent);
|
|
784
|
+
* } else if (state.status === 'failed') {
|
|
785
|
+
* console.error('Error:', state.error);
|
|
786
|
+
* }
|
|
787
|
+
* ```
|
|
788
|
+
*
|
|
789
|
+
* @public
|
|
765
790
|
*/
|
|
766
791
|
getState() {
|
|
767
792
|
return this.state;
|
|
768
793
|
}
|
|
769
794
|
/**
|
|
770
795
|
* Subscribe to state changes
|
|
771
|
-
*
|
|
796
|
+
*
|
|
797
|
+
* Registers a callback function that will be called immediately with the current state,
|
|
798
|
+
* and then again whenever the state changes. This is useful for reactive UI updates.
|
|
799
|
+
*
|
|
800
|
+
* @param subscriber - Callback function to be called with state updates
|
|
801
|
+
* @returns Unsubscribe function - call this to stop receiving updates
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```typescript
|
|
805
|
+
* const unsubscribe = sdk.subscribe((state) => {
|
|
806
|
+
* switch (state.status) {
|
|
807
|
+
* case 'ready':
|
|
808
|
+
* console.log('Ready to accept payment');
|
|
809
|
+
* break;
|
|
810
|
+
* case 'processing':
|
|
811
|
+
* console.log('Processing payment...');
|
|
812
|
+
* break;
|
|
813
|
+
* case 'succeeded':
|
|
814
|
+
* console.log('Payment succeeded!');
|
|
815
|
+
* break;
|
|
816
|
+
* case 'failed':
|
|
817
|
+
* console.error('Payment failed:', state.error.message);
|
|
818
|
+
* break;
|
|
819
|
+
* }
|
|
820
|
+
* });
|
|
821
|
+
*
|
|
822
|
+
* // Later, when you want to stop listening:
|
|
823
|
+
* unsubscribe();
|
|
824
|
+
* ```
|
|
825
|
+
*
|
|
826
|
+
* @public
|
|
772
827
|
*/
|
|
773
828
|
subscribe(t) {
|
|
774
829
|
return this.subscribers.add(t), t(this.state), () => {
|
|
@@ -776,7 +831,39 @@ var dn = class {
|
|
|
776
831
|
};
|
|
777
832
|
}
|
|
778
833
|
/**
|
|
779
|
-
* Add event listener
|
|
834
|
+
* Add an event listener for specific payment events
|
|
835
|
+
*
|
|
836
|
+
* Allows you to listen to specific payment lifecycle events with full type safety.
|
|
837
|
+
* Unlike `subscribe`, which receives all state changes, this method lets you listen
|
|
838
|
+
* to specific events like payment initialization, success, failure, etc.
|
|
839
|
+
*
|
|
840
|
+
* @param eventType - The type of event to listen for
|
|
841
|
+
* @param listener - Callback function to be called when the event occurs
|
|
842
|
+
* @returns Unsubscribe function - call this to remove the listener
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* ```typescript
|
|
846
|
+
* // Listen for successful payments
|
|
847
|
+
* const removeListener = sdk.on('payment_succeeded', (event) => {
|
|
848
|
+
* console.log('Payment succeeded!', event.payload.paymentIntent);
|
|
849
|
+
* console.log('Method used:', event.payload.methodId);
|
|
850
|
+
* });
|
|
851
|
+
*
|
|
852
|
+
* // Listen for QR codes
|
|
853
|
+
* sdk.on('qr_code_received', (event) => {
|
|
854
|
+
* displayQRCode(event.payload.qrCode);
|
|
855
|
+
* });
|
|
856
|
+
*
|
|
857
|
+
* // Listen for required actions (3DS)
|
|
858
|
+
* sdk.on('payment_requires_action', (event) => {
|
|
859
|
+
* openAuthenticationWindow(event.payload.actionUrl);
|
|
860
|
+
* });
|
|
861
|
+
*
|
|
862
|
+
* // Later, remove the listener:
|
|
863
|
+
* removeListener();
|
|
864
|
+
* ```
|
|
865
|
+
*
|
|
866
|
+
* @public
|
|
780
867
|
*/
|
|
781
868
|
on(t, e) {
|
|
782
869
|
this.eventListeners[t] || (this.eventListeners[t] = []);
|
|
@@ -787,10 +874,46 @@ var dn = class {
|
|
|
787
874
|
};
|
|
788
875
|
}
|
|
789
876
|
/**
|
|
790
|
-
* Initialize payment intent
|
|
877
|
+
* Initialize a new payment intent
|
|
878
|
+
*
|
|
879
|
+
* Creates a payment intent on the server and fetches available payment methods.
|
|
880
|
+
* This must be called before attempting to submit a payment. The SDK state will
|
|
881
|
+
* transition from 'idle' → 'initializing' → 'ready' (or 'failed' on error).
|
|
882
|
+
*
|
|
883
|
+
* @param params - Payment initialization parameters
|
|
884
|
+
* @param params.amount - Payment amount in smallest currency unit (e.g., cents for USD)
|
|
885
|
+
* @param params.currency - ISO 4217 currency code (e.g., 'USD', 'SGD', 'EUR')
|
|
886
|
+
* @param params.orderId - Your unique order/transaction identifier
|
|
887
|
+
* @param params.notes - Optional notes or description for the payment
|
|
888
|
+
* @param params.metadata - Optional metadata object with custom key-value pairs
|
|
889
|
+
* @returns Promise that resolves with the created payment intent
|
|
890
|
+
* @throws {Error} If initialization fails (network error, invalid credentials, etc.)
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```typescript
|
|
894
|
+
* try {
|
|
895
|
+
* const paymentIntent = await sdk.initialize({
|
|
896
|
+
* amount: 5000, // $50.00
|
|
897
|
+
* currency: 'USD',
|
|
898
|
+
* orderId: 'ORDER-123',
|
|
899
|
+
* notes: 'Premium subscription',
|
|
900
|
+
* metadata: {
|
|
901
|
+
* userId: '12345',
|
|
902
|
+
* subscriptionId: 'sub_abc',
|
|
903
|
+
* },
|
|
904
|
+
* });
|
|
905
|
+
*
|
|
906
|
+
* console.log('Payment intent created:', paymentIntent.id);
|
|
907
|
+
* console.log('Amount with fees:', paymentIntent.amount);
|
|
908
|
+
* } catch (error) {
|
|
909
|
+
* console.error('Failed to initialize:', error);
|
|
910
|
+
* }
|
|
911
|
+
* ```
|
|
912
|
+
*
|
|
913
|
+
* @public
|
|
791
914
|
*/
|
|
792
915
|
async initialize(t) {
|
|
793
|
-
this.setState({ status:
|
|
916
|
+
this.setState({ status: $.INITIALIZING }), this.emit({
|
|
794
917
|
type: "initialize",
|
|
795
918
|
payload: t
|
|
796
919
|
});
|
|
@@ -811,15 +934,21 @@ var dn = class {
|
|
|
811
934
|
if (!s)
|
|
812
935
|
throw new Error("No token found in redirectUrl");
|
|
813
936
|
this.paymentToken = s, this.paymentIntentId = i.result.paymentIntentId;
|
|
814
|
-
const l = await this.adapters.http.get(
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
937
|
+
const l = await this.adapters.http.get(
|
|
938
|
+
`${this.getApiBaseUrl()}/payment-intent/get-payment-data`,
|
|
939
|
+
{
|
|
940
|
+
"x-token": this.paymentToken
|
|
941
|
+
}
|
|
942
|
+
), a = await this.adapters.http.get(
|
|
943
|
+
`${this.getApiBaseUrl()}/payment-intent/available-methods`,
|
|
944
|
+
{
|
|
945
|
+
"x-token": this.paymentToken
|
|
946
|
+
}
|
|
947
|
+
), d = {
|
|
819
948
|
id: this.paymentIntentId,
|
|
820
949
|
amount: l.result.customerAmount || t.amount,
|
|
821
950
|
currency: l.result.currency || t.currency,
|
|
822
|
-
status:
|
|
951
|
+
status: $.READY,
|
|
823
952
|
...t.metadata && { metadata: t.metadata }
|
|
824
953
|
}, c = a.result.paymentMethods.map((h, f) => {
|
|
825
954
|
let u = null;
|
|
@@ -831,7 +960,7 @@ var dn = class {
|
|
|
831
960
|
};
|
|
832
961
|
}).filter((h) => h !== null);
|
|
833
962
|
return this.setState({
|
|
834
|
-
status:
|
|
963
|
+
status: $.READY,
|
|
835
964
|
paymentIntent: d,
|
|
836
965
|
availableMethods: c
|
|
837
966
|
}), this.emit({
|
|
@@ -848,7 +977,7 @@ var dn = class {
|
|
|
848
977
|
timestamp: this.adapters.timer.now()
|
|
849
978
|
};
|
|
850
979
|
throw this.setState({
|
|
851
|
-
status:
|
|
980
|
+
status: $.FAILED,
|
|
852
981
|
error: n
|
|
853
982
|
}), this.emit({
|
|
854
983
|
type: "payment_failed",
|
|
@@ -857,7 +986,56 @@ var dn = class {
|
|
|
857
986
|
}
|
|
858
987
|
}
|
|
859
988
|
/**
|
|
860
|
-
* Submit payment with selected method
|
|
989
|
+
* Submit a payment with the selected payment method
|
|
990
|
+
*
|
|
991
|
+
* Processes a payment using the specified payment method and customer details.
|
|
992
|
+
* The SDK must be in 'ready' state before calling this method. After submission,
|
|
993
|
+
* the SDK automatically polls for payment status updates.
|
|
994
|
+
*
|
|
995
|
+
* For card payments, the payment may require 3D Secure authentication, which will
|
|
996
|
+
* trigger a 'payment_requires_action' event with an authentication URL.
|
|
997
|
+
*
|
|
998
|
+
* For PayNow/QR payments, a QR code will be provided via 'qr_code_received' event
|
|
999
|
+
* that the customer needs to scan with their mobile banking app.
|
|
1000
|
+
*
|
|
1001
|
+
* @param methodId - The payment method to use ('card' or 'paynow')
|
|
1002
|
+
* @param paymentData - Payment details object containing customer and payment information
|
|
1003
|
+
* @param paymentData.firstName - Customer's first name
|
|
1004
|
+
* @param paymentData.lastName - Customer's last name
|
|
1005
|
+
* @param paymentData.email - Customer's email address
|
|
1006
|
+
* @param paymentData.cardNumber - Card number (for card payments)
|
|
1007
|
+
* @param paymentData.expiryMonth - Card expiry month (for card payments)
|
|
1008
|
+
* @param paymentData.expiryYear - Card expiry year (for card payments)
|
|
1009
|
+
* @param paymentData.cvv - Card CVV code (for card payments)
|
|
1010
|
+
* @returns Promise that resolves with the payment intent
|
|
1011
|
+
* @throws {Error} If SDK is not in ready state, no payment token available, or submission fails
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* ```typescript
|
|
1015
|
+
* // Card payment
|
|
1016
|
+
* try {
|
|
1017
|
+
* await sdk.submitPayment('card', {
|
|
1018
|
+
* firstName: 'John',
|
|
1019
|
+
* lastName: 'Doe',
|
|
1020
|
+
* email: 'john@example.com',
|
|
1021
|
+
* cardNumber: '4242424242424242',
|
|
1022
|
+
* expiryMonth: '12',
|
|
1023
|
+
* expiryYear: '2025',
|
|
1024
|
+
* cvv: '123',
|
|
1025
|
+
* });
|
|
1026
|
+
* } catch (error) {
|
|
1027
|
+
* console.error('Payment failed:', error);
|
|
1028
|
+
* }
|
|
1029
|
+
*
|
|
1030
|
+
* // PayNow payment
|
|
1031
|
+
* await sdk.submitPayment('paynow', {
|
|
1032
|
+
* firstName: 'John',
|
|
1033
|
+
* lastName: 'Doe',
|
|
1034
|
+
* email: 'john@example.com',
|
|
1035
|
+
* });
|
|
1036
|
+
* ```
|
|
1037
|
+
*
|
|
1038
|
+
* @public
|
|
861
1039
|
*/
|
|
862
1040
|
async submitPayment(t, e) {
|
|
863
1041
|
var r, i, o, s, l;
|
|
@@ -867,7 +1045,7 @@ var dn = class {
|
|
|
867
1045
|
if (!this.paymentToken)
|
|
868
1046
|
throw new Error("Cannot submit payment: No payment token available");
|
|
869
1047
|
this.ignore3DSInPolling = !1, this.ignoreQRInPolling = !1, this.setState({
|
|
870
|
-
status:
|
|
1048
|
+
status: $.PROCESSING,
|
|
871
1049
|
paymentIntent: n.paymentIntent,
|
|
872
1050
|
selectedMethod: t,
|
|
873
1051
|
availableMethods: n.availableMethods
|
|
@@ -880,16 +1058,16 @@ var dn = class {
|
|
|
880
1058
|
});
|
|
881
1059
|
try {
|
|
882
1060
|
const a = {
|
|
883
|
-
firstName: e.firstName,
|
|
884
|
-
lastName: e.lastName,
|
|
885
|
-
email: e.email,
|
|
1061
|
+
firstName: String(e.firstName),
|
|
1062
|
+
lastName: String(e.lastName),
|
|
1063
|
+
email: String(e.email),
|
|
886
1064
|
paymentMethod: t === "card" ? {
|
|
887
1065
|
type: "card",
|
|
888
1066
|
card: {
|
|
889
|
-
number: e.cardNumber,
|
|
890
|
-
expiryMonth: e.expiryMonth,
|
|
891
|
-
expiryYear: e.expiryYear,
|
|
892
|
-
cvc: e.cvv
|
|
1067
|
+
number: String(e.cardNumber),
|
|
1068
|
+
expiryMonth: String(e.expiryMonth),
|
|
1069
|
+
expiryYear: String(e.expiryYear),
|
|
1070
|
+
cvc: String(e.cvv)
|
|
893
1071
|
}
|
|
894
1072
|
} : { type: "qr" }
|
|
895
1073
|
};
|
|
@@ -903,19 +1081,15 @@ var dn = class {
|
|
|
903
1081
|
id: this.paymentIntentId || "",
|
|
904
1082
|
amount: n.paymentIntent.amount,
|
|
905
1083
|
currency: n.paymentIntent.currency,
|
|
906
|
-
status:
|
|
1084
|
+
status: $.PROCESSING
|
|
907
1085
|
};
|
|
908
1086
|
} catch (a) {
|
|
909
1087
|
let d = "Unknown error", c = "PAYMENT_FAILED";
|
|
910
1088
|
if (a instanceof Error)
|
|
911
1089
|
try {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
d = u.message || ((i = u.error) == null ? void 0 : i.message) || a.message, c = u.code || ((o = u.error) == null ? void 0 : o.code) || c;
|
|
916
|
-
} else if (f.data) {
|
|
917
|
-
const u = f.data;
|
|
918
|
-
d = u.message || ((s = u.error) == null ? void 0 : s.message) || a.message, c = u.code || ((l = u.error) == null ? void 0 : l.code) || c;
|
|
1090
|
+
if (sn(a)) {
|
|
1091
|
+
const f = (r = a.response) == null ? void 0 : r.data, u = a.data;
|
|
1092
|
+
f ? (d = f.message || ((i = f.error) == null ? void 0 : i.message) || a.message, c = f.code || ((o = f.error) == null ? void 0 : o.code) || c) : u ? (d = u.message || ((s = u.error) == null ? void 0 : s.message) || a.message, c = u.code || ((l = u.error) == null ? void 0 : l.code) || c) : d = a.message;
|
|
919
1093
|
} else
|
|
920
1094
|
d = a.message;
|
|
921
1095
|
} catch {
|
|
@@ -927,7 +1101,7 @@ var dn = class {
|
|
|
927
1101
|
timestamp: this.adapters.timer.now()
|
|
928
1102
|
};
|
|
929
1103
|
throw this.setState({
|
|
930
|
-
status:
|
|
1104
|
+
status: $.FAILED,
|
|
931
1105
|
error: h,
|
|
932
1106
|
paymentIntent: n.paymentIntent
|
|
933
1107
|
}), this.emit({
|
|
@@ -940,8 +1114,39 @@ var dn = class {
|
|
|
940
1114
|
}
|
|
941
1115
|
}
|
|
942
1116
|
/**
|
|
943
|
-
* Resume polling after
|
|
944
|
-
*
|
|
1117
|
+
* Resume polling after 3D Secure or QR code flow completes
|
|
1118
|
+
*
|
|
1119
|
+
* This method should be called after the user completes 3D Secure authentication
|
|
1120
|
+
* or scans a QR code. It resumes payment status polling while ignoring subsequent
|
|
1121
|
+
* action URLs or QR codes to prevent showing the same modal/action multiple times.
|
|
1122
|
+
*
|
|
1123
|
+
* The SDK will continue polling until it receives a terminal status (succeeded or failed).
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* ```typescript
|
|
1127
|
+
* // After 3DS authentication completes
|
|
1128
|
+
* sdk.on('payment_requires_action', (event) => {
|
|
1129
|
+
* const authWindow = window.open(event.payload.actionUrl);
|
|
1130
|
+
*
|
|
1131
|
+
* // Monitor when auth window closes
|
|
1132
|
+
* const checkClosed = setInterval(() => {
|
|
1133
|
+
* if (authWindow?.closed) {
|
|
1134
|
+
* clearInterval(checkClosed);
|
|
1135
|
+
* sdk.resumePolling(); // Resume polling for final status
|
|
1136
|
+
* }
|
|
1137
|
+
* }, 500);
|
|
1138
|
+
* });
|
|
1139
|
+
*
|
|
1140
|
+
* // After QR code is scanned
|
|
1141
|
+
* sdk.on('qr_code_received', (event) => {
|
|
1142
|
+
* displayQRCode(event.payload.qrCode);
|
|
1143
|
+
* // User scans QR code with their banking app
|
|
1144
|
+
* // Once they confirm payment in their app:
|
|
1145
|
+
* sdk.resumePolling(); // Resume polling for final status
|
|
1146
|
+
* });
|
|
1147
|
+
* ```
|
|
1148
|
+
*
|
|
1149
|
+
* @public
|
|
945
1150
|
*/
|
|
946
1151
|
resumePolling() {
|
|
947
1152
|
if (!this.paymentToken) {
|
|
@@ -951,7 +1156,29 @@ var dn = class {
|
|
|
951
1156
|
this.ignore3DSInPolling = !0, this.ignoreQRInPolling = !0, this.startPolling();
|
|
952
1157
|
}
|
|
953
1158
|
/**
|
|
954
|
-
* Destroy SDK instance and
|
|
1159
|
+
* Destroy the SDK instance and clean up all resources
|
|
1160
|
+
*
|
|
1161
|
+
* This method should be called when you're done with the SDK instance to:
|
|
1162
|
+
* - Stop all polling operations
|
|
1163
|
+
* - Remove all event listeners
|
|
1164
|
+
* - Clear all state subscribers
|
|
1165
|
+
* - Free up memory
|
|
1166
|
+
*
|
|
1167
|
+
* After calling destroy(), the SDK instance should not be used again.
|
|
1168
|
+
*
|
|
1169
|
+
* @example
|
|
1170
|
+
* ```typescript
|
|
1171
|
+
* // When component unmounts or page unloads
|
|
1172
|
+
* useEffect(() => {
|
|
1173
|
+
* const sdk = new PaymentSDK(config, adapters);
|
|
1174
|
+
*
|
|
1175
|
+
* return () => {
|
|
1176
|
+
* sdk.destroy(); // Cleanup on unmount
|
|
1177
|
+
* };
|
|
1178
|
+
* }, []);
|
|
1179
|
+
* ```
|
|
1180
|
+
*
|
|
1181
|
+
* @public
|
|
955
1182
|
*/
|
|
956
1183
|
destroy() {
|
|
957
1184
|
this.stopPolling(), this.subscribers.clear(), Object.keys(this.eventListeners).forEach((t) => {
|
|
@@ -966,7 +1193,7 @@ var dn = class {
|
|
|
966
1193
|
console.warn("Cannot start polling: no payment token available");
|
|
967
1194
|
return;
|
|
968
1195
|
}
|
|
969
|
-
this.stopPolling(), this.pollingService = new
|
|
1196
|
+
this.stopPolling(), this.pollingService = new ln(
|
|
970
1197
|
this.adapters,
|
|
971
1198
|
this.getApiBaseUrl(),
|
|
972
1199
|
this.paymentToken,
|
|
@@ -1031,11 +1258,11 @@ var dn = class {
|
|
|
1031
1258
|
id: t.paymentIntentId,
|
|
1032
1259
|
amount: t.amount ?? e.paymentIntent.amount,
|
|
1033
1260
|
currency: t.currency ?? e.paymentIntent.currency,
|
|
1034
|
-
status:
|
|
1261
|
+
status: $.REQUIRES_ACTION,
|
|
1035
1262
|
...t.metadata && { metadata: t.metadata }
|
|
1036
1263
|
};
|
|
1037
1264
|
this.setState({
|
|
1038
|
-
status:
|
|
1265
|
+
status: $.REQUIRES_ACTION,
|
|
1039
1266
|
paymentIntent: r,
|
|
1040
1267
|
actionUrl: t.nextActionUrl,
|
|
1041
1268
|
selectedMethod: e.selectedMethod,
|
|
@@ -1059,7 +1286,7 @@ var dn = class {
|
|
|
1059
1286
|
};
|
|
1060
1287
|
if (t.status === "succeeded")
|
|
1061
1288
|
this.stopPolling(), this.setState({
|
|
1062
|
-
status:
|
|
1289
|
+
status: $.SUCCEEDED,
|
|
1063
1290
|
paymentIntent: n,
|
|
1064
1291
|
selectedMethod: e.selectedMethod
|
|
1065
1292
|
}), this.emit({
|
|
@@ -1077,7 +1304,7 @@ var dn = class {
|
|
|
1077
1304
|
timestamp: this.adapters.timer.now()
|
|
1078
1305
|
};
|
|
1079
1306
|
this.setState({
|
|
1080
|
-
status:
|
|
1307
|
+
status: $.FAILED,
|
|
1081
1308
|
error: i,
|
|
1082
1309
|
paymentIntent: n
|
|
1083
1310
|
}), this.emit({
|
|
@@ -1143,7 +1370,7 @@ H.prototype = {
|
|
|
1143
1370
|
return e.tailPrefix ? r + o.toString() + (e.numeralDecimalScale > 0 ? s.toString() : "") + e.prefix : i + o.toString() + (e.numeralDecimalScale > 0 ? s.toString() : "");
|
|
1144
1371
|
}
|
|
1145
1372
|
};
|
|
1146
|
-
var
|
|
1373
|
+
var un = H, yt = function(t, e, n) {
|
|
1147
1374
|
var r = this;
|
|
1148
1375
|
r.date = [], r.blocks = [], r.datePattern = t, r.dateMin = e.split("-").reverse().map(function(i) {
|
|
1149
1376
|
return parseInt(i, 10);
|
|
@@ -1230,7 +1457,7 @@ yt.prototype = {
|
|
|
1230
1457
|
return e ? (t < 10 ? "000" : t < 100 ? "00" : t < 1e3 ? "0" : "") + t : (t < 10 ? "0" : "") + t;
|
|
1231
1458
|
}
|
|
1232
1459
|
};
|
|
1233
|
-
var
|
|
1460
|
+
var hn = yt, bt = function(t, e) {
|
|
1234
1461
|
var n = this;
|
|
1235
1462
|
n.time = [], n.blocks = [], n.timePattern = t, n.timeFormat = e, n.initBlocks();
|
|
1236
1463
|
};
|
|
@@ -1323,7 +1550,7 @@ bt.prototype = {
|
|
|
1323
1550
|
return (t < 10 ? "0" : "") + t;
|
|
1324
1551
|
}
|
|
1325
1552
|
};
|
|
1326
|
-
var
|
|
1553
|
+
var fn = bt, wt = function(t, e) {
|
|
1327
1554
|
var n = this;
|
|
1328
1555
|
n.delimiter = e || e === "" ? e : " ", n.delimiterRE = e ? new RegExp("\\" + e, "g") : "", n.formatter = t;
|
|
1329
1556
|
};
|
|
@@ -1339,7 +1566,7 @@ wt.prototype = {
|
|
|
1339
1566
|
return n = n.replace(/[()]/g, ""), n = n.replace(/[\s-]/g, e.delimiter), n;
|
|
1340
1567
|
}
|
|
1341
1568
|
};
|
|
1342
|
-
var
|
|
1569
|
+
var mn = wt, Fe = {
|
|
1343
1570
|
blocks: {
|
|
1344
1571
|
uatp: [4, 5, 6],
|
|
1345
1572
|
amex: [4, 6, 5],
|
|
@@ -1406,7 +1633,7 @@ var fn = wt, Fe = {
|
|
|
1406
1633
|
blocks: e ? this.getStrictBlocks(n.general) : n.general
|
|
1407
1634
|
};
|
|
1408
1635
|
}
|
|
1409
|
-
},
|
|
1636
|
+
}, pn = Fe, gn = {
|
|
1410
1637
|
noop: function() {
|
|
1411
1638
|
},
|
|
1412
1639
|
strip: function(t, e) {
|
|
@@ -1535,7 +1762,7 @@ var fn = wt, Fe = {
|
|
|
1535
1762
|
isAndroidBackspaceKeydown: function(t, e) {
|
|
1536
1763
|
return !this.isAndroid() || !t || !e ? !1 : e === t.slice(0, -1);
|
|
1537
1764
|
}
|
|
1538
|
-
},
|
|
1765
|
+
}, yn = gn, bn = {
|
|
1539
1766
|
// Maybe change to object-assign
|
|
1540
1767
|
// for now just keep it as simple
|
|
1541
1768
|
assign: function(t, e) {
|
|
@@ -1543,7 +1770,7 @@ var fn = wt, Fe = {
|
|
|
1543
1770
|
}, t.phone = !!e.phone, t.phoneRegionCode = e.phoneRegionCode || "AU", t.phoneFormatter = {}, t.time = !!e.time, t.timePattern = e.timePattern || ["h", "m", "s"], t.timeFormat = e.timeFormat || "24", t.timeFormatter = {}, t.date = !!e.date, t.datePattern = e.datePattern || ["d", "m", "Y"], t.dateMin = e.dateMin || "", t.dateMax = e.dateMax || "", t.dateFormatter = {}, t.numeral = !!e.numeral, t.numeralIntegerScale = e.numeralIntegerScale > 0 ? e.numeralIntegerScale : 0, t.numeralDecimalScale = e.numeralDecimalScale >= 0 ? e.numeralDecimalScale : 2, t.numeralDecimalMark = e.numeralDecimalMark || ".", t.numeralThousandsGroupStyle = e.numeralThousandsGroupStyle || "thousand", t.numeralPositiveOnly = !!e.numeralPositiveOnly, t.stripLeadingZeroes = e.stripLeadingZeroes !== !1, t.signBeforePrefix = !!e.signBeforePrefix, t.tailPrefix = !!e.tailPrefix, t.swapHiddenInput = !!e.swapHiddenInput, t.numericOnly = t.creditCard || t.date || !!e.numericOnly, t.uppercase = !!e.uppercase, t.lowercase = !!e.lowercase, t.prefix = t.creditCard || t.date ? "" : e.prefix || "", t.noImmediatePrefix = !!e.noImmediatePrefix, t.prefixLength = t.prefix.length, t.rawValueTrimPrefix = !!e.rawValueTrimPrefix, t.copyDelimiter = !!e.copyDelimiter, t.initValue = e.initValue !== void 0 && e.initValue !== null ? e.initValue.toString() : "", t.delimiter = e.delimiter || e.delimiter === "" ? e.delimiter : e.date ? "/" : e.time ? ":" : e.numeral ? "," : (e.phone, " "), t.delimiterLength = t.delimiter.length, t.delimiterLazyShow = !!e.delimiterLazyShow, t.delimiters = e.delimiters || [], t.blocks = e.blocks || [], t.blocksLength = t.blocks.length, t.root = typeof Z == "object" && Z ? Z : window, t.document = e.document || t.root.document, t.maxLength = 0, t.backspace = !1, t.result = "", t.onValueChanged = e.onValueChanged || function() {
|
|
1544
1771
|
}, t;
|
|
1545
1772
|
}
|
|
1546
|
-
},
|
|
1773
|
+
}, wn = bn, x = function(t, e) {
|
|
1547
1774
|
var n = this, r = !1;
|
|
1548
1775
|
if (typeof t == "string" ? (n.element = document.querySelector(t), r = document.querySelectorAll(t).length > 1) : typeof t.length < "u" && t.length > 0 ? (n.element = t[0], r = t.length > 1) : n.element = t, !n.element)
|
|
1549
1776
|
throw new Error("[cleave.js] Please check the element");
|
|
@@ -1714,19 +1941,19 @@ x.prototype = {
|
|
|
1714
1941
|
return "[Cleave Object]";
|
|
1715
1942
|
}
|
|
1716
1943
|
};
|
|
1717
|
-
x.NumeralFormatter =
|
|
1718
|
-
x.DateFormatter =
|
|
1719
|
-
x.TimeFormatter =
|
|
1720
|
-
x.PhoneFormatter =
|
|
1721
|
-
x.CreditCardDetector =
|
|
1722
|
-
x.Util =
|
|
1723
|
-
x.DefaultProperties =
|
|
1944
|
+
x.NumeralFormatter = un;
|
|
1945
|
+
x.DateFormatter = hn;
|
|
1946
|
+
x.TimeFormatter = fn;
|
|
1947
|
+
x.PhoneFormatter = mn;
|
|
1948
|
+
x.CreditCardDetector = pn;
|
|
1949
|
+
x.Util = yn;
|
|
1950
|
+
x.DefaultProperties = wn;
|
|
1724
1951
|
(typeof Z == "object" && Z ? Z : window).Cleave = x;
|
|
1725
|
-
var at = x, fe = {},
|
|
1952
|
+
var at = x, fe = {}, vn = function() {
|
|
1726
1953
|
return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
|
|
1727
|
-
}, vt = {},
|
|
1954
|
+
}, vt = {}, D = {};
|
|
1728
1955
|
let Ye;
|
|
1729
|
-
const
|
|
1956
|
+
const xn = [
|
|
1730
1957
|
0,
|
|
1731
1958
|
// Not used
|
|
1732
1959
|
26,
|
|
@@ -1770,29 +1997,29 @@ const vn = [
|
|
|
1770
1997
|
3532,
|
|
1771
1998
|
3706
|
|
1772
1999
|
];
|
|
1773
|
-
|
|
2000
|
+
D.getSymbolSize = function(e) {
|
|
1774
2001
|
if (!e) throw new Error('"version" cannot be null or undefined');
|
|
1775
2002
|
if (e < 1 || e > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
1776
2003
|
return e * 4 + 17;
|
|
1777
2004
|
};
|
|
1778
|
-
|
|
1779
|
-
return
|
|
2005
|
+
D.getSymbolTotalCodewords = function(e) {
|
|
2006
|
+
return xn[e];
|
|
1780
2007
|
};
|
|
1781
|
-
|
|
2008
|
+
D.getBCHDigit = function(t) {
|
|
1782
2009
|
let e = 0;
|
|
1783
2010
|
for (; t !== 0; )
|
|
1784
2011
|
e++, t >>>= 1;
|
|
1785
2012
|
return e;
|
|
1786
2013
|
};
|
|
1787
|
-
|
|
2014
|
+
D.setToSJISFunction = function(e) {
|
|
1788
2015
|
if (typeof e != "function")
|
|
1789
2016
|
throw new Error('"toSJISFunc" is not a valid function.');
|
|
1790
2017
|
Ye = e;
|
|
1791
2018
|
};
|
|
1792
|
-
|
|
2019
|
+
D.isKanjiModeEnabled = function() {
|
|
1793
2020
|
return typeof Ye < "u";
|
|
1794
2021
|
};
|
|
1795
|
-
|
|
2022
|
+
D.toSJIS = function(e) {
|
|
1796
2023
|
return Ye(e);
|
|
1797
2024
|
};
|
|
1798
2025
|
var Ce = {};
|
|
@@ -1850,7 +2077,7 @@ xt.prototype = {
|
|
|
1850
2077
|
this.buffer.length <= e && this.buffer.push(0), t && (this.buffer[e] |= 128 >>> this.length % 8), this.length++;
|
|
1851
2078
|
}
|
|
1852
2079
|
};
|
|
1853
|
-
var
|
|
2080
|
+
var Sn = xt;
|
|
1854
2081
|
function me(t) {
|
|
1855
2082
|
if (!t || t < 1)
|
|
1856
2083
|
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
@@ -1869,9 +2096,9 @@ me.prototype.xor = function(t, e, n) {
|
|
|
1869
2096
|
me.prototype.isReserved = function(t, e) {
|
|
1870
2097
|
return this.reservedBit[t * this.size + e];
|
|
1871
2098
|
};
|
|
1872
|
-
var
|
|
2099
|
+
var Cn = me, St = {};
|
|
1873
2100
|
(function(t) {
|
|
1874
|
-
const e =
|
|
2101
|
+
const e = D.getSymbolSize;
|
|
1875
2102
|
t.getRowColCoords = function(r) {
|
|
1876
2103
|
if (r === 1) return [];
|
|
1877
2104
|
const i = Math.floor(r / 7) + 2, o = e(r), s = o === 145 ? 26 : Math.ceil((o - 13) / (2 * i - 2)) * 2, l = [o - 7];
|
|
@@ -1889,9 +2116,9 @@ var Sn = me, St = {};
|
|
|
1889
2116
|
};
|
|
1890
2117
|
})(St);
|
|
1891
2118
|
var Ct = {};
|
|
1892
|
-
const
|
|
2119
|
+
const kn = D.getSymbolSize, lt = 7;
|
|
1893
2120
|
Ct.getPositions = function(e) {
|
|
1894
|
-
const n =
|
|
2121
|
+
const n = kn(e);
|
|
1895
2122
|
return [
|
|
1896
2123
|
// top-left
|
|
1897
2124
|
[0, 0],
|
|
@@ -2415,30 +2642,30 @@ Ke.prototype.encode = function(e) {
|
|
|
2415
2642
|
}
|
|
2416
2643
|
return r;
|
|
2417
2644
|
};
|
|
2418
|
-
var
|
|
2645
|
+
var En = Ke, Pt = {}, z = {}, Qe = {};
|
|
2419
2646
|
Qe.isValid = function(e) {
|
|
2420
2647
|
return !isNaN(e) && e >= 1 && e <= 40;
|
|
2421
2648
|
};
|
|
2422
2649
|
var R = {};
|
|
2423
|
-
const It = "[0-9]+",
|
|
2650
|
+
const It = "[0-9]+", An = "[A-Z $%*+\\-./:]+";
|
|
2424
2651
|
let ue = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
2425
2652
|
ue = ue.replace(/u/g, "\\u");
|
|
2426
|
-
const
|
|
2653
|
+
const Pn = "(?:(?![A-Z0-9 $%*+\\-./:]|" + ue + `)(?:.|[\r
|
|
2427
2654
|
]))+`;
|
|
2428
2655
|
R.KANJI = new RegExp(ue, "g");
|
|
2429
2656
|
R.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
2430
|
-
R.BYTE = new RegExp(
|
|
2657
|
+
R.BYTE = new RegExp(Pn, "g");
|
|
2431
2658
|
R.NUMERIC = new RegExp(It, "g");
|
|
2432
|
-
R.ALPHANUMERIC = new RegExp(
|
|
2433
|
-
const
|
|
2659
|
+
R.ALPHANUMERIC = new RegExp(An, "g");
|
|
2660
|
+
const In = new RegExp("^" + ue + "$"), _n = new RegExp("^" + It + "$"), Dn = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
2434
2661
|
R.testKanji = function(e) {
|
|
2435
|
-
return
|
|
2662
|
+
return In.test(e);
|
|
2436
2663
|
};
|
|
2437
2664
|
R.testNumeric = function(e) {
|
|
2438
|
-
return
|
|
2665
|
+
return _n.test(e);
|
|
2439
2666
|
};
|
|
2440
2667
|
R.testAlphanumeric = function(e) {
|
|
2441
|
-
return
|
|
2668
|
+
return Dn.test(e);
|
|
2442
2669
|
};
|
|
2443
2670
|
(function(t) {
|
|
2444
2671
|
const e = Qe, n = R;
|
|
@@ -2498,9 +2725,9 @@ R.testAlphanumeric = function(e) {
|
|
|
2498
2725
|
return s;
|
|
2499
2726
|
}
|
|
2500
2727
|
};
|
|
2501
|
-
})(
|
|
2728
|
+
})(z);
|
|
2502
2729
|
(function(t) {
|
|
2503
|
-
const e =
|
|
2730
|
+
const e = D, n = ke, r = Ce, i = z, o = Qe, s = 7973, l = e.getBCHDigit(s);
|
|
2504
2731
|
function a(f, u, m) {
|
|
2505
2732
|
for (let g = 1; g <= 40; g++)
|
|
2506
2733
|
if (u <= t.getCapacity(g, m, f))
|
|
@@ -2563,18 +2790,18 @@ R.testAlphanumeric = function(e) {
|
|
|
2563
2790
|
};
|
|
2564
2791
|
})(Pt);
|
|
2565
2792
|
var _t = {};
|
|
2566
|
-
const Le =
|
|
2793
|
+
const Le = D, Dt = 1335, $n = 21522, dt = Le.getBCHDigit(Dt);
|
|
2567
2794
|
_t.getEncodedBits = function(e, n) {
|
|
2568
2795
|
const r = e.bit << 3 | n;
|
|
2569
2796
|
let i = r << 10;
|
|
2570
2797
|
for (; Le.getBCHDigit(i) - dt >= 0; )
|
|
2571
|
-
i ^=
|
|
2798
|
+
i ^= Dt << Le.getBCHDigit(i) - dt;
|
|
2572
2799
|
return (r << 10 | i) ^ $n;
|
|
2573
2800
|
};
|
|
2574
|
-
var
|
|
2575
|
-
const
|
|
2801
|
+
var $t = {};
|
|
2802
|
+
const Mn = z;
|
|
2576
2803
|
function W(t) {
|
|
2577
|
-
this.mode =
|
|
2804
|
+
this.mode = Mn.NUMERIC, this.data = t.toString();
|
|
2578
2805
|
}
|
|
2579
2806
|
W.getBitsLength = function(e) {
|
|
2580
2807
|
return 10 * Math.floor(e / 3) + (e % 3 ? e % 3 * 3 + 1 : 0);
|
|
@@ -2592,8 +2819,8 @@ W.prototype.write = function(e) {
|
|
|
2592
2819
|
const o = this.data.length - n;
|
|
2593
2820
|
o > 0 && (r = this.data.substr(n), i = parseInt(r, 10), e.put(i, o * 3 + 1));
|
|
2594
2821
|
};
|
|
2595
|
-
var
|
|
2596
|
-
const
|
|
2822
|
+
var Tn = W;
|
|
2823
|
+
const Nn = z, Me = [
|
|
2597
2824
|
"0",
|
|
2598
2825
|
"1",
|
|
2599
2826
|
"2",
|
|
@@ -2641,7 +2868,7 @@ const Tn = O, Me = [
|
|
|
2641
2868
|
":"
|
|
2642
2869
|
];
|
|
2643
2870
|
function X(t) {
|
|
2644
|
-
this.mode =
|
|
2871
|
+
this.mode = Nn.ALPHANUMERIC, this.data = t;
|
|
2645
2872
|
}
|
|
2646
2873
|
X.getBitsLength = function(e) {
|
|
2647
2874
|
return 11 * Math.floor(e / 2) + 6 * (e % 2);
|
|
@@ -2660,10 +2887,10 @@ X.prototype.write = function(e) {
|
|
|
2660
2887
|
}
|
|
2661
2888
|
this.data.length % 2 && e.put(Me.indexOf(this.data[n]), 6);
|
|
2662
2889
|
};
|
|
2663
|
-
var
|
|
2664
|
-
const
|
|
2890
|
+
var Rn = X;
|
|
2891
|
+
const Bn = z;
|
|
2665
2892
|
function ee(t) {
|
|
2666
|
-
this.mode =
|
|
2893
|
+
this.mode = Bn.BYTE, typeof t == "string" ? this.data = new TextEncoder().encode(t) : this.data = new Uint8Array(t);
|
|
2667
2894
|
}
|
|
2668
2895
|
ee.getBitsLength = function(e) {
|
|
2669
2896
|
return e * 8;
|
|
@@ -2678,10 +2905,10 @@ ee.prototype.write = function(t) {
|
|
|
2678
2905
|
for (let e = 0, n = this.data.length; e < n; e++)
|
|
2679
2906
|
t.put(this.data[e], 8);
|
|
2680
2907
|
};
|
|
2681
|
-
var
|
|
2682
|
-
const
|
|
2908
|
+
var Fn = ee;
|
|
2909
|
+
const Ln = z, Un = D;
|
|
2683
2910
|
function te(t) {
|
|
2684
|
-
this.mode =
|
|
2911
|
+
this.mode = Ln.KANJI, this.data = t;
|
|
2685
2912
|
}
|
|
2686
2913
|
te.getBitsLength = function(e) {
|
|
2687
2914
|
return e * 13;
|
|
@@ -2695,7 +2922,7 @@ te.prototype.getBitsLength = function() {
|
|
|
2695
2922
|
te.prototype.write = function(t) {
|
|
2696
2923
|
let e;
|
|
2697
2924
|
for (e = 0; e < this.data.length; e++) {
|
|
2698
|
-
let n =
|
|
2925
|
+
let n = Un.toSJIS(this.data[e]);
|
|
2699
2926
|
if (n >= 33088 && n <= 40956)
|
|
2700
2927
|
n -= 33088;
|
|
2701
2928
|
else if (n >= 57408 && n <= 60351)
|
|
@@ -2708,7 +2935,7 @@ Make sure your charset is UTF-8`
|
|
|
2708
2935
|
n = (n >>> 8 & 255) * 192 + (n & 255), t.put(n, 13);
|
|
2709
2936
|
}
|
|
2710
2937
|
};
|
|
2711
|
-
var
|
|
2938
|
+
var On = te, Mt = { exports: {} };
|
|
2712
2939
|
(function(t) {
|
|
2713
2940
|
var e = {
|
|
2714
2941
|
single_source_shortest_paths: function(n, r, i) {
|
|
@@ -2776,7 +3003,7 @@ var Un = te, Mt = { exports: {} };
|
|
|
2776
3003
|
})(Mt);
|
|
2777
3004
|
var zn = Mt.exports;
|
|
2778
3005
|
(function(t) {
|
|
2779
|
-
const e =
|
|
3006
|
+
const e = z, n = Tn, r = Rn, i = Fn, o = On, s = R, l = D, a = zn;
|
|
2780
3007
|
function d(b) {
|
|
2781
3008
|
return unescape(encodeURIComponent(b)).length;
|
|
2782
3009
|
}
|
|
@@ -2905,10 +3132,10 @@ var zn = Mt.exports;
|
|
|
2905
3132
|
h(w, l.isKanjiModeEnabled())
|
|
2906
3133
|
);
|
|
2907
3134
|
};
|
|
2908
|
-
})(
|
|
2909
|
-
const Ae =
|
|
2910
|
-
function
|
|
2911
|
-
const n = t.size, r =
|
|
3135
|
+
})($t);
|
|
3136
|
+
const Ae = D, Te = Ce, qn = Sn, Vn = Cn, Hn = St, jn = Ct, Ue = kt, Oe = ke, Yn = En, xe = Pt, Kn = _t, Qn = z, Ne = $t;
|
|
3137
|
+
function Zn(t, e) {
|
|
3138
|
+
const n = t.size, r = jn.getPositions(e);
|
|
2912
3139
|
for (let i = 0; i < r.length; i++) {
|
|
2913
3140
|
const o = r[i][0], s = r[i][1];
|
|
2914
3141
|
for (let l = -1; l <= 7; l++)
|
|
@@ -2917,15 +3144,15 @@ function Qn(t, e) {
|
|
|
2917
3144
|
s + a <= -1 || n <= s + a || (l >= 0 && l <= 6 && (a === 0 || a === 6) || a >= 0 && a <= 6 && (l === 0 || l === 6) || l >= 2 && l <= 4 && a >= 2 && a <= 4 ? t.set(o + l, s + a, !0, !0) : t.set(o + l, s + a, !1, !0));
|
|
2918
3145
|
}
|
|
2919
3146
|
}
|
|
2920
|
-
function
|
|
3147
|
+
function Gn(t) {
|
|
2921
3148
|
const e = t.size;
|
|
2922
3149
|
for (let n = 8; n < e - 8; n++) {
|
|
2923
3150
|
const r = n % 2 === 0;
|
|
2924
3151
|
t.set(n, 6, r, !0), t.set(6, n, r, !0);
|
|
2925
3152
|
}
|
|
2926
3153
|
}
|
|
2927
|
-
function
|
|
2928
|
-
const n =
|
|
3154
|
+
function Jn(t, e) {
|
|
3155
|
+
const n = Hn.getPositions(e);
|
|
2929
3156
|
for (let r = 0; r < n.length; r++) {
|
|
2930
3157
|
const i = n[r][0], o = n[r][1];
|
|
2931
3158
|
for (let s = -2; s <= 2; s++)
|
|
@@ -2933,20 +3160,20 @@ function Gn(t, e) {
|
|
|
2933
3160
|
s === -2 || s === 2 || l === -2 || l === 2 || s === 0 && l === 0 ? t.set(i + s, o + l, !0, !0) : t.set(i + s, o + l, !1, !0);
|
|
2934
3161
|
}
|
|
2935
3162
|
}
|
|
2936
|
-
function
|
|
3163
|
+
function Wn(t, e) {
|
|
2937
3164
|
const n = t.size, r = xe.getEncodedBits(e);
|
|
2938
3165
|
let i, o, s;
|
|
2939
3166
|
for (let l = 0; l < 18; l++)
|
|
2940
3167
|
i = Math.floor(l / 3), o = l % 3 + n - 8 - 3, s = (r >> l & 1) === 1, t.set(i, o, s, !0), t.set(o, i, s, !0);
|
|
2941
3168
|
}
|
|
2942
3169
|
function Re(t, e, n) {
|
|
2943
|
-
const r = t.size, i =
|
|
3170
|
+
const r = t.size, i = Kn.getEncodedBits(e, n);
|
|
2944
3171
|
let o, s;
|
|
2945
3172
|
for (o = 0; o < 15; o++)
|
|
2946
3173
|
s = (i >> o & 1) === 1, o < 6 ? t.set(o, 8, s, !0) : o < 8 ? t.set(o + 1, 8, s, !0) : t.set(r - 15 + o, 8, s, !0), o < 8 ? t.set(8, r - o - 1, s, !0) : o < 9 ? t.set(8, 15 - o - 1 + 1, s, !0) : t.set(8, 15 - o - 1, s, !0);
|
|
2947
3174
|
t.set(r - 8, 8, 1, !0);
|
|
2948
3175
|
}
|
|
2949
|
-
function
|
|
3176
|
+
function Xn(t, e) {
|
|
2950
3177
|
const n = t.size;
|
|
2951
3178
|
let r = -1, i = n - 1, o = 7, s = 0;
|
|
2952
3179
|
for (let l = n - 1; l > 0; l -= 2)
|
|
@@ -2962,21 +3189,21 @@ function Wn(t, e) {
|
|
|
2962
3189
|
}
|
|
2963
3190
|
}
|
|
2964
3191
|
}
|
|
2965
|
-
function
|
|
2966
|
-
const r = new
|
|
3192
|
+
function er(t, e, n) {
|
|
3193
|
+
const r = new qn();
|
|
2967
3194
|
n.forEach(function(a) {
|
|
2968
|
-
r.put(a.mode.bit, 4), r.put(a.getLength(),
|
|
3195
|
+
r.put(a.mode.bit, 4), r.put(a.getLength(), Qn.getCharCountIndicator(a.mode, t)), a.write(r);
|
|
2969
3196
|
});
|
|
2970
|
-
const i = Ae.getSymbolTotalCodewords(t), o =
|
|
3197
|
+
const i = Ae.getSymbolTotalCodewords(t), o = Oe.getTotalCodewordsCount(t, e), s = (i - o) * 8;
|
|
2971
3198
|
for (r.getLengthInBits() + 4 <= s && r.put(0, 4); r.getLengthInBits() % 8 !== 0; )
|
|
2972
3199
|
r.putBit(0);
|
|
2973
3200
|
const l = (s - r.getLengthInBits()) / 8;
|
|
2974
3201
|
for (let a = 0; a < l; a++)
|
|
2975
3202
|
r.put(a % 2 ? 17 : 236, 8);
|
|
2976
|
-
return
|
|
3203
|
+
return tr(r, t, e);
|
|
2977
3204
|
}
|
|
2978
|
-
function
|
|
2979
|
-
const r = Ae.getSymbolTotalCodewords(e), i =
|
|
3205
|
+
function tr(t, e, n) {
|
|
3206
|
+
const r = Ae.getSymbolTotalCodewords(e), i = Oe.getTotalCodewordsCount(e, n), o = r - i, s = Oe.getBlocksCount(e, n), l = r % s, a = s - l, d = Math.floor(r / s), c = Math.floor(o / s), h = c + 1, f = d - c, u = new Yn(f);
|
|
2980
3207
|
let m = 0;
|
|
2981
3208
|
const g = new Array(s), k = new Array(s);
|
|
2982
3209
|
let b = 0;
|
|
@@ -2995,7 +3222,7 @@ function er(t, e, n) {
|
|
|
2995
3222
|
y[p++] = k[E][C];
|
|
2996
3223
|
return y;
|
|
2997
3224
|
}
|
|
2998
|
-
function
|
|
3225
|
+
function nr(t, e, n, r) {
|
|
2999
3226
|
let i;
|
|
3000
3227
|
if (Array.isArray(t))
|
|
3001
3228
|
i = Ne.fromArray(t);
|
|
@@ -3020,8 +3247,8 @@ The chosen QR Code version cannot contain this amount of data.
|
|
|
3020
3247
|
Minimum version required to store current data is: ` + o + `.
|
|
3021
3248
|
`
|
|
3022
3249
|
);
|
|
3023
|
-
const s =
|
|
3024
|
-
return
|
|
3250
|
+
const s = er(e, n, i), l = Ae.getSymbolSize(e), a = new Vn(l);
|
|
3251
|
+
return Zn(a, e), Gn(a), Jn(a, e), Re(a, n, 0), e >= 7 && Wn(a, e), Xn(a, s), isNaN(r) && (r = Ue.getBestMask(
|
|
3025
3252
|
a,
|
|
3026
3253
|
Re.bind(null, a, n)
|
|
3027
3254
|
)), Ue.applyMask(r, a), Re(a, n, r), {
|
|
@@ -3036,7 +3263,7 @@ vt.create = function(e, n) {
|
|
|
3036
3263
|
if (typeof e > "u" || e === "")
|
|
3037
3264
|
throw new Error("No input text");
|
|
3038
3265
|
let r = Te.M, i, o;
|
|
3039
|
-
return typeof n < "u" && (r = Te.from(n.errorCorrectionLevel, Te.M), i = xe.from(n.version), o = Ue.from(n.maskPattern), n.toSJISFunc && Ae.setToSJISFunction(n.toSJISFunc)),
|
|
3266
|
+
return typeof n < "u" && (r = Te.from(n.errorCorrectionLevel, Te.M), i = xe.from(n.version), o = Ue.from(n.maskPattern), n.toSJISFunc && Ae.setToSJISFunction(n.toSJISFunc)), nr(e, i, r, o);
|
|
3040
3267
|
};
|
|
3041
3268
|
var Tt = {}, Ze = {};
|
|
3042
3269
|
(function(t) {
|
|
@@ -3115,7 +3342,7 @@ var Tt = {}, Ze = {};
|
|
|
3115
3342
|
};
|
|
3116
3343
|
})(Tt);
|
|
3117
3344
|
var Nt = {};
|
|
3118
|
-
const
|
|
3345
|
+
const rr = Ze;
|
|
3119
3346
|
function ct(t, e) {
|
|
3120
3347
|
const n = t.a / 255, r = e + '="' + t.hex + '"';
|
|
3121
3348
|
return n < 1 ? r + " " + e + '-opacity="' + n.toFixed(2).slice(1) + '"' : r;
|
|
@@ -3124,7 +3351,7 @@ function Be(t, e, n) {
|
|
|
3124
3351
|
let r = t + e;
|
|
3125
3352
|
return typeof n < "u" && (r += " " + n), r;
|
|
3126
3353
|
}
|
|
3127
|
-
function
|
|
3354
|
+
function ir(t, e, n) {
|
|
3128
3355
|
let r = "", i = 0, o = !1, s = 0;
|
|
3129
3356
|
for (let l = 0; l < t.length; l++) {
|
|
3130
3357
|
const a = Math.floor(l % e), d = Math.floor(l / e);
|
|
@@ -3133,14 +3360,14 @@ function rr(t, e, n) {
|
|
|
3133
3360
|
return r;
|
|
3134
3361
|
}
|
|
3135
3362
|
Nt.render = function(e, n, r) {
|
|
3136
|
-
const i =
|
|
3363
|
+
const i = rr.getOptions(n), o = e.modules.size, s = e.modules.data, l = o + i.margin * 2, a = i.color.light.a ? "<path " + ct(i.color.light, "fill") + ' d="M0 0h' + l + "v" + l + 'H0z"/>' : "", d = "<path " + ct(i.color.dark, "stroke") + ' d="' + ir(s, o, i.margin) + '"/>', c = 'viewBox="0 0 ' + l + " " + l + '"', f = '<svg xmlns="http://www.w3.org/2000/svg" ' + (i.width ? 'width="' + i.width + '" height="' + i.width + '" ' : "") + c + ' shape-rendering="crispEdges">' + a + d + `</svg>
|
|
3137
3364
|
`;
|
|
3138
3365
|
return typeof r == "function" && r(null, f), f;
|
|
3139
3366
|
};
|
|
3140
|
-
const
|
|
3367
|
+
const or = vn, ze = vt, Rt = Tt, sr = Nt;
|
|
3141
3368
|
function Ge(t, e, n, r, i) {
|
|
3142
3369
|
const o = [].slice.call(arguments, 1), s = o.length, l = typeof o[s - 1] == "function";
|
|
3143
|
-
if (!l && !
|
|
3370
|
+
if (!l && !or())
|
|
3144
3371
|
throw new Error("Callback required as last argument");
|
|
3145
3372
|
if (l) {
|
|
3146
3373
|
if (s < 2)
|
|
@@ -3151,7 +3378,7 @@ function Ge(t, e, n, r, i) {
|
|
|
3151
3378
|
throw new Error("Too few arguments provided");
|
|
3152
3379
|
return s === 1 ? (n = e, e = r = void 0) : s === 2 && !e.getContext && (r = n, n = e, e = void 0), new Promise(function(a, d) {
|
|
3153
3380
|
try {
|
|
3154
|
-
const c =
|
|
3381
|
+
const c = ze.create(n, r);
|
|
3155
3382
|
a(t(c, e, r));
|
|
3156
3383
|
} catch (c) {
|
|
3157
3384
|
d(c);
|
|
@@ -3159,22 +3386,22 @@ function Ge(t, e, n, r, i) {
|
|
|
3159
3386
|
});
|
|
3160
3387
|
}
|
|
3161
3388
|
try {
|
|
3162
|
-
const a =
|
|
3389
|
+
const a = ze.create(n, r);
|
|
3163
3390
|
i(null, t(a, e, r));
|
|
3164
3391
|
} catch (a) {
|
|
3165
3392
|
i(a);
|
|
3166
3393
|
}
|
|
3167
3394
|
}
|
|
3168
|
-
fe.create =
|
|
3395
|
+
fe.create = ze.create;
|
|
3169
3396
|
fe.toCanvas = Ge.bind(null, Rt.render);
|
|
3170
3397
|
fe.toDataURL = Ge.bind(null, Rt.renderToDataURL);
|
|
3171
3398
|
fe.toString = Ge.bind(null, function(t, e, n) {
|
|
3172
|
-
return
|
|
3399
|
+
return sr.render(t, n);
|
|
3173
3400
|
});
|
|
3174
|
-
var
|
|
3175
|
-
for (var i = r > 1 ? void 0 : r ?
|
|
3401
|
+
var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, S = (t, e, n, r) => {
|
|
3402
|
+
for (var i = r > 1 ? void 0 : r ? lr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
|
|
3176
3403
|
(s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
|
|
3177
|
-
return r && i &&
|
|
3404
|
+
return r && i && ar(e, n, i), i;
|
|
3178
3405
|
};
|
|
3179
3406
|
let v = class extends se {
|
|
3180
3407
|
constructor() {
|
|
@@ -3249,7 +3476,31 @@ let v = class extends se {
|
|
|
3249
3476
|
}
|
|
3250
3477
|
initializeSDK() {
|
|
3251
3478
|
var t;
|
|
3252
|
-
!this.config || !this.adapters || !this.amount || !this.currency || !this.orderId
|
|
3479
|
+
if (!this.config || !this.adapters || !this.amount || !this.currency || !this.orderId) {
|
|
3480
|
+
console.error(
|
|
3481
|
+
"OnePayment: Missing required props. Ensure config, adapters, amount, currency, and orderId are provided."
|
|
3482
|
+
);
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
3485
|
+
if (!this.firstName || typeof this.firstName != "string" || this.firstName.trim() === "") {
|
|
3486
|
+
console.error(
|
|
3487
|
+
"OnePayment: firstName is required and must be a non-empty string. Customer information is required for all payment methods."
|
|
3488
|
+
);
|
|
3489
|
+
return;
|
|
3490
|
+
}
|
|
3491
|
+
if (!this.lastName || typeof this.lastName != "string" || this.lastName.trim() === "") {
|
|
3492
|
+
console.error(
|
|
3493
|
+
"OnePayment: lastName is required and must be a non-empty string. Customer information is required for all payment methods."
|
|
3494
|
+
);
|
|
3495
|
+
return;
|
|
3496
|
+
}
|
|
3497
|
+
if (!this.email || typeof this.email != "string" || this.email.trim() === "") {
|
|
3498
|
+
console.error(
|
|
3499
|
+
"OnePayment: email is required and must be a non-empty string. Customer information is required for all payment methods."
|
|
3500
|
+
);
|
|
3501
|
+
return;
|
|
3502
|
+
}
|
|
3503
|
+
this.isInitialized || (this.isInitialized = !0, (t = this.sdk) == null || t.destroy(), this.sdk = new cn(this.config, this.adapters), this.sdk.subscribe((e) => {
|
|
3253
3504
|
this.currentState = e, this.dispatchEvent(
|
|
3254
3505
|
new CustomEvent("state-change", {
|
|
3255
3506
|
detail: { state: e },
|