🤖 Merge PR #45509 Stripe - Subscriptions Transfer Data Definition by @asithade

* Subscription Transfer Data Definition

* Missing Semi-colon

* Added Test & Fixed Optional Field
This commit is contained in:
Asitha de Silva 2020-06-28 12:57:19 -07:00 committed by GitHub
parent 30efa4bd9f
commit 5572603010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -35,6 +35,7 @@
// Collin Pham <https://github.com/collin-pham>
// Timon van Spronsen <https://github.com/TimonVS>
// Sean Chen <https://github.com/kamiyo>
// Asitha de Silva <https://github.com/asithade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -10650,6 +10651,22 @@ declare namespace Stripe {
* Indicates if a customer is on or off-session while an invoice payment is attempted.
*/
off_session?: boolean;
/**
* If specified, the funds from the subscriptions invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.
*/
transfer_data?: {
/**
* ID of an existing, connected Stripe account.
*/
destination: string;
/**
* A non-negative decimal between 0 and 100, with at most two decimal places.
* This represents the percentage of the subscription invoice subtotal that will be transferred to the destination account.
* By default, the entire amount is transferred to the destination.
*/
amount_percent?: number;
};
}
interface ISubscriptionCreationOptions extends ISubscriptionCustCreationOptions {

View File

@ -543,6 +543,9 @@ stripe.customers
customer.subscriptions
.create({ items: [{ plan: 'gold' }], billing: 'charge_automatically' })
.then(subscription => {});
customer.subscriptions
.create({ items: [{ plan: 'gold' }], transfer_data: { destination: 'acct_17wV8KBoqMA9o2xk' }})
.then(subscription => {});
customer.subscriptions.retrieve('sub_8Eluur5KoIKxuy').then(subscription => {
customer.subscriptions
.update('sub_8Eluur5KoIKxuy', { items: [{ id: subscription.items.data[0].id, plan: 'silver' }] })