Skip to content

Commit

Permalink
Updates recurly-js types
Browse files Browse the repository at this point in the history
  • Loading branch information
recurly-integrations committed Feb 14, 2024
1 parent 6cb00a7 commit 3b4ded1
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 9 deletions.
6 changes: 6 additions & 0 deletions types/recurly__recurly-js/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Type definitions for non-npm package @recurly/recurly-js 4.27
// Project: https://github.com/recurly/recurly-js
// Definitions by: Christopher Rogers <https://github.com/chrissrogers>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1
import { Recurly } from './lib/recurly';

declare global {
Expand All @@ -17,6 +22,7 @@ export * from './lib/address';
export * from './lib/adyen';
export * from './lib/bank-redirect';
export * from './lib/apple-pay/index';
export * from './lib/amazon-pay';
export * from './lib/google-pay/index';
export * from './lib/bank-account';
export * from './lib/configure';
Expand Down
40 changes: 40 additions & 0 deletions types/recurly__recurly-js/lib/amazon-pay.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Emitter } from './emitter';

export type AmazonPayOptions = {
/**
* 2 Digit Country Code
*/
region?: string;

/**
* Specify which Payment Gateway in Recurly must handle the payment.
*/
gatewayCode?: string

/**
* Sets button to Sandbox environment
*/
sandbox?: boolean;
};

export type AmazonPayEvent = 'ready' | 'token' | 'error' | 'close' | 'done';

export interface AmazonPayInstance extends Emitter<AmazonPayEvent> {
/**
* Invokes the Amazon Payment Modal
*/
start: () => void;

/**
* Attaches an Element to the DOM, as a child of the specified parent target.
*
*/
attach: () => void;

/**
* Renders Amazon Pay button to the page
*/
renderButton: (element: string) => void;
}

export type AmazonPay = (amazonPayOptions?: AmazonPayOptions) => AmazonPayInstance;
5 changes: 0 additions & 5 deletions types/recurly__recurly-js/lib/apple-pay/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,10 @@ export type ApplePayConfig = {
* Callbacks for the events emitted by the payment session when a user selects options in the payment sheet.
*/
callbacks?: {
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onPaymentMethodSelected?: (event: ApplePayPaymentMethodSelectedEvent) => Promise<ApplePaySelectionUpdate> | ApplePaySelectionUpdate | void,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onShippingContactSelected?: (event: ApplePayShippingContactSelectedEvent) => Promise<ApplePaySelectionUpdate> | ApplePaySelectionUpdate | void,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onShippingMethodSelected?: (event: ApplePayShippingMethodSelectedEvent) => Promise<ApplePaySelectionUpdate> | ApplePaySelectionUpdate | void,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onCouponCodeChanged?: (event: ApplePayCouponCodeChangedEvent) => Promise<ApplePaySelectionUpdate> | ApplePaySelectionUpdate | void,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onPaymentAuthorized?: (event: ApplePayPaymentAuthorizedEvent) => Promise<ApplePayErrorUpdate> | ApplePayErrorUpdate | void,
};

Expand Down
2 changes: 1 addition & 1 deletion types/recurly__recurly-js/lib/apple-pay/native.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export type ApplePayPayment = {
* The shipping contact selected by the user for this transaction.
*/
shippingContact: ApplePayPaymentContact;
recurlyToken: TokenPayload;
};

/**
Expand All @@ -374,5 +375,4 @@ export type ApplePayPaymentAuthorizedEvent = {
payment: ApplePayPayment;

gatewayToken?: string;
recurlyToken: TokenPayload;
};
1 change: 0 additions & 1 deletion types/recurly__recurly-js/lib/google-pay/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export type GooglePayOptions = {
*/
callbacks?: {
onPaymentDataChanged?: (intermediatePaymentData: GooglePayIntermediatePaymentData) => Promise<GooglePayPaymentDataRequestUpdate>;
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onPaymentAuthorized?: (paymentData: GooglePayPaymentData) => Promise<GooglePayPaymentAuthorizationResult> | void;
},
};
Expand Down
8 changes: 8 additions & 0 deletions types/recurly__recurly-js/lib/recurly.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Adyen } from './adyen';
import { BankRedirect } from './bank-redirect';
import { AlternativePaymentMethods } from './alternative-payment-methods';
import { ApplePay } from './apple-pay/index';
import { AmazonPay } from './amazon-pay';
import { BankAccount } from './bank-account';
import { Configure } from './configure';
import { Elements } from './elements';
Expand Down Expand Up @@ -89,6 +90,13 @@ export interface Recurly extends Emitter<RecurlyEvent> {
*/
PayPal: PayPal;

/**
* Use Recurly to process Amazon Pay v2 transactions
*
* @see {@link https://recurly.com/developers/reference/recurly-js/index.html#amazon-pay-v2|AmazonPay}
*/
AmazonPay: AmazonPay;

/**
* Recurly automates complicated subscriptions, with many factors influencing the total price at checkout. With this
* in mind, Recurly.js provides a robust `recurly.Pricing.Checkout` class designed to make determining the actual
Expand Down
1 change: 0 additions & 1 deletion types/recurly__recurly-js/test/apple-pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ApplePaySelectionUpdate,
} from '@recurly/recurly-js';

// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
function getTaxes ({ paymentMethod: { billingContact } }: ApplePayPaymentMethodSelectedEvent): ApplePaySelectionUpdate | void {
if (billingContact?.postalCode === '12345') {
return { newLineItems: [{ label: 'Tax', amount: '1.00' }] };
Expand Down
1 change: 0 additions & 1 deletion types/recurly__recurly-js/test/google-pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function googlePay () {
buttonColor: 'black',
},
callbacks: {
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
onPaymentAuthorized: (paymentData: GooglePayPaymentData): Promise<GooglePayPaymentAuthorizationResult> | void => {
if (paymentData.email === '[email protected]') {
return Promise.reject({
Expand Down

0 comments on commit 3b4ded1

Please sign in to comment.