Skip to content

Commit

Permalink
allow billingAddress to be passed in via customer options when
Browse files Browse the repository at this point in the history
initializing AlternativePaymentMethods class

update typescript types
  • Loading branch information
gilv93 committed Oct 25, 2024
1 parent 92e30ef commit 269d55f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/recurly/alternative-payment-methods/gateways/adyen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class AdyenGateway extends Base {
this.gatewayType = 'adyen';
this.webComponent = undefined;
this.customerBillingAddress = undefined;

if (options.customer?.billingAddress) {
super.validateBillingAddress(options.customer.billingAddress);
this.customerBillingAddress = options.customer.billingAddress;
}
}

scripts () {
Expand Down Expand Up @@ -89,7 +94,7 @@ class AdyenGateway extends Base {
}

async submitWebComponent (billingAddress) {
this.customerBillingAddress = billingAddress;
if (this.customerBillingAddress === undefined) { this.customerBillingAddress = billingAddress; }
return this.webComponent.submit();
}

Expand Down
12 changes: 12 additions & 0 deletions types/lib/alternative-payment-methods.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export type AdyenAlternativePaymentMethodOptions = {
componentConfig?: { [key: string]: any }
};

export type CustomerOptions = {
/**
* The customer's billing address.
*/
billingAddress?: Address;
}

export type AlternativePaymentMethodStartOptions = {
/**
* List of payment methods to be presented to the customer.
Expand Down Expand Up @@ -78,6 +85,11 @@ export type AlternativePaymentMethodStartOptions = {
* Adyen options.
*/
adyen?: AdyenAlternativePaymentMethodOptions

/**
* Sets additional customer fields on the generated token.
*/
customer?: CustomerOptions,
};

export type AlternativePaymentMethodSubmitOptions = {
Expand Down

0 comments on commit 269d55f

Please sign in to comment.