@one-payments/web-components 1.5.4 → 1.5.5
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 +1670 -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 +301 -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,
|
|
@@ -604,6 +643,34 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
604
643
|
window.location.href = redirectUrl;
|
|
605
644
|
}
|
|
606
645
|
});
|
|
646
|
+
// Handle Atom redirect
|
|
647
|
+
this.sdk.on('atom_redirect', (event) => {
|
|
648
|
+
const { redirectUrl } = event.payload;
|
|
649
|
+
if (redirectUrl) {
|
|
650
|
+
// Redirect the entire page to the external payment page
|
|
651
|
+
window.location.href = redirectUrl;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
// Handle Dana redirect
|
|
655
|
+
this.sdk.on('dana_redirect', (event) => {
|
|
656
|
+
console.log('[WebComponent] dana_redirect event received:', event.payload);
|
|
657
|
+
const { redirectUrl } = event.payload;
|
|
658
|
+
if (redirectUrl) {
|
|
659
|
+
console.log('[WebComponent] Redirecting to Dana URL:', redirectUrl);
|
|
660
|
+
// Redirect the entire page to the external payment page
|
|
661
|
+
window.location.href = redirectUrl;
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
// Handle Touch 'n Go redirect
|
|
665
|
+
this.sdk.on('tng_redirect', (event) => {
|
|
666
|
+
console.log('[WebComponent] tng_redirect event received:', event.payload);
|
|
667
|
+
const { redirectUrl } = event.payload;
|
|
668
|
+
if (redirectUrl) {
|
|
669
|
+
console.log('[WebComponent] Redirecting to TnG URL:', redirectUrl);
|
|
670
|
+
// Redirect the entire page to the external payment page
|
|
671
|
+
window.location.href = redirectUrl;
|
|
672
|
+
}
|
|
673
|
+
});
|
|
607
674
|
this.sdk.initialize({
|
|
608
675
|
amount: this.amount,
|
|
609
676
|
currency: this.currency,
|
|
@@ -806,6 +873,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
806
873
|
firstName: this.firstName,
|
|
807
874
|
lastName: this.lastName,
|
|
808
875
|
email: this.email,
|
|
876
|
+
phoneNumber: this.phoneNumber,
|
|
809
877
|
});
|
|
810
878
|
}
|
|
811
879
|
handlePayNowPayment() {
|
|
@@ -819,6 +887,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
819
887
|
firstName: this.firstName,
|
|
820
888
|
lastName: this.lastName,
|
|
821
889
|
email: this.email,
|
|
890
|
+
phoneNumber: this.phoneNumber,
|
|
822
891
|
});
|
|
823
892
|
// showQRCode will be set by the event listener when qrCode is received
|
|
824
893
|
}
|
|
@@ -834,6 +903,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
834
903
|
firstName: this.firstName,
|
|
835
904
|
lastName: this.lastName,
|
|
836
905
|
email: this.email,
|
|
906
|
+
phoneNumber: this.phoneNumber,
|
|
837
907
|
});
|
|
838
908
|
}
|
|
839
909
|
handleDuitNowPayment() {
|
|
@@ -848,6 +918,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
848
918
|
firstName: this.firstName,
|
|
849
919
|
lastName: this.lastName,
|
|
850
920
|
email: this.email,
|
|
921
|
+
phoneNumber: this.phoneNumber,
|
|
851
922
|
});
|
|
852
923
|
}
|
|
853
924
|
handleGoPayPayment() {
|
|
@@ -862,6 +933,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
862
933
|
firstName: this.firstName,
|
|
863
934
|
lastName: this.lastName,
|
|
864
935
|
email: this.email,
|
|
936
|
+
phoneNumber: this.phoneNumber,
|
|
865
937
|
});
|
|
866
938
|
}
|
|
867
939
|
handleBoostPayment() {
|
|
@@ -876,6 +948,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
876
948
|
firstName: this.firstName,
|
|
877
949
|
lastName: this.lastName,
|
|
878
950
|
email: this.email,
|
|
951
|
+
phoneNumber: this.phoneNumber,
|
|
879
952
|
});
|
|
880
953
|
}
|
|
881
954
|
handleShopeePayPayment() {
|
|
@@ -890,9 +963,62 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
890
963
|
firstName: this.firstName,
|
|
891
964
|
lastName: this.lastName,
|
|
892
965
|
email: this.email,
|
|
966
|
+
phoneNumber: this.phoneNumber,
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
handleAtomPayment() {
|
|
970
|
+
if (!this.sdk || this.currentState.status !== 'ready') {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
// Lock payment methods to prevent switching
|
|
974
|
+
this.paymentLocked = true;
|
|
975
|
+
// Use customer info from props
|
|
976
|
+
// SDK will redirect to external payment page when nextActionUrl is received
|
|
977
|
+
this.sdk.submitPayment(PAYMENT_METHODS.ATOM, {
|
|
978
|
+
firstName: this.firstName,
|
|
979
|
+
lastName: this.lastName,
|
|
980
|
+
email: this.email,
|
|
981
|
+
phoneNumber: this.phoneNumber,
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
handleDanaPayment() {
|
|
985
|
+
if (!this.sdk || this.currentState.status !== 'ready') {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
// Lock payment methods to prevent switching
|
|
989
|
+
this.paymentLocked = true;
|
|
990
|
+
// Use customer info from props
|
|
991
|
+
// SDK will redirect to external payment page when nextActionUrl is received
|
|
992
|
+
this.sdk.submitPayment(PAYMENT_METHODS.DANA, {
|
|
993
|
+
firstName: this.firstName,
|
|
994
|
+
lastName: this.lastName,
|
|
995
|
+
email: this.email,
|
|
996
|
+
phoneNumber: this.phoneNumber,
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
handleTngPayment() {
|
|
1000
|
+
if (!this.sdk || this.currentState.status !== 'ready') {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
// Lock payment methods to prevent switching
|
|
1004
|
+
this.paymentLocked = true;
|
|
1005
|
+
// Use customer info from props
|
|
1006
|
+
// SDK will redirect to external payment page when nextActionUrl is received
|
|
1007
|
+
this.sdk.submitPayment(PAYMENT_METHODS.TNG, {
|
|
1008
|
+
firstName: this.firstName,
|
|
1009
|
+
lastName: this.lastName,
|
|
1010
|
+
email: this.email,
|
|
1011
|
+
phoneNumber: this.phoneNumber,
|
|
893
1012
|
});
|
|
894
1013
|
}
|
|
895
1014
|
// --- Render Methods ---
|
|
1015
|
+
/**
|
|
1016
|
+
* Get the formatted pay amount for buttons (net amount including fees)
|
|
1017
|
+
*/
|
|
1018
|
+
getPayButtonAmount() {
|
|
1019
|
+
const transactionData = this.getTransactionData();
|
|
1020
|
+
return `${this.currency} ${transactionData.netAmount.toFixed(2)}`;
|
|
1021
|
+
}
|
|
896
1022
|
getTransactionData() {
|
|
897
1023
|
const data = this.paymentData;
|
|
898
1024
|
// Return fallback data if payment data is not loaded yet
|
|
@@ -1178,7 +1304,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1178
1304
|
${this.currentState.status === 'processing' ||
|
|
1179
1305
|
this.currentState.status === 'requires_action'
|
|
1180
1306
|
? 'Processing...'
|
|
1181
|
-
: `Pay ${this.
|
|
1307
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1182
1308
|
</button>
|
|
1183
1309
|
</div>
|
|
1184
1310
|
</div>
|
|
@@ -1237,7 +1363,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1237
1363
|
${this.currentState.status === 'processing' ||
|
|
1238
1364
|
this.currentState.status === 'requires_action'
|
|
1239
1365
|
? 'Processing...'
|
|
1240
|
-
: `Pay ${this.
|
|
1366
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1241
1367
|
</button>
|
|
1242
1368
|
</div>
|
|
1243
1369
|
</div>
|
|
@@ -1280,7 +1406,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1280
1406
|
${this.currentState.status === 'processing' ||
|
|
1281
1407
|
this.currentState.status === 'requires_action'
|
|
1282
1408
|
? 'Redirecting...'
|
|
1283
|
-
: `Pay ${this.
|
|
1409
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1284
1410
|
</button>
|
|
1285
1411
|
</div>
|
|
1286
1412
|
</div>
|
|
@@ -1323,7 +1449,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1323
1449
|
${this.currentState.status === 'processing' ||
|
|
1324
1450
|
this.currentState.status === 'requires_action'
|
|
1325
1451
|
? 'Redirecting...'
|
|
1326
|
-
: `Pay ${this.
|
|
1452
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1327
1453
|
</button>
|
|
1328
1454
|
</div>
|
|
1329
1455
|
</div>
|
|
@@ -1366,7 +1492,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1366
1492
|
${this.currentState.status === 'processing' ||
|
|
1367
1493
|
this.currentState.status === 'requires_action'
|
|
1368
1494
|
? 'Redirecting...'
|
|
1369
|
-
: `Pay ${this.
|
|
1495
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1370
1496
|
</button>
|
|
1371
1497
|
</div>
|
|
1372
1498
|
</div>
|
|
@@ -1409,7 +1535,7 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1409
1535
|
${this.currentState.status === 'processing' ||
|
|
1410
1536
|
this.currentState.status === 'requires_action'
|
|
1411
1537
|
? 'Redirecting...'
|
|
1412
|
-
: `Pay ${this.
|
|
1538
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1413
1539
|
</button>
|
|
1414
1540
|
</div>
|
|
1415
1541
|
</div>
|
|
@@ -1452,7 +1578,136 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1452
1578
|
${this.currentState.status === 'processing' ||
|
|
1453
1579
|
this.currentState.status === 'requires_action'
|
|
1454
1580
|
? 'Redirecting...'
|
|
1455
|
-
: `Pay ${this.
|
|
1581
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1582
|
+
</button>
|
|
1583
|
+
</div>
|
|
1584
|
+
</div>
|
|
1585
|
+
</div>
|
|
1586
|
+
`;
|
|
1587
|
+
}
|
|
1588
|
+
renderAtomContent() {
|
|
1589
|
+
return html `
|
|
1590
|
+
<div class="paynow-container">
|
|
1591
|
+
<div class="paynow-instructions">
|
|
1592
|
+
<h3 class="instructions-title">How to Pay with Atome:</h3>
|
|
1593
|
+
|
|
1594
|
+
<div class="instruction-steps">
|
|
1595
|
+
<div class="instruction-step">
|
|
1596
|
+
<div class="step-number">1</div>
|
|
1597
|
+
<p class="step-text">Click <strong>"Pay"</strong> to go to the payment page.</p>
|
|
1598
|
+
</div>
|
|
1599
|
+
|
|
1600
|
+
<div class="instruction-step">
|
|
1601
|
+
<div class="step-number">2</div>
|
|
1602
|
+
<p class="step-text">Complete the payment on the external page.</p>
|
|
1603
|
+
</div>
|
|
1604
|
+
|
|
1605
|
+
<div class="instruction-step">
|
|
1606
|
+
<div class="step-number">3</div>
|
|
1607
|
+
<p class="step-text">You'll be redirected back automatically.</p>
|
|
1608
|
+
</div>
|
|
1609
|
+
</div>
|
|
1610
|
+
|
|
1611
|
+
<div class="submit-section">
|
|
1612
|
+
<button
|
|
1613
|
+
class="pay-button ${this.currentState.status === 'processing' ||
|
|
1614
|
+
this.currentState.status === 'requires_action'
|
|
1615
|
+
? 'loading'
|
|
1616
|
+
: ''}"
|
|
1617
|
+
@click=${this.handleAtomPayment}
|
|
1618
|
+
?disabled=${this.currentState.status === 'processing' ||
|
|
1619
|
+
this.currentState.status === 'requires_action'}
|
|
1620
|
+
>
|
|
1621
|
+
${this.currentState.status === 'processing' ||
|
|
1622
|
+
this.currentState.status === 'requires_action'
|
|
1623
|
+
? 'Redirecting...'
|
|
1624
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1625
|
+
</button>
|
|
1626
|
+
</div>
|
|
1627
|
+
</div>
|
|
1628
|
+
</div>
|
|
1629
|
+
`;
|
|
1630
|
+
}
|
|
1631
|
+
renderDanaContent() {
|
|
1632
|
+
return html `
|
|
1633
|
+
<div class="paynow-container">
|
|
1634
|
+
<div class="paynow-instructions">
|
|
1635
|
+
<h3 class="instructions-title">How to Pay with Dana:</h3>
|
|
1636
|
+
|
|
1637
|
+
<div class="instruction-steps">
|
|
1638
|
+
<div class="instruction-step">
|
|
1639
|
+
<div class="step-number">1</div>
|
|
1640
|
+
<p class="step-text">Click <strong>"Pay"</strong> to go to the payment page.</p>
|
|
1641
|
+
</div>
|
|
1642
|
+
|
|
1643
|
+
<div class="instruction-step">
|
|
1644
|
+
<div class="step-number">2</div>
|
|
1645
|
+
<p class="step-text">Complete the payment in the Dana app.</p>
|
|
1646
|
+
</div>
|
|
1647
|
+
|
|
1648
|
+
<div class="instruction-step">
|
|
1649
|
+
<div class="step-number">3</div>
|
|
1650
|
+
<p class="step-text">You'll be redirected back automatically.</p>
|
|
1651
|
+
</div>
|
|
1652
|
+
</div>
|
|
1653
|
+
|
|
1654
|
+
<div class="submit-section">
|
|
1655
|
+
<button
|
|
1656
|
+
class="pay-button ${this.currentState.status === 'processing' ||
|
|
1657
|
+
this.currentState.status === 'requires_action'
|
|
1658
|
+
? 'loading'
|
|
1659
|
+
: ''}"
|
|
1660
|
+
@click=${this.handleDanaPayment}
|
|
1661
|
+
?disabled=${this.currentState.status === 'processing' ||
|
|
1662
|
+
this.currentState.status === 'requires_action'}
|
|
1663
|
+
>
|
|
1664
|
+
${this.currentState.status === 'processing' ||
|
|
1665
|
+
this.currentState.status === 'requires_action'
|
|
1666
|
+
? 'Redirecting...'
|
|
1667
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1668
|
+
</button>
|
|
1669
|
+
</div>
|
|
1670
|
+
</div>
|
|
1671
|
+
</div>
|
|
1672
|
+
`;
|
|
1673
|
+
}
|
|
1674
|
+
renderTngContent() {
|
|
1675
|
+
return html `
|
|
1676
|
+
<div class="paynow-container">
|
|
1677
|
+
<div class="paynow-instructions">
|
|
1678
|
+
<h3 class="instructions-title">How to Pay with Touch 'n Go:</h3>
|
|
1679
|
+
|
|
1680
|
+
<div class="instruction-steps">
|
|
1681
|
+
<div class="instruction-step">
|
|
1682
|
+
<div class="step-number">1</div>
|
|
1683
|
+
<p class="step-text">Click <strong>"Pay"</strong> to go to the payment page.</p>
|
|
1684
|
+
</div>
|
|
1685
|
+
|
|
1686
|
+
<div class="instruction-step">
|
|
1687
|
+
<div class="step-number">2</div>
|
|
1688
|
+
<p class="step-text">Complete the payment in the Touch 'n Go eWallet app.</p>
|
|
1689
|
+
</div>
|
|
1690
|
+
|
|
1691
|
+
<div class="instruction-step">
|
|
1692
|
+
<div class="step-number">3</div>
|
|
1693
|
+
<p class="step-text">You'll be redirected back automatically.</p>
|
|
1694
|
+
</div>
|
|
1695
|
+
</div>
|
|
1696
|
+
|
|
1697
|
+
<div class="submit-section">
|
|
1698
|
+
<button
|
|
1699
|
+
class="pay-button ${this.currentState.status === 'processing' ||
|
|
1700
|
+
this.currentState.status === 'requires_action'
|
|
1701
|
+
? 'loading'
|
|
1702
|
+
: ''}"
|
|
1703
|
+
@click=${this.handleTngPayment}
|
|
1704
|
+
?disabled=${this.currentState.status === 'processing' ||
|
|
1705
|
+
this.currentState.status === 'requires_action'}
|
|
1706
|
+
>
|
|
1707
|
+
${this.currentState.status === 'processing' ||
|
|
1708
|
+
this.currentState.status === 'requires_action'
|
|
1709
|
+
? 'Redirecting...'
|
|
1710
|
+
: `Pay ${this.getPayButtonAmount()}`}
|
|
1456
1711
|
</button>
|
|
1457
1712
|
</div>
|
|
1458
1713
|
</div>
|
|
@@ -1550,6 +1805,12 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1550
1805
|
return 'Boost';
|
|
1551
1806
|
case PAYMENT_METHODS.SHOPEEPAY:
|
|
1552
1807
|
return 'ShopeePay';
|
|
1808
|
+
case PAYMENT_METHODS.ATOM:
|
|
1809
|
+
return 'Atome';
|
|
1810
|
+
case PAYMENT_METHODS.DANA:
|
|
1811
|
+
return 'Dana';
|
|
1812
|
+
case PAYMENT_METHODS.TNG:
|
|
1813
|
+
return "Touch 'n Go";
|
|
1553
1814
|
default:
|
|
1554
1815
|
return id;
|
|
1555
1816
|
}
|
|
@@ -1613,6 +1874,27 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1613
1874
|
<div class="method-icon-right">
|
|
1614
1875
|
<img src="${SHOPEEPAY_ICON_DATA_URL}" alt="ShopeePay" style="width: 45px; height: auto;" />
|
|
1615
1876
|
</div>
|
|
1877
|
+
`;
|
|
1878
|
+
}
|
|
1879
|
+
else if (id === PAYMENT_METHODS.ATOM) {
|
|
1880
|
+
return html `
|
|
1881
|
+
<div class="method-icon-right">
|
|
1882
|
+
<img src="${ATOM_ICON_DATA_URL}" alt="Atome" style="width: 45px; height: auto;" />
|
|
1883
|
+
</div>
|
|
1884
|
+
`;
|
|
1885
|
+
}
|
|
1886
|
+
else if (id === PAYMENT_METHODS.DANA) {
|
|
1887
|
+
return html `
|
|
1888
|
+
<div class="method-icon-right">
|
|
1889
|
+
<img src="${DANA_ICON_DATA_URL}" alt="Dana" style="width: 45px; height: auto;" />
|
|
1890
|
+
</div>
|
|
1891
|
+
`;
|
|
1892
|
+
}
|
|
1893
|
+
else if (id === PAYMENT_METHODS.TNG) {
|
|
1894
|
+
return html `
|
|
1895
|
+
<div class="method-icon-right">
|
|
1896
|
+
<img src="${TNG_ICON_DATA_URL}" alt="Touch 'n Go" style="width: 45px; height: auto;" />
|
|
1897
|
+
</div>
|
|
1616
1898
|
`;
|
|
1617
1899
|
}
|
|
1618
1900
|
return null;
|
|
@@ -1677,7 +1959,13 @@ let OnePayment = class OnePayment extends LitElement {
|
|
|
1677
1959
|
? this.renderBoostContent()
|
|
1678
1960
|
: method.id === PAYMENT_METHODS.SHOPEEPAY
|
|
1679
1961
|
? this.renderShopeePayContent()
|
|
1680
|
-
:
|
|
1962
|
+
: method.id === PAYMENT_METHODS.ATOM
|
|
1963
|
+
? this.renderAtomContent()
|
|
1964
|
+
: method.id === PAYMENT_METHODS.DANA
|
|
1965
|
+
? this.renderDanaContent()
|
|
1966
|
+
: method.id === PAYMENT_METHODS.TNG
|
|
1967
|
+
? this.renderTngContent()
|
|
1968
|
+
: null}
|
|
1681
1969
|
</div>`
|
|
1682
1970
|
: ''}
|
|
1683
1971
|
</div>
|
|
@@ -1875,6 +2163,7 @@ OnePayment.styles = css `
|
|
|
1875
2163
|
justify-content: center;
|
|
1876
2164
|
flex-shrink: 0;
|
|
1877
2165
|
color: var(--op-color-text-secondary);
|
|
2166
|
+
margin-left: 0.5rem;
|
|
1878
2167
|
}
|
|
1879
2168
|
|
|
1880
2169
|
.method-icon-right svg {
|
|
@@ -3040,6 +3329,9 @@ __decorate([
|
|
|
3040
3329
|
__decorate([
|
|
3041
3330
|
property({ type: String })
|
|
3042
3331
|
], OnePayment.prototype, "email", void 0);
|
|
3332
|
+
__decorate([
|
|
3333
|
+
property({ type: String })
|
|
3334
|
+
], OnePayment.prototype, "phoneNumber", void 0);
|
|
3043
3335
|
__decorate([
|
|
3044
3336
|
property({ type: Array })
|
|
3045
3337
|
], OnePayment.prototype, "excludePaymentMethods", void 0);
|