Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add missing type definitions for Adyen APM #907

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading