diff --git a/enabler/index.html b/enabler/index.html index 2a6592a..3264840 100644 --- a/enabler/index.html +++ b/enabler/index.html @@ -57,6 +57,9 @@

Dev Site

sessionId: sessionId, config: { + }, + onError:(error) => { + console.log('onError', error) }, onComplete: ({ isSuccess, paymentReference }) => { console.log('onComplete', { isSuccess, paymentReference }); diff --git a/enabler/src/components/payment-methods/googlepay.ts b/enabler/src/components/payment-methods/googlepay.ts index fe7cd73..678f2cc 100644 --- a/enabler/src/components/payment-methods/googlepay.ts +++ b/enabler/src/components/payment-methods/googlepay.ts @@ -1,5 +1,6 @@ -import { PaymentMethod } from '../../payment-enabler/payment-enabler'; -import { AdyenBaseComponentBuilder, BaseOptions } from '../base'; +import Core from "@adyen/adyen-web/dist/types/core/core"; +import { ComponentOptions, PaymentMethod } from '../../payment-enabler/payment-enabler'; +import { AdyenBaseComponentBuilder, BaseOptions, DefaultAdyenComponent } from '../base'; /** * Google pay component @@ -13,4 +14,38 @@ export class GooglepayBuilder extends AdyenBaseComponentBuilder { constructor(baseOptions: BaseOptions) { super(PaymentMethod.googlepay, baseOptions); } + + build(config: ComponentOptions): GooglePayComponent { + const googlePayComponent = new GooglePayComponent({ + paymentMethod: this.paymentMethod, + adyenCheckout: this.adyenCheckout, + componentOptions: config, + sessionId: this.sessionId, + processorUrl: this.processorUrl, + }) + googlePayComponent.init(); + + return googlePayComponent + } } + +export class GooglePayComponent extends DefaultAdyenComponent { + constructor(opts: { + paymentMethod: PaymentMethod; + adyenCheckout: typeof Core; + componentOptions: ComponentOptions; + sessionId: string; + processorUrl: string; + usesOwnCertificate?: boolean; + }) { + super(opts); + } + + init() { + this.component = this.adyenCheckout.create(this.paymentMethod, { + ...this.componentOptions, + buttonType: 'pay', + buttonSizeMode: 'fill' + }) + } +} \ No newline at end of file