Skip to content

Commit

Permalink
Merge pull request #119 from commercetools/johnsonogwuru/enable-googl…
Browse files Browse the repository at this point in the history
…epay

feat(payment): Enable support for Google Pay
  • Loading branch information
johnsonogwuru authored May 16, 2024
2 parents 347f084 + 73fc265 commit 0579e05
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions enabler/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ <h1 class="h3 mb-3 font-weight-normal">Dev Site</h1>
sessionId: sessionId,
config: {

},
onError:(error) => {
console.log('onError', error)
},
onComplete: ({ isSuccess, paymentReference }) => {
console.log('onComplete', { isSuccess, paymentReference });
Expand Down
39 changes: 37 additions & 2 deletions enabler/src/components/payment-methods/googlepay.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
})
}
}

0 comments on commit 0579e05

Please sign in to comment.