Skip to content

Commit 20e8e86

Browse files
feat(fpx): add support for fpx online banking Malaysia payment method (#476)
* feat(fpx): add support for fpx online banking Malaysia * chore(enabler/processor): add mapping for adyen to ct payment method type
1 parent b45c28a commit 20e8e86

File tree

13 files changed

+106
-15
lines changed

13 files changed

+106
-15
lines changed

enabler/dev-utils/session.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const getSessionId = async (cartId, isDropin = false) => {
5252
"blik",
5353
"card",
5454
"eps",
55+
"fpx",
5556
"googlepay",
5657
"ideal",
5758
"klarna_billie",

enabler/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ <h1 class="h3 mb-3 font-weight-normal">Dev Site</h1>
310310
"blik",
311311
"card",
312312
"eps",
313+
"fpx",
313314
"ideal",
314315
"klarna_billie",
315316
"klarna_pay_later",

enabler/src/components/base.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Vipps,
1515
OnlineBankingPL,
1616
AfterPay,
17+
MolPayEBankingMY,
1718
} from "@adyen/adyen-web";
1819
import {
1920
ComponentOptions,
@@ -30,6 +31,7 @@ type AdyenComponent =
3031
| GooglePay
3132
| Klarna
3233
| EPS
34+
| MolPayEBankingMY
3335
| Twint
3436
| Redirect
3537
| SepaDirectDebit
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import {
2+
ComponentOptions,
3+
PaymentComponent,
4+
PaymentMethod,
5+
} from "../../payment-enabler/payment-enabler";
6+
import { AdyenBaseComponentBuilder, DefaultAdyenComponent } from "../base";
7+
import { BaseOptions } from "../../payment-enabler/adyen-payment-enabler";
8+
import { MolPayEBankingMY, ICore } from "@adyen/adyen-web";
9+
10+
/**
11+
* fpx-online-banking-malaysia component
12+
*
13+
* Configuration options:
14+
* https://docs.adyen.com/payment-methods/fpx-online-banking-malaysia/web-component/
15+
*/
16+
export class FPXBuilder extends AdyenBaseComponentBuilder {
17+
constructor(baseOptions: BaseOptions) {
18+
super(PaymentMethod.fpx, baseOptions);
19+
}
20+
21+
build(config: ComponentOptions): PaymentComponent {
22+
const fpxComponent = new FPXComponent({
23+
paymentMethod: this.paymentMethod,
24+
adyenCheckout: this.adyenCheckout,
25+
componentOptions: config,
26+
sessionId: this.sessionId,
27+
processorUrl: this.processorUrl,
28+
paymentComponentConfigOverride:
29+
this.resolvePaymentComponentConfigOverride(PaymentMethod.fpx),
30+
});
31+
fpxComponent.init();
32+
return fpxComponent;
33+
}
34+
}
35+
36+
export class FPXComponent extends DefaultAdyenComponent {
37+
constructor(opts: {
38+
paymentMethod: PaymentMethod;
39+
adyenCheckout: ICore;
40+
componentOptions: ComponentOptions;
41+
sessionId: string;
42+
processorUrl: string;
43+
paymentComponentConfigOverride: Record<string, any>;
44+
}) {
45+
super(opts);
46+
}
47+
48+
init(): void {
49+
this.component = new MolPayEBankingMY(this.adyenCheckout, {
50+
// Override the default config with the one provided by the user
51+
...this.paymentComponentConfigOverride,
52+
// Configuration that can not be overridden
53+
showPayButton: this.componentOptions.showPayButton,
54+
});
55+
}
56+
57+
async showValidation() {
58+
this.component.showValidation();
59+
}
60+
61+
async isValid() {
62+
return this.component.isValid;
63+
}
64+
}

enabler/src/dropin/dropin-embedded.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
Swish,
3232
Vipps,
3333
AfterPay,
34+
MolPayEBankingMY,
3435
} from "@adyen/adyen-web";
3536

3637
export class DropinEmbeddedBuilder implements PaymentDropinBuilder {
@@ -163,6 +164,7 @@ export class DropinComponents implements DropinComponent {
163164
Card,
164165
GooglePay,
165166
EPS,
167+
MolPayEBankingMY,
166168
Klarna,
167169
OnlineBankingPL,
168170
PayPal,
@@ -262,6 +264,11 @@ export class DropinComponents implements DropinComponent {
262264
],
263265
// Configuration that can not be overridden
264266
},
267+
molpay_ebanking_fpx_MY: {
268+
// Override the default config with the one provided by the user
269+
...this.dropinConfigOverride[getPaymentMethodType(PaymentMethod.fpx)],
270+
// Configuration that can not be overridden
271+
},
265272
onlineBanking_PL: {
266273
// Override the default config with the one provided by the user
267274
...this.dropinConfigOverride[

enabler/src/payment-enabler/adyen-payment-enabler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { convertToAdyenLocale } from "../converters/locale.converter";
4545
import { AfterPayBuilder } from "../components/payment-methods/afterpay";
4646
import { ClearpayBuilder } from "../components/payment-methods/clearpay";
4747
import { StoredCardBuilder } from "../stored/stored-payment-methods/card";
48+
import { FPXBuilder } from "../components/payment-methods/fpx";
4849

4950
class AdyenInitError extends Error {
5051
sessionId: string;
@@ -354,6 +355,7 @@ export class AdyenPaymentEnabler implements PaymentEnabler {
354355
blik: BlikBuilder,
355356
card: CardBuilder,
356357
eps: EPSBuilder,
358+
fpx: FPXBuilder,
357359
googlepay: GooglepayBuilder,
358360
ideal: IdealBuilder,
359361
klarna_billie: KlarnaBillieBuilder,

enabler/src/payment-enabler/payment-enabler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export enum PaymentMethod {
4646
clearpay = "clearpay",
4747
dropin = "dropin",
4848
eps = "eps",
49+
fpx = "molpay_ebanking_fpx_MY", // FPX Online banking Malaysia
4950
googlepay = "googlepay",
5051
ideal = "ideal",
5152
klarna_billie = "klarna_b2b", // Billie

processor/src/config/payment-method.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const paymentMethodConfig: PaymentMethodConfig = {
2626
eps: {
2727
supportSeparateCapture: false,
2828
},
29+
molpay_ebanking_fpx_MY: {
30+
supportSeparateCapture: false,
31+
},
2932
ideal: {
3033
supportSeparateCapture: false,
3134
},

processor/src/services/converters/helper.converter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ const PAYMENT_METHOD_TO_ADYEN_MAPPING: Record<string, string> = {
288288
klarna_pay_now: 'klarna_paynow',
289289
klarna_pay_overtime: 'klarna_account',
290290
przelewy24: GenericIssuerPaymentMethodDetails.TypeEnum.OnlineBankingPl,
291+
fpx: 'molpay_ebanking_fpx_MY',
291292
};
292293

293294
const ADYEN_TO_PAYMENT_METHOD_MAPPING: Record<string, string> = Object.entries(PAYMENT_METHOD_TO_ADYEN_MAPPING).reduce(

processor/src/services/converters/payment-components.converter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export class PaymentComponentsConverter {
3030
{
3131
type: 'eps',
3232
},
33+
{
34+
type: 'fpx', // FPX Online banking Malaysia
35+
},
3336
{
3437
type: 'googlepay',
3538
},

0 commit comments

Comments
 (0)