@one-payments/web-components 1.5.4 → 1.5.6
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 +1674 -1400
- package/dist/one-payment.browser.iife.js +565 -204
- package/dist/one-payment.browser.iife.js.map +1 -1
- package/dist/one-payment.d.ts +30 -0
- package/dist/one-payment.d.ts.map +1 -1
- package/dist/one-payment.js +314 -9
- package/dist/one-payment.js.map +1 -1
- package/package.json +2 -2
package/dist/one-payment.d.ts
CHANGED
|
@@ -249,6 +249,26 @@ export declare class OnePayment extends LitElement {
|
|
|
249
249
|
* @public
|
|
250
250
|
*/
|
|
251
251
|
email: string;
|
|
252
|
+
/**
|
|
253
|
+
* Customer's phone number (REQUIRED)
|
|
254
|
+
*
|
|
255
|
+
* The payer's phone number. This field is required for all payment methods
|
|
256
|
+
* and is used for:
|
|
257
|
+
* - Payment verification
|
|
258
|
+
* - Transaction notifications via SMS
|
|
259
|
+
* - Customer communication
|
|
260
|
+
* - Fraud prevention
|
|
261
|
+
*
|
|
262
|
+
* **Validation:**
|
|
263
|
+
* - Cannot be empty or whitespace-only
|
|
264
|
+
* - Must be provided before payment submission
|
|
265
|
+
* - Should include country code (e.g., '+65' for Singapore, '+60' for Malaysia)
|
|
266
|
+
*
|
|
267
|
+
* @required
|
|
268
|
+
* @type {string}
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
phoneNumber: string;
|
|
252
272
|
/**
|
|
253
273
|
* Optional array of payment method IDs to exclude from display
|
|
254
274
|
*
|
|
@@ -462,6 +482,13 @@ export declare class OnePayment extends LitElement {
|
|
|
462
482
|
private handleGoPayPayment;
|
|
463
483
|
private handleBoostPayment;
|
|
464
484
|
private handleShopeePayPayment;
|
|
485
|
+
private handleAtomPayment;
|
|
486
|
+
private handleDanaPayment;
|
|
487
|
+
private handleTngPayment;
|
|
488
|
+
/**
|
|
489
|
+
* Get the formatted pay amount for buttons (net amount including fees)
|
|
490
|
+
*/
|
|
491
|
+
private getPayButtonAmount;
|
|
465
492
|
private getTransactionData;
|
|
466
493
|
private renderTransactionDetailsSkeleton;
|
|
467
494
|
private renderPaymentMethodsSkeleton;
|
|
@@ -474,6 +501,9 @@ export declare class OnePayment extends LitElement {
|
|
|
474
501
|
private renderGoPayContent;
|
|
475
502
|
private renderBoostContent;
|
|
476
503
|
private renderShopeePayContent;
|
|
504
|
+
private renderAtomContent;
|
|
505
|
+
private renderDanaContent;
|
|
506
|
+
private renderTngContent;
|
|
477
507
|
private render3DSModal;
|
|
478
508
|
private renderStatusBlock;
|
|
479
509
|
render(): import("lit").TemplateResult<1>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-payment.d.ts","sourceRoot":"","sources":["../src/one-payment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,KAAK,EACL,eAAe,EAGf,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAM5B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,EAAE,WAAW,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,eAAe,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,cAAc,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CAC/C;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBACa,UAAW,SAAQ,UAAU;IAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACyB,MAAM,EAAG,SAAS,CAAC;IAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACyB,QAAQ,EAAG,QAAQ,CAAC;IAEhD;;;;;;;;;;;;;;;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gBAAgB;IAoBxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,kBAAkB;IAwE1B,OAAO,CAAC,gCAAgC;IAyBxC,OAAO,CAAC,4BAA4B;IAiBpC,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,wBAAwB;IAsEhC,OAAO,CAAC,cAAc;IAkHtB,OAAO,CAAC,mBAAmB;IA8D3B,OAAO,CAAC,sBAAsB;IA4C9B,OAAO,CAAC,oBAAoB;IA4C5B,OAAO,CAAC,kBAAkB;IA4C1B,OAAO,CAAC,kBAAkB;IA4C1B,OAAO,CAAC,sBAAsB;IA4C9B,OAAO,CAAC,iBAAiB;IA4CzB,OAAO,CAAC,iBAAiB;IA4CzB,OAAO,CAAC,gBAAgB;IA4CxB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,iBAAiB;IAwChB,MAAM;CA0NhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
package/dist/one-payment.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { __decorate } from "tslib";
|
|
6
6
|
import { LitElement, html, css } from 'lit';
|
|
7
7
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
8
|
-
import { PaymentSDK, PAYMENT_METHODS, PAYNOW_ICON_DATA_URL, PROMPTPAY_ICON_DATA_URL, DUITNOW_ICON_DATA_URL, GOPAY_ICON_DATA_URL, BOOST_ICON_DATA_URL, SHOPEEPAY_ICON_DATA_URL } from '@one-payments/core';
|
|
8
|
+
import { PaymentSDK, PAYMENT_METHODS, PAYNOW_ICON_DATA_URL, PROMPTPAY_ICON_DATA_URL, DUITNOW_ICON_DATA_URL, GOPAY_ICON_DATA_URL, BOOST_ICON_DATA_URL, SHOPEEPAY_ICON_DATA_URL, ATOM_ICON_DATA_URL, DANA_ICON_DATA_URL, TNG_ICON_DATA_URL } from '@one-payments/core';
|
|
9
9
|
import CleaveConstructor from 'cleave.js';
|
|
10
10
|
import QRCode from 'qrcode';
|
|
11
11
|
/**
|
|
@@ -145,6 +145,9 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
145
145
|
if (!this.email || typeof this.email !== 'string' || this.email.trim() === '') {
|
|
146
146
|
return false;
|
|
147
147
|
}
|
|
148
|
+
if (!this.phoneNumber || typeof this.phoneNumber !== 'string' || this.phoneNumber.trim() === '') {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
148
151
|
return true;
|
|
149
152
|
}
|
|
150
153
|
/**
|
|
@@ -422,6 +425,42 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
422
425
|
};
|
|
423
426
|
}
|
|
424
427
|
}
|
|
428
|
+
// Check currency validation for Atom (SGD or MYR only)
|
|
429
|
+
if (method.id === PAYMENT_METHODS.ATOM) {
|
|
430
|
+
const transactionData = this.getTransactionData();
|
|
431
|
+
const currency = transactionData.currency;
|
|
432
|
+
if (currency !== 'SGD' && currency !== 'MYR') {
|
|
433
|
+
return {
|
|
434
|
+
id: method.id,
|
|
435
|
+
enabled: false,
|
|
436
|
+
disabledReason: 'Atom is only available for SGD and MYR currencies',
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
// Check currency validation for Dana (IDR only)
|
|
441
|
+
if (method.id === PAYMENT_METHODS.DANA) {
|
|
442
|
+
const transactionData = this.getTransactionData();
|
|
443
|
+
const currency = transactionData.currency;
|
|
444
|
+
if (currency !== 'IDR') {
|
|
445
|
+
return {
|
|
446
|
+
id: method.id,
|
|
447
|
+
enabled: false,
|
|
448
|
+
disabledReason: 'Dana is only available for IDR currency',
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// Check currency validation for Touch 'n Go (MYR only)
|
|
453
|
+
if (method.id === PAYMENT_METHODS.TNG) {
|
|
454
|
+
const transactionData = this.getTransactionData();
|
|
455
|
+
const currency = transactionData.currency;
|
|
456
|
+
if (currency !== 'MYR') {
|
|
457
|
+
return {
|
|
458
|
+
id: method.id,
|
|
459
|
+
enabled: false,
|
|
460
|
+
disabledReason: "Touch 'n Go is only available for MYR currency",
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}
|
|
425
464
|
return {
|
|
426
465
|
id: method.id,
|
|
427
466
|
enabled: true,
|
|
@@ -497,6 +536,19 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
497
536
|
this.paymentData = event.payload.paymentData;
|
|
498
537
|
// Hide skeleton loading, show actual UI
|
|
499
538
|
this.isInitializing = false;
|
|
539
|
+
// Inject Airwallex fraud prevention script on first mount
|
|
540
|
+
// This only runs once during initialization, not during polling
|
|
541
|
+
if (event.payload.paymentData?.sessionId) {
|
|
542
|
+
const existingScript = document.getElementById('airwallex-fraud-api');
|
|
543
|
+
if (!existingScript) {
|
|
544
|
+
const script = document.createElement('script');
|
|
545
|
+
script.src = 'https://static.airwallex.com/webapp/fraud/device-fingerprint/index.js';
|
|
546
|
+
script.async = true;
|
|
547
|
+
script.setAttribute('data-order-session-id', event.payload.paymentData.sessionId);
|
|
548
|
+
script.setAttribute('id', 'airwallex-fraud-api');
|
|
549
|
+
document.body.appendChild(script);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
500
552
|
});
|
|
501
553
|
// Handle 3DS authentication requirement
|
|
502
554
|
this.sdk.on('payment_requires_action', (event) => {
|
|
@@ -604,6 +656,34 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
604
656
|
window.location.href = redirectUrl;
|
|
605
657
|
}
|
|
606
658
|
});
|
|
659
|
+
// Handle Atom redirect
|
|
660
|
+
this.sdk.on('atom_redirect', (event) => {
|
|
661
|
+
const { redirectUrl } = event.payload;
|
|
662
|
+
if (redirectUrl) {
|
|
663
|
+
// Redirect the entire page to the external payment page
|
|
664
|
+
window.location.href = redirectUrl;
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
// Handle Dana redirect
|
|
668
|
+
this.sdk.on('dana_redirect', (event) => {
|
|
669
|
+
console.log('[WebComponent] dana_redirect event received:', event.payload);
|
|
670
|
+
const { redirectUrl } = event.payload;
|
|
671
|
+
if (redirectUrl) {
|
|
672
|
+
console.log('[WebComponent] Redirecting to Dana URL:', redirectUrl);
|
|
673
|
+
// Redirect the entire page to the external payment page
|
|
674
|
+
window.location.href = redirectUrl;
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
// Handle Touch 'n Go redirect
|
|
678
|
+
this.sdk.on('tng_redirect', (event) => {
|
|
679
|
+
console.log('[WebComponent] tng_redirect event received:', event.payload);
|
|
680
|
+
const { redirectUrl } = event.payload;
|
|
681
|
+
if (redirectUrl) {
|
|
682
|
+
console.log('[WebComponent] Redirecting to TnG URL:', redirectUrl);
|
|
683
|
+
// Redirect the entire page to the external payment page
|
|
684
|
+
window.location.href = redirectUrl;
|
|
685
|
+
}
|
|
686
|
+
});
|
|
607
687
|
this.sdk.initialize({
|
|
608
688
|
amount: this.amount,
|
|
609
689
|
currency: this.currency,
|
|
@@ -806,6 +886,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
806
886
|
firstName: this.firstName,
|
|
807
887
|
lastName: this.lastName,
|
|
808
888
|
email: this.email,
|
|
889
|
+
phoneNumber: this.phoneNumber,
|
|
809
890
|
});
|
|
810
891
|
}
|
|
811
892
|
handlePayNowPayment() {
|
|
@@ -819,6 +900,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
819
900
|
firstName: this.firstName,
|
|
820
901
|
lastName: this.lastName,
|
|
821
902
|
email: this.email,
|
|
903
|
+
phoneNumber: this.phoneNumber,
|
|
822
904
|
});
|
|
823
905
|
// showQRCode will be set by the event listener when qrCode is received
|
|
824
906
|
}
|
|
@@ -834,6 +916,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
834
916
|
firstName: this.firstName,
|
|
835
917
|
lastName: this.lastName,
|
|
836
918
|
email: this.email,
|
|
919
|
+
phoneNumber: this.phoneNumber,
|
|
837
920
|
});
|
|
838
921
|
}
|
|
839
922
|
handleDuitNowPayment() {
|
|
@@ -848,6 +931,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
848
931
|
firstName: this.firstName,
|
|
849
932
|
lastName: this.lastName,
|
|
850
933
|
email: this.email,
|
|
934
|
+
phoneNumber: this.phoneNumber,
|
|
851
935
|
});
|
|
852
936
|
}
|
|
853
937
|
handleGoPayPayment() {
|
|
@@ -862,6 +946,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
862
946
|
firstName: this.firstName,
|
|
863
947
|
lastName: this.lastName,
|
|
864
948
|
email: this.email,
|
|
949
|
+
phoneNumber: this.phoneNumber,
|
|
865
950
|
});
|
|
866
951
|
}
|
|
867
952
|
handleBoostPayment() {
|
|
@@ -876,6 +961,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
876
961
|
firstName: this.firstName,
|
|
877
962
|
lastName: this.lastName,
|
|
878
963
|
email: this.email,
|
|
964
|
+
phoneNumber: this.phoneNumber,
|
|
879
965
|
});
|
|
880
966
|
}
|
|
881
967
|
handleShopeePayPayment() {
|
|
@@ -890,9 +976,62 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
890
976
|
firstName: this.firstName,
|
|
891
977
|
lastName: this.lastName,
|
|
892
978
|
email: this.email,
|
|
979
|
+
phoneNumber: this.phoneNumber,
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
handleAtomPayment() {
|
|
983
|
+
if (!this.sdk || this.currentState.status !== 'ready') {
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
// Lock payment methods to prevent switching
|
|
987
|
+
this.paymentLocked = true;
|
|
988
|
+
// Use customer info from props
|
|
989
|
+
// SDK will redirect to external payment page when nextActionUrl is received
|
|
990
|
+
this.sdk.submitPayment(PAYMENT_METHODS.ATOM, {
|
|
991
|
+
firstName: this.firstName,
|
|
992
|
+
lastName: this.lastName,
|
|
993
|
+
email: this.email,
|
|
994
|
+
phoneNumber: this.phoneNumber,
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
handleDanaPayment() {
|
|
998
|
+
if (!this.sdk || this.currentState.status !== 'ready') {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
// Lock payment methods to prevent switching
|
|
1002
|
+
this.paymentLocked = true;
|
|
1003
|
+
// Use customer info from props
|
|
1004
|
+
// SDK will redirect to external payment page when nextActionUrl is received
|
|
1005
|
+
this.sdk.submitPayment(PAYMENT_METHODS.DANA, {
|
|
1006
|
+
firstName: this.firstName,
|
|
1007
|
+
lastName: this.lastName,
|
|
1008
|
+
email: this.email,
|
|
1009
|
+
phoneNumber: this.phoneNumber,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
handleTngPayment() {
|
|
1013
|
+
if (!this.sdk || this.currentState.status !== 'ready') {
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
// Lock payment methods to prevent switching
|
|
1017
|
+
this.paymentLocked = true;
|
|
1018
|
+
// Use customer info from props
|
|
1019
|
+
// SDK will redirect to external payment page when nextActionUrl is received
|
|
1020
|
+
this.sdk.submitPayment(PAYMENT_METHODS.TNG, {
|
|
1021
|
+
firstName: this.firstName,
|
|
1022
|
+
lastName: this.lastName,
|
|
1023
|
+
email: this.email,
|
|
1024
|
+
phoneNumber: this.phoneNumber,
|
|
893
1025
|
});
|
|
894
1026
|
}
|
|
895
1027
|
// --- Render Methods ---
|
|
1028
|
+
/**
|
|
1029
|
+
* Get the formatted pay amount for buttons (net amount including fees)
|
|
1030
|
+
*/
|
|
1031
|
+
getPayButtonAmount() {
|
|
1032
|
+
const transactionData = this.getTransactionData();
|
|
1033
|
+
return `${this.currency} ${transactionData.netAmount.toFixed(2)}`;
|
|
1034
|
+
}
|
|
896
1035
|
getTransactionData() {
|
|
897
1036
|
const data = this.paymentData;
|
|
898
1037
|
// Return fallback data if payment data is not loaded yet
|
|
@@ -1178,7 +1317,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1178
1317
|
${this.currentState.status === 'processing' ||
|
|
1179
1318
|
this.currentState.status === 'requires_action'
|
|
1180
1319
|
? 'Processing...'
|
|
1181
|
-
: `Pay ${this.
|
|
1320
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1182
1321
|
</button>
|
|
1183
1322
|
</div>
|
|
1184
1323
|
</div>
|
|
@@ -1237,7 +1376,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1237
1376
|
${this.currentState.status === 'processing' ||
|
|
1238
1377
|
this.currentState.status === 'requires_action'
|
|
1239
1378
|
? 'Processing...'
|
|
1240
|
-
: `Pay ${this.
|
|
1379
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1241
1380
|
</button>
|
|
1242
1381
|
</div>
|
|
1243
1382
|
</div>
|
|
@@ -1280,7 +1419,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1280
1419
|
${this.currentState.status === 'processing' ||
|
|
1281
1420
|
this.currentState.status === 'requires_action'
|
|
1282
1421
|
? 'Redirecting...'
|
|
1283
|
-
: `Pay ${this.
|
|
1422
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1284
1423
|
</button>
|
|
1285
1424
|
</div>
|
|
1286
1425
|
</div>
|
|
@@ -1323,7 +1462,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1323
1462
|
${this.currentState.status === 'processing' ||
|
|
1324
1463
|
this.currentState.status === 'requires_action'
|
|
1325
1464
|
? 'Redirecting...'
|
|
1326
|
-
: `Pay ${this.
|
|
1465
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1327
1466
|
</button>
|
|
1328
1467
|
</div>
|
|
1329
1468
|
</div>
|
|
@@ -1366,7 +1505,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1366
1505
|
${this.currentState.status === 'processing' ||
|
|
1367
1506
|
this.currentState.status === 'requires_action'
|
|
1368
1507
|
? 'Redirecting...'
|
|
1369
|
-
: `Pay ${this.
|
|
1508
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1370
1509
|
</button>
|
|
1371
1510
|
</div>
|
|
1372
1511
|
</div>
|
|
@@ -1409,7 +1548,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1409
1548
|
${this.currentState.status === 'processing' ||
|
|
1410
1549
|
this.currentState.status === 'requires_action'
|
|
1411
1550
|
? 'Redirecting...'
|
|
1412
|
-
: `Pay ${this.
|
|
1551
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1413
1552
|
</button>
|
|
1414
1553
|
</div>
|
|
1415
1554
|
</div>
|
|
@@ -1452,7 +1591,136 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1452
1591
|
${this.currentState.status === 'processing' ||
|
|
1453
1592
|
this.currentState.status === 'requires_action'
|
|
1454
1593
|
? 'Redirecting...'
|
|
1455
|
-
: `Pay ${this.
|
|
1594
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1595
|
+
</button>
|
|
1596
|
+
</div>
|
|
1597
|
+
</div>
|
|
1598
|
+
</div>
|
|
1599
|
+
`;
|
|
1600
|
+
}
|
|
1601
|
+
renderAtomContent() {
|
|
1602
|
+
return html `
|
|
1603
|
+
<div class="paynow-container">
|
|
1604
|
+
<div class="paynow-instructions">
|
|
1605
|
+
<h3 class="instructions-title">How to Pay with Atome:</h3>
|
|
1606
|
+
|
|
1607
|
+
<div class="instruction-steps">
|
|
1608
|
+
<div class="instruction-step">
|
|
1609
|
+
<div class="step-number">1</div>
|
|
1610
|
+
<p class="step-text">Click <strong>"Pay"</strong> to go to the payment page.</p>
|
|
1611
|
+
</div>
|
|
1612
|
+
|
|
1613
|
+
<div class="instruction-step">
|
|
1614
|
+
<div class="step-number">2</div>
|
|
1615
|
+
<p class="step-text">Complete the payment on the external page.</p>
|
|
1616
|
+
</div>
|
|
1617
|
+
|
|
1618
|
+
<div class="instruction-step">
|
|
1619
|
+
<div class="step-number">3</div>
|
|
1620
|
+
<p class="step-text">You'll be redirected back automatically.</p>
|
|
1621
|
+
</div>
|
|
1622
|
+
</div>
|
|
1623
|
+
|
|
1624
|
+
<div class="submit-section">
|
|
1625
|
+
<button
|
|
1626
|
+
class="pay-button ${this.currentState.status === 'processing' ||
|
|
1627
|
+
this.currentState.status === 'requires_action'
|
|
1628
|
+
? 'loading'
|
|
1629
|
+
: ''}"
|
|
1630
|
+
@click=${this.handleAtomPayment}
|
|
1631
|
+
?disabled=${this.currentState.status === 'processing' ||
|
|
1632
|
+
this.currentState.status === 'requires_action'}
|
|
1633
|
+
>
|
|
1634
|
+
${this.currentState.status === 'processing' ||
|
|
1635
|
+
this.currentState.status === 'requires_action'
|
|
1636
|
+
? 'Redirecting...'
|
|
1637
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1638
|
+
</button>
|
|
1639
|
+
</div>
|
|
1640
|
+
</div>
|
|
1641
|
+
</div>
|
|
1642
|
+
`;
|
|
1643
|
+
}
|
|
1644
|
+
renderDanaContent() {
|
|
1645
|
+
return html `
|
|
1646
|
+
<div class="paynow-container">
|
|
1647
|
+
<div class="paynow-instructions">
|
|
1648
|
+
<h3 class="instructions-title">How to Pay with Dana:</h3>
|
|
1649
|
+
|
|
1650
|
+
<div class="instruction-steps">
|
|
1651
|
+
<div class="instruction-step">
|
|
1652
|
+
<div class="step-number">1</div>
|
|
1653
|
+
<p class="step-text">Click <strong>"Pay"</strong> to go to the payment page.</p>
|
|
1654
|
+
</div>
|
|
1655
|
+
|
|
1656
|
+
<div class="instruction-step">
|
|
1657
|
+
<div class="step-number">2</div>
|
|
1658
|
+
<p class="step-text">Complete the payment in the Dana app.</p>
|
|
1659
|
+
</div>
|
|
1660
|
+
|
|
1661
|
+
<div class="instruction-step">
|
|
1662
|
+
<div class="step-number">3</div>
|
|
1663
|
+
<p class="step-text">You'll be redirected back automatically.</p>
|
|
1664
|
+
</div>
|
|
1665
|
+
</div>
|
|
1666
|
+
|
|
1667
|
+
<div class="submit-section">
|
|
1668
|
+
<button
|
|
1669
|
+
class="pay-button ${this.currentState.status === 'processing' ||
|
|
1670
|
+
this.currentState.status === 'requires_action'
|
|
1671
|
+
? 'loading'
|
|
1672
|
+
: ''}"
|
|
1673
|
+
@click=${this.handleDanaPayment}
|
|
1674
|
+
?disabled=${this.currentState.status === 'processing' ||
|
|
1675
|
+
this.currentState.status === 'requires_action'}
|
|
1676
|
+
>
|
|
1677
|
+
${this.currentState.status === 'processing' ||
|
|
1678
|
+
this.currentState.status === 'requires_action'
|
|
1679
|
+
? 'Redirecting...'
|
|
1680
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1681
|
+
</button>
|
|
1682
|
+
</div>
|
|
1683
|
+
</div>
|
|
1684
|
+
</div>
|
|
1685
|
+
`;
|
|
1686
|
+
}
|
|
1687
|
+
renderTngContent() {
|
|
1688
|
+
return html `
|
|
1689
|
+
<div class="paynow-container">
|
|
1690
|
+
<div class="paynow-instructions">
|
|
1691
|
+
<h3 class="instructions-title">How to Pay with Touch 'n Go:</h3>
|
|
1692
|
+
|
|
1693
|
+
<div class="instruction-steps">
|
|
1694
|
+
<div class="instruction-step">
|
|
1695
|
+
<div class="step-number">1</div>
|
|
1696
|
+
<p class="step-text">Click <strong>"Pay"</strong> to go to the payment page.</p>
|
|
1697
|
+
</div>
|
|
1698
|
+
|
|
1699
|
+
<div class="instruction-step">
|
|
1700
|
+
<div class="step-number">2</div>
|
|
1701
|
+
<p class="step-text">Complete the payment in the Touch 'n Go eWallet app.</p>
|
|
1702
|
+
</div>
|
|
1703
|
+
|
|
1704
|
+
<div class="instruction-step">
|
|
1705
|
+
<div class="step-number">3</div>
|
|
1706
|
+
<p class="step-text">You'll be redirected back automatically.</p>
|
|
1707
|
+
</div>
|
|
1708
|
+
</div>
|
|
1709
|
+
|
|
1710
|
+
<div class="submit-section">
|
|
1711
|
+
<button
|
|
1712
|
+
class="pay-button ${this.currentState.status === 'processing' ||
|
|
1713
|
+
this.currentState.status === 'requires_action'
|
|
1714
|
+
? 'loading'
|
|
1715
|
+
: ''}"
|
|
1716
|
+
@click=${this.handleTngPayment}
|
|
1717
|
+
?disabled=${this.currentState.status === 'processing' ||
|
|
1718
|
+
this.currentState.status === 'requires_action'}
|
|
1719
|
+
>
|
|
1720
|
+
${this.currentState.status === 'processing' ||
|
|
1721
|
+
this.currentState.status === 'requires_action'
|
|
1722
|
+
? 'Redirecting...'
|
|
1723
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1456
1724
|
</button>
|
|
1457
1725
|
</div>
|
|
1458
1726
|
</div>
|
|
@@ -1550,6 +1818,12 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1550
1818
|
return 'Boost';
|
|
1551
1819
|
case PAYMENT_METHODS.SHOPEEPAY:
|
|
1552
1820
|
return 'ShopeePay';
|
|
1821
|
+
case PAYMENT_METHODS.ATOM:
|
|
1822
|
+
return 'Atome';
|
|
1823
|
+
case PAYMENT_METHODS.DANA:
|
|
1824
|
+
return 'Dana';
|
|
1825
|
+
case PAYMENT_METHODS.TNG:
|
|
1826
|
+
return "Touch 'n Go";
|
|
1553
1827
|
default:
|
|
1554
1828
|
return id;
|
|
1555
1829
|
}
|
|
@@ -1613,6 +1887,27 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1613
1887
|
<div class="method-icon-right">
|
|
1614
1888
|
<img src="${SHOPEEPAY_ICON_DATA_URL}" alt="ShopeePay" style="width: 45px; height: auto;" />
|
|
1615
1889
|
</div>
|
|
1890
|
+
`;
|
|
1891
|
+
}
|
|
1892
|
+
else if (id === PAYMENT_METHODS.ATOM) {
|
|
1893
|
+
return html `
|
|
1894
|
+
<div class="method-icon-right">
|
|
1895
|
+
<img src="${ATOM_ICON_DATA_URL}" alt="Atome" style="width: 45px; height: auto;" />
|
|
1896
|
+
</div>
|
|
1897
|
+
`;
|
|
1898
|
+
}
|
|
1899
|
+
else if (id === PAYMENT_METHODS.DANA) {
|
|
1900
|
+
return html `
|
|
1901
|
+
<div class="method-icon-right">
|
|
1902
|
+
<img src="${DANA_ICON_DATA_URL}" alt="Dana" style="width: 45px; height: auto;" />
|
|
1903
|
+
</div>
|
|
1904
|
+
`;
|
|
1905
|
+
}
|
|
1906
|
+
else if (id === PAYMENT_METHODS.TNG) {
|
|
1907
|
+
return html `
|
|
1908
|
+
<div class="method-icon-right">
|
|
1909
|
+
<img src="${TNG_ICON_DATA_URL}" alt="Touch 'n Go" style="width: 45px; height: auto;" />
|
|
1910
|
+
</div>
|
|
1616
1911
|
`;
|
|
1617
1912
|
}
|
|
1618
1913
|
return null;
|
|
@@ -1677,7 +1972,13 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1677
1972
|
? this.renderBoostContent()
|
|
1678
1973
|
: method.id === PAYMENT_METHODS.SHOPEEPAY
|
|
1679
1974
|
? this.renderShopeePayContent()
|
|
1680
|
-
:
|
|
1975
|
+
: method.id === PAYMENT_METHODS.ATOM
|
|
1976
|
+
? this.renderAtomContent()
|
|
1977
|
+
: method.id === PAYMENT_METHODS.DANA
|
|
1978
|
+
? this.renderDanaContent()
|
|
1979
|
+
: method.id === PAYMENT_METHODS.TNG
|
|
1980
|
+
? this.renderTngContent()
|
|
1981
|
+
: null}
|
|
1681
1982
|
</div>`
|
|
1682
1983
|
: ''}
|
|
1683
1984
|
</div>
|
|
@@ -1875,6 +2176,7 @@ OnePayment.styles = css `
|
|
|
1875
2176
|
justify-content: center;
|
|
1876
2177
|
flex-shrink: 0;
|
|
1877
2178
|
color: var(--op-color-text-secondary);
|
|
2179
|
+
margin-left: 0.5rem;
|
|
1878
2180
|
}
|
|
1879
2181
|
|
|
1880
2182
|
.method-icon-right svg {
|
|
@@ -3040,6 +3342,9 @@ __decorate([
|
|
|
3040
3342
|
__decorate([
|
|
3041
3343
|
property({ type: String })
|
|
3042
3344
|
], OnePayment.prototype, "email", void 0);
|
|
3345
|
+
__decorate([
|
|
3346
|
+
property({ type: String })
|
|
3347
|
+
], OnePayment.prototype, "phoneNumber", void 0);
|
|
3043
3348
|
__decorate([
|
|
3044
3349
|
property({ type: Array })
|
|
3045
3350
|
], OnePayment.prototype, "excludePaymentMethods", void 0);
|