Skip to content

Commit

Permalink
Merge pull request #907 from recurly/updated-types
Browse files Browse the repository at this point in the history
chore: add missing type definitions for Adyen APM
  • Loading branch information
chrissrogers authored Nov 14, 2024
2 parents b258a60 + c629b8a commit 7057f0c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
21 changes: 21 additions & 0 deletions test/types/alternative-payment-methods.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default function alternativePaymentMethods () {
const apm = window.recurly.AlternativePaymentMethods({
allowedPaymentMethods: ['ideal', 'sofort', 'cashapp'],
blockedPaymentMethods: ['bacs'],
containerSelector: '#payment-methods',
amount: 1000,
currency: 'EUR',
countryCode: 'NL',
returnURL: 'https://example.com/return',
adyen: {
publicKey: 'public-key',
},
});

apm.on('error', () => {});
// @ts-expect-error
apm.start({});
apm.start().then(() => {});
apm.submit({}).then(() => {});
apm.handleAction({}).then(() => {});
}
22 changes: 14 additions & 8 deletions types/lib/alternative-payment-methods.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Emitter } from './emitter';

export type AlternativePaymentMethodEvents = 'token' | 'error' | 'valid';

export type AlternativePaymentMethodType = 'boleto';
export type AlternativePaymentMethodType = 'boleto' | 'ideal' | 'sofort' | 'paypal' | 'cashapp' | 'bacs';

export type ChannelType = 'iOS' | 'Android' | 'Web';

Expand All @@ -16,15 +16,15 @@ export type AdyenAlternativePaymentMethodOptions = {
publicKey: string,

/**
* Indicate a test or a live environment.
* Indicate a test or a live environment. Defaults to `"test"`.
*/
env?: AdyenEnvironmentType,

/**
* Show or hides a Pay Button for each payment method. Defaults to false.
* Show or hides a Pay Button for each payment method. Defaults to `false`.
* When the button is disable you need to call the submit() function when the payment form is valid.
*/
showPayButton?: false,
showPayButton?: boolean,

/**
* Additional Adyen Configuration.
Expand Down Expand Up @@ -71,13 +71,14 @@ export type AlternativePaymentMethodStartOptions = {
countryCode: string;

/**
* The customer's locale. This is used to set the language rendered in the UI.
* The customer's locale. This is used to set the language rendered in the UI. Defaults to `"en-US"`.
*/
locale?: string;

/**
* The platform where a payment transaction takes place.
* This field can be used for filtering out payment methods that are only available on specific platforms.
* Defaults to `"Web"`.
*/
channel?: ChannelType,

Expand All @@ -89,7 +90,12 @@ export type AlternativePaymentMethodStartOptions = {
/**
* Sets additional customer fields on the generated token.
*/
customer?: CustomerOptions
customer?: CustomerOptions,

/**
* The URL to return to after the shopper completes the payment.
*/
returnURL?: string
};

export type AlternativePaymentMethodSubmitOptions = {
Expand All @@ -103,7 +109,7 @@ export interface AlternativePaymentMethodsInstance extends Emitter<AlternativePa
/**
* Start the PaymentMethods and render the components.
*/
start: (data: AlternativePaymentMethodStartOptions) => Promise<void>;
start: () => Promise<void>;

/**
* Submit the customer payment information and produce a token.
Expand All @@ -121,4 +127,4 @@ export interface AlternativePaymentMethodsInstance extends Emitter<AlternativePa
handleAction: (paymentResponse: any) => Promise<void>;
}

export type AlternativePaymentMethods = () => AlternativePaymentMethodsInstance;
export type AlternativePaymentMethods = (config: AlternativePaymentMethodStartOptions) => AlternativePaymentMethodsInstance;

0 comments on commit 7057f0c

Please sign in to comment.