From 3b4ded1f5b9233409390254030cf464955fdaaa6 Mon Sep 17 00:00:00 2001 From: recurly-integrations Date: Wed, 14 Feb 2024 20:35:53 +0000 Subject: [PATCH] Updates recurly-js types --- types/recurly__recurly-js/index.d.ts | 6 +++ types/recurly__recurly-js/lib/amazon-pay.d.ts | 40 +++++++++++++++++++ .../lib/apple-pay/index.d.ts | 5 --- .../lib/apple-pay/native.d.ts | 2 +- .../lib/google-pay/index.d.ts | 1 - types/recurly__recurly-js/lib/recurly.d.ts | 8 ++++ types/recurly__recurly-js/test/apple-pay.ts | 1 - types/recurly__recurly-js/test/google-pay.ts | 1 - 8 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 types/recurly__recurly-js/lib/amazon-pay.d.ts diff --git a/types/recurly__recurly-js/index.d.ts b/types/recurly__recurly-js/index.d.ts index ebb311e8a4ffba..cf4ea79a3eb577 100644 --- a/types/recurly__recurly-js/index.d.ts +++ b/types/recurly__recurly-js/index.d.ts @@ -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 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 import { Recurly } from './lib/recurly'; declare global { @@ -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'; diff --git a/types/recurly__recurly-js/lib/amazon-pay.d.ts b/types/recurly__recurly-js/lib/amazon-pay.d.ts new file mode 100644 index 00000000000000..056fdc29b7ae0a --- /dev/null +++ b/types/recurly__recurly-js/lib/amazon-pay.d.ts @@ -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 { + /** + * 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; diff --git a/types/recurly__recurly-js/lib/apple-pay/index.d.ts b/types/recurly__recurly-js/lib/apple-pay/index.d.ts index 5b9813d1a0c20d..e76a7b484d0509 100644 --- a/types/recurly__recurly-js/lib/apple-pay/index.d.ts +++ b/types/recurly__recurly-js/lib/apple-pay/index.d.ts @@ -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 | void, -// eslint-disable-next-line @typescript-eslint/no-invalid-void-type onShippingContactSelected?: (event: ApplePayShippingContactSelectedEvent) => Promise | ApplePaySelectionUpdate | void, -// eslint-disable-next-line @typescript-eslint/no-invalid-void-type onShippingMethodSelected?: (event: ApplePayShippingMethodSelectedEvent) => Promise | ApplePaySelectionUpdate | void, -// eslint-disable-next-line @typescript-eslint/no-invalid-void-type onCouponCodeChanged?: (event: ApplePayCouponCodeChangedEvent) => Promise | ApplePaySelectionUpdate | void, -// eslint-disable-next-line @typescript-eslint/no-invalid-void-type onPaymentAuthorized?: (event: ApplePayPaymentAuthorizedEvent) => Promise | ApplePayErrorUpdate | void, }; diff --git a/types/recurly__recurly-js/lib/apple-pay/native.d.ts b/types/recurly__recurly-js/lib/apple-pay/native.d.ts index 979e129a2e3feb..86455df741c936 100644 --- a/types/recurly__recurly-js/lib/apple-pay/native.d.ts +++ b/types/recurly__recurly-js/lib/apple-pay/native.d.ts @@ -362,6 +362,7 @@ export type ApplePayPayment = { * The shipping contact selected by the user for this transaction. */ shippingContact: ApplePayPaymentContact; + recurlyToken: TokenPayload; }; /** @@ -374,5 +375,4 @@ export type ApplePayPaymentAuthorizedEvent = { payment: ApplePayPayment; gatewayToken?: string; - recurlyToken: TokenPayload; }; diff --git a/types/recurly__recurly-js/lib/google-pay/index.d.ts b/types/recurly__recurly-js/lib/google-pay/index.d.ts index 3d1e6ed1e12164..ed09f6083f344a 100644 --- a/types/recurly__recurly-js/lib/google-pay/index.d.ts +++ b/types/recurly__recurly-js/lib/google-pay/index.d.ts @@ -91,7 +91,6 @@ export type GooglePayOptions = { */ callbacks?: { onPaymentDataChanged?: (intermediatePaymentData: GooglePayIntermediatePaymentData) => Promise; -// eslint-disable-next-line @typescript-eslint/no-invalid-void-type onPaymentAuthorized?: (paymentData: GooglePayPaymentData) => Promise | void; }, }; diff --git a/types/recurly__recurly-js/lib/recurly.d.ts b/types/recurly__recurly-js/lib/recurly.d.ts index bdf0d332126028..45765b43239cc6 100644 --- a/types/recurly__recurly-js/lib/recurly.d.ts +++ b/types/recurly__recurly-js/lib/recurly.d.ts @@ -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'; @@ -89,6 +90,13 @@ export interface Recurly extends Emitter { */ 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 diff --git a/types/recurly__recurly-js/test/apple-pay.ts b/types/recurly__recurly-js/test/apple-pay.ts index 6935ac463e3fa7..5e52cae58b70ef 100644 --- a/types/recurly__recurly-js/test/apple-pay.ts +++ b/types/recurly__recurly-js/test/apple-pay.ts @@ -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' }] }; diff --git a/types/recurly__recurly-js/test/google-pay.ts b/types/recurly__recurly-js/test/google-pay.ts index 0c28e11305e0ed..1bffb71a1e822d 100644 --- a/types/recurly__recurly-js/test/google-pay.ts +++ b/types/recurly__recurly-js/test/google-pay.ts @@ -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 | void => { if (paymentData.email === 'test@example.com') { return Promise.reject({