mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #45675 Updates types for Recurly.js v4.13.0 by @dbrudner
Co-authored-by: dbrudner <dbrudner@users.noreply.github.com>
This commit is contained in:
parent
db10cf8903
commit
8c81e77bba
3
types/recurly__recurly-js/index.d.ts
vendored
3
types/recurly__recurly-js/index.d.ts
vendored
@ -1,10 +1,9 @@
|
||||
// Type definitions for non-npm package recurly__recurly-js 4.12
|
||||
// Type definitions for non-npm package recurly__recurly-js 4.13
|
||||
// Project: https://github.com/recurly/recurly-js
|
||||
// Definitions by: Dave Brudner <https://github.com/dbrudner>
|
||||
// Chris Rogers <https://github.com/chrissrogers>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { Recurly } from './lib/recurly';
|
||||
|
||||
declare global {
|
||||
|
||||
12
types/recurly__recurly-js/lib/bank-account.d.ts
vendored
12
types/recurly__recurly-js/lib/bank-account.d.ts
vendored
@ -2,12 +2,14 @@ import { RecurlyError } from './error';
|
||||
import { TokenHandler } from './token';
|
||||
|
||||
export type BillingInfo = {
|
||||
routing_number: string;
|
||||
account_number: string;
|
||||
account_number_confirmation: string;
|
||||
account_type: string;
|
||||
iban?: string;
|
||||
name_on_account: string;
|
||||
routing_number?: string;
|
||||
account_number?: string;
|
||||
account_number_confirmation?: string;
|
||||
account_type?: string;
|
||||
sort_code?: string;
|
||||
type?: string;
|
||||
iban?: string;
|
||||
address1?: string;
|
||||
address2?: string;
|
||||
city?: string;
|
||||
|
||||
3
types/recurly__recurly-js/lib/emitter.d.ts
vendored
3
types/recurly__recurly-js/lib/emitter.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
type Listener = (...args: any[]) => void;
|
||||
|
||||
interface Emitter<Event = string> {
|
||||
on(event: Event, listener: Listener): Emitter<Event>;
|
||||
once(event: Event, listener: Listener): Emitter<Event>;
|
||||
@ -9,5 +10,5 @@ interface Emitter<Event = string> {
|
||||
}
|
||||
|
||||
export {
|
||||
Emitter
|
||||
Emitter
|
||||
};
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
export default function threeDSecure() {
|
||||
const risk = window.recurly.Risk();
|
||||
const threeDSecure = risk.ThreeDSecure({
|
||||
actionTokenId: 'token',
|
||||
actionTokenId: 'token'
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
threeDSecure.on('fake-event', () => {});
|
||||
threeDSecure.on('token', () => {});
|
||||
threeDSecure.on('error', () => {});
|
||||
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
export default function adyen() {
|
||||
const adyen = window.recurly.Adyen();
|
||||
|
||||
// $ExpectError
|
||||
adyen.on('fake-event', () => {});
|
||||
adyen.on('token', () => {});
|
||||
adyen.start({ invoiceUuid: 'invoice-uuid' });
|
||||
adyen.start({
|
||||
invoiceUuid: 'invoice-uuid',
|
||||
skinCode: 'skin-code',
|
||||
countryCode: 'PL',
|
||||
shopperLocale: 'en_PL',
|
||||
shopperLocale: 'en_PL'
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
|
||||
@ -4,7 +4,7 @@ export default function applePay() {
|
||||
currency: 'USD',
|
||||
label: 'My Subscription',
|
||||
total: '29.00',
|
||||
pricing: window.recurly.Pricing.Checkout(),
|
||||
pricing: window.recurly.Pricing.Checkout()
|
||||
});
|
||||
|
||||
applePay.ready(() => {});
|
||||
|
||||
@ -13,16 +13,29 @@ export default function bankAccount() {
|
||||
}
|
||||
});
|
||||
|
||||
window.recurly.bankAccount.token(formEl, (err, token) => {
|
||||
const billingInfo = {
|
||||
routing_number: '123456780',
|
||||
account_number: '111111111',
|
||||
account_number_confirmation: '111111111',
|
||||
account_type: 'checking',
|
||||
iban: '123',
|
||||
name_on_account: 'Pat Smith',
|
||||
address1: '123 Main St.',
|
||||
address2: 'Unit 1',
|
||||
city: 'Hope',
|
||||
state: 'WA',
|
||||
postal_code: '98552',
|
||||
country: 'US',
|
||||
vat_number: 'SE0000',
|
||||
};
|
||||
|
||||
window.recurly.bankAccount.token(billingInfo, (err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
|
||||
// $ExpectError
|
||||
token.fake;
|
||||
}
|
||||
});
|
||||
|
||||
@ -47,4 +60,40 @@ export default function bankAccount() {
|
||||
token.type;
|
||||
}
|
||||
});
|
||||
|
||||
const minimalBacsBillingInfo = {
|
||||
type: 'bacs',
|
||||
account_number: "1234",
|
||||
account_number_confirmation: "1234",
|
||||
sort_code: "1234",
|
||||
name_on_account: "1234"
|
||||
};
|
||||
|
||||
window.recurly.bankAccount.token(minimalBacsBillingInfo, (err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
}
|
||||
});
|
||||
|
||||
const missingNameOnAccountBacsBillingInfo = {
|
||||
type: 'bacs',
|
||||
account_number: "1234",
|
||||
account_number_confirmation: "1234",
|
||||
sort_code: "1234",
|
||||
};
|
||||
|
||||
// $ExpectError
|
||||
window.recurly.bankAccount.token(missingNameOnAccountBacsBillingInfo, (err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export default function configure() {
|
||||
window.recurly.configure('ewr1-BrfKUWEllwCxdpRZvZloaJ');
|
||||
window.recurly.configure('my-public-key');
|
||||
window.recurly.configure({
|
||||
cors: true,
|
||||
currency: 'USD',
|
||||
|
||||
@ -10,16 +10,16 @@ export default function elements() {
|
||||
fontWeight: 'bold',
|
||||
content: {
|
||||
number: 'Card number',
|
||||
cvv: 'CVC',
|
||||
},
|
||||
cvv: 'CVC'
|
||||
}
|
||||
},
|
||||
invalid: {
|
||||
fontColor: 'red',
|
||||
},
|
||||
},
|
||||
fontColor: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const elementStyle = {
|
||||
const elementOptions = {
|
||||
format: true,
|
||||
inputType: 'text',
|
||||
tabIndex: '1',
|
||||
@ -39,10 +39,10 @@ export default function elements() {
|
||||
}
|
||||
|
||||
[
|
||||
elements.CardNumberElement(elementStyle),
|
||||
elements.CardMonthElement(elementStyle),
|
||||
elements.CardYearElement(elementStyle),
|
||||
elements.CardCvvElement(elementStyle),
|
||||
elements.CardNumberElement(elementOptions),
|
||||
elements.CardMonthElement(elementOptions),
|
||||
elements.CardYearElement(elementOptions),
|
||||
elements.CardCvvElement(elementOptions)
|
||||
].forEach(element => {
|
||||
element.attach('#recurly-elements');
|
||||
element.on('attach', () => {});
|
||||
|
||||
@ -27,6 +27,5 @@ export default function paypal() {
|
||||
description: "description"
|
||||
}
|
||||
});
|
||||
|
||||
paypal.destroy();
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ export default function subscriptionPricing() {
|
||||
const el = document.querySelector('div');
|
||||
|
||||
if (el) {
|
||||
checkoutPricing.attach(el);
|
||||
checkoutPricing.attach(el);
|
||||
}
|
||||
|
||||
checkoutPricing.attach('#my-pricing-form');
|
||||
@ -12,7 +12,7 @@ export default function subscriptionPricing() {
|
||||
checkoutPricing
|
||||
.address({
|
||||
first_name: 'dave',
|
||||
last_name: 'b',
|
||||
last_name: 'b'
|
||||
})
|
||||
.address({
|
||||
first_name: 'dave',
|
||||
@ -24,25 +24,25 @@ export default function subscriptionPricing() {
|
||||
postal_code: 'postal_code',
|
||||
country: 'country',
|
||||
phone: 'phone',
|
||||
vat_number: 'vat_number',
|
||||
vat_number: 'vat_number'
|
||||
})
|
||||
.adjustment({
|
||||
id: '0',
|
||||
amount: 1,
|
||||
quantity: 1,
|
||||
taxExempt: true,
|
||||
taxCode: 'my-tax-code',
|
||||
taxCode: 'my-tax-code'
|
||||
})
|
||||
.adjustment({
|
||||
itemCode: 'item',
|
||||
quantity: 1,
|
||||
quantity: 1
|
||||
})
|
||||
.coupon('my-coupon-code')
|
||||
.currency('USD')
|
||||
.giftCard('my-gift-card-code')
|
||||
.shippingAddress({
|
||||
first_name: 'dave',
|
||||
last_name: 'b',
|
||||
last_name: 'b'
|
||||
})
|
||||
.shippingAddress({
|
||||
first_name: 'dave',
|
||||
@ -54,18 +54,18 @@ export default function subscriptionPricing() {
|
||||
postal_code: 'postal_code',
|
||||
country: 'country',
|
||||
phone: 'phone',
|
||||
vat_number: 'vat_number',
|
||||
vat_number: 'vat_number'
|
||||
})
|
||||
.tax({
|
||||
tax_code: 'tax_code',
|
||||
tax_code: 'tax_code'
|
||||
})
|
||||
.tax({
|
||||
tax_code: 'tax_code',
|
||||
vat_number: 'vat_number',
|
||||
amounts: {
|
||||
now: 'now',
|
||||
next: 'next',
|
||||
},
|
||||
next: 'next'
|
||||
}
|
||||
})
|
||||
.then(x => x)
|
||||
.catch(e => {
|
||||
@ -76,7 +76,7 @@ export default function subscriptionPricing() {
|
||||
})
|
||||
.shippingAddress({
|
||||
first_name: 'dave',
|
||||
last_name: 'b',
|
||||
last_name: 'b'
|
||||
})
|
||||
.shippingAddress({
|
||||
first_name: 'dave',
|
||||
@ -88,18 +88,79 @@ export default function subscriptionPricing() {
|
||||
postal_code: 'postal_code',
|
||||
country: 'country',
|
||||
phone: 'phone',
|
||||
vat_number: 'vat_number',
|
||||
vat_number: 'vat_number'
|
||||
})
|
||||
.tax({
|
||||
tax_code: 'digital',
|
||||
tax_code: 'digital'
|
||||
})
|
||||
.subscription(
|
||||
window.recurly.Pricing.Subscription()
|
||||
.plan('basic', { quantity: 1 })
|
||||
.done(),
|
||||
.done()
|
||||
)
|
||||
.then(x => x)
|
||||
.done(pricing => {
|
||||
// $ExpectType string
|
||||
pricing.price.now.items[0].addons;
|
||||
// $ExpectType string
|
||||
pricing.price.now.items[0].amount;
|
||||
// $ExpectType string
|
||||
pricing.price.now.items[0].id;
|
||||
// $ExpectType string
|
||||
pricing.price.now.items[0].plan;
|
||||
// $ExpectType string
|
||||
pricing.price.now.items[0].setupFee;
|
||||
// $ExpectType string
|
||||
pricing.price.now.items[0].type;
|
||||
// $ExpectType string
|
||||
pricing.price.now.subscriptions;
|
||||
// $ExpectType string
|
||||
pricing.price.now.adjustments;
|
||||
// $ExpectType string
|
||||
pricing.price.now.discount;
|
||||
// $ExpectType string
|
||||
pricing.price.now.subtotal;
|
||||
// $ExpectType string
|
||||
pricing.price.now.taxes;
|
||||
// $ExpectType string
|
||||
pricing.price.now.giftCard;
|
||||
// $ExpectType string
|
||||
pricing.price.now.total;
|
||||
// $ExpectType string
|
||||
pricing.price.next.items[0].addons;
|
||||
// $ExpectType string
|
||||
pricing.price.next.items[0].amount;
|
||||
// $ExpectType string
|
||||
pricing.price.next.items[0].id;
|
||||
// $ExpectType string
|
||||
pricing.price.next.items[0].plan;
|
||||
// $ExpectType string
|
||||
pricing.price.next.items[0].setupFee;
|
||||
// $ExpectType string
|
||||
pricing.price.next.items[0].type;
|
||||
// $ExpectType string
|
||||
pricing.price.next.subscriptions;
|
||||
// $ExpectType string
|
||||
pricing.price.next.adjustments;
|
||||
// $ExpectType string
|
||||
pricing.price.next.discount;
|
||||
// $ExpectType string
|
||||
pricing.price.next.subtotal;
|
||||
// $ExpectType string
|
||||
pricing.price.next.taxes;
|
||||
// $ExpectType string
|
||||
pricing.price.next.giftCard;
|
||||
// $ExpectType string
|
||||
pricing.price.next.total;
|
||||
// $ExpectType string
|
||||
pricing.price.currency.code;
|
||||
// $ExpectType string
|
||||
pricing.price.currency.symbol;
|
||||
// $ExpectType string
|
||||
pricing.price.taxes[0].rate;
|
||||
// $ExpectType string
|
||||
pricing.price.taxes[0].region;
|
||||
// $ExpectType string
|
||||
pricing.price.taxes[0].tax_type;
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
export default function checkoutPricing() {
|
||||
export default function subscriptionPricing() {
|
||||
window.recurly.Pricing.Subscription()
|
||||
.plan('basic', { quantity: 1 })
|
||||
.then(x => x)
|
||||
.addon('addon1', { quantity: 2 })
|
||||
.address({
|
||||
first_name: 'dave',
|
||||
last_name: 'b',
|
||||
last_name: 'b'
|
||||
})
|
||||
.address({
|
||||
first_name: 'dave',
|
||||
@ -17,11 +17,11 @@ export default function checkoutPricing() {
|
||||
postal_code: 'postal_code',
|
||||
country: 'country',
|
||||
phone: 'phone',
|
||||
vat_number: 'vat_number',
|
||||
vat_number: 'vat_number'
|
||||
})
|
||||
.shippingAddress({
|
||||
first_name: 'dave',
|
||||
last_name: 'b',
|
||||
last_name: 'b'
|
||||
})
|
||||
.shippingAddress({
|
||||
first_name: 'dave',
|
||||
@ -33,34 +33,76 @@ export default function checkoutPricing() {
|
||||
postal_code: 'postal_code',
|
||||
country: 'country',
|
||||
phone: 'phone',
|
||||
vat_number: 'vat_number',
|
||||
vat_number: 'vat_number'
|
||||
})
|
||||
.coupon('coupon')
|
||||
.currency('USD')
|
||||
.giftcard('giftcard')
|
||||
.tax({
|
||||
tax_code: 'tax_code',
|
||||
tax_code: 'tax_code'
|
||||
})
|
||||
.tax({
|
||||
tax_code: 'tax_code',
|
||||
vat_number: 'vat_number',
|
||||
amounts: {
|
||||
now: 'now',
|
||||
next: 'next',
|
||||
},
|
||||
next: 'next'
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
e.code;
|
||||
e.classification;
|
||||
e.message;
|
||||
e.name;
|
||||
|
||||
// $ExpectError
|
||||
e.fake;
|
||||
})
|
||||
.done(pricing => {
|
||||
if (pricing) {
|
||||
// $ExpectType string
|
||||
pricing.price.now.subtotal;
|
||||
// $ExpectType string
|
||||
pricing.price.now.plan;
|
||||
// $ExpectType string
|
||||
pricing.price.now.addons;
|
||||
// $ExpectType string
|
||||
pricing.price.now.setup_fee;
|
||||
// $ExpectType string
|
||||
pricing.price.now.discount;
|
||||
// $ExpectType string
|
||||
pricing.price.now.tax;
|
||||
// $ExpectType string
|
||||
pricing.price.now.total;
|
||||
// $ExpectType string
|
||||
pricing.price.next.subtotal;
|
||||
// $ExpectType string
|
||||
pricing.price.next.plan;
|
||||
// $ExpectType string
|
||||
pricing.price.next.addons;
|
||||
// $ExpectType string
|
||||
pricing.price.next.setup_fee;
|
||||
// $ExpectType string
|
||||
pricing.price.next.discount;
|
||||
// $ExpectType string
|
||||
pricing.price.next.tax;
|
||||
// $ExpectType string
|
||||
pricing.price.next.total;
|
||||
// $ExpectType string
|
||||
pricing.price.base.plan.unit;
|
||||
// $ExpectType string
|
||||
pricing.price.base.plan.setup_fee;
|
||||
// $ExpectType string
|
||||
pricing.price.base.addons.myAddon;
|
||||
// $ExpectType string
|
||||
pricing.price.addons.myAddon;
|
||||
// $ExpectType string
|
||||
pricing.price.currency.code;
|
||||
// $ExpectType string
|
||||
pricing.price.currency.symbol;
|
||||
// $ExpectType string
|
||||
pricing.price.taxes[0].rate;
|
||||
// $ExpectType string
|
||||
pricing.price.taxes[0].region;
|
||||
// $ExpectType string
|
||||
pricing.price.taxes[0].tax_type;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
export default function hostedFieldToken() {
|
||||
window.recurly.token(document.querySelector('form') as HTMLFormElement, (err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
// $ExpectError
|
||||
token.fake;
|
||||
}
|
||||
});
|
||||
const form = document.querySelector('form');
|
||||
|
||||
// $ExpectError
|
||||
window.recurly.token(document.querySelector('div'), () => {});
|
||||
|
||||
// $ExpectError
|
||||
window.recurly.token((err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
}
|
||||
if (form) {
|
||||
window.recurly.token(form, (err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// $ExpectError
|
||||
window.recurly.token(document.querySelector('div'), () => {});
|
||||
|
||||
// $ExpectError
|
||||
window.recurly.token((err, token) => {
|
||||
if (err) {
|
||||
err.message;
|
||||
err.code;
|
||||
} else {
|
||||
token.id;
|
||||
token.type;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user