diff --git a/lib/recurly/alternative-payment-methods/gateways/adyen.js b/lib/recurly/alternative-payment-methods/gateways/adyen.js index 2525a951..ac1f0ceb 100644 --- a/lib/recurly/alternative-payment-methods/gateways/adyen.js +++ b/lib/recurly/alternative-payment-methods/gateways/adyen.js @@ -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 () { @@ -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(); } diff --git a/types/lib/alternative-payment-methods.d.ts b/types/lib/alternative-payment-methods.d.ts index 942173ce..875c0b8b 100644 --- a/types/lib/alternative-payment-methods.d.ts +++ b/types/lib/alternative-payment-methods.d.ts @@ -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. @@ -78,6 +85,11 @@ export type AlternativePaymentMethodStartOptions = { * Adyen options. */ adyen?: AdyenAlternativePaymentMethodOptions + + /** + * Sets additional customer fields on the generated token. + */ + customer?: CustomerOptions, }; export type AlternativePaymentMethodSubmitOptions = {