Skip to content

Commit

Permalink
Merge pull request stripe#1042 from stripe/remi/codegen-4bd4c01
Browse files Browse the repository at this point in the history
Add support for the Payout Reverse API
  • Loading branch information
remi-stripe authored Oct 14, 2020
2 parents fcda014 + cc1cf6e commit 93cdffd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/resources/Payouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ module.exports = StripeResource.extend({
method: 'POST',
path: '/{payout}/cancel',
}),

reverse: stripeMethod({
method: 'POST',
path: '/{payout}/reverse',
}),
});
13 changes: 13 additions & 0 deletions test/resources/Payouts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,17 @@ describe('Payouts Resource', () => {
});
});
});

describe('reverse', () => {
it('Sends the correct request', () => {
stripe.payouts.reverse(PAYOUT_TEST_ID);
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: `/v1/payouts/${PAYOUT_TEST_ID}/reverse`,
headers: {},
data: {},
settings: {},
});
});
});
});
37 changes: 37 additions & 0 deletions types/2020-08-27/Payouts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ declare module 'stripe' {
*/
method: string;

/**
* If the payout reverses another, this is the ID of the original payout.
*/
original_payout?: string | Stripe.Payout | null;

/**
* If the payout was reversed, this is the ID of the payout that reverses this payout.
*/
reversed_by?: string | Stripe.Payout | null;

/**
* The source balance this payout came from. One of `card`, `fpx`, or `bank_account`.
*/
Expand Down Expand Up @@ -216,6 +226,18 @@ declare module 'stripe' {
expand?: Array<string>;
}

interface PayoutReverseParams {
/**
* Specifies which fields in the response should be expanded.
*/
expand?: Array<string>;

/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: MetadataParam;
}

class PayoutsResource {
/**
* To send funds to your own bank account, you create a new payout object. Your [Stripe balance](https://stripe.com/docs/api#balance) must be able to cover the payout amount, or you'll receive an “Insufficient Funds” error.
Expand Down Expand Up @@ -272,6 +294,21 @@ declare module 'stripe' {
id: string,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Payout>>;

/**
* Reverses a payout by debiting the destination bank account. Only payouts for connected accounts to US bank accounts may be reversed at this time. If the payout is in the pending status, /v1/payouts/:id/cancel should be used instead.
*
* By requesting a reversal via /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account has authorized the debit on the bank account and that no other authorization is required.
*/
reverse(
id: string,
params?: PayoutReverseParams,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Payout>>;
reverse(
id: string,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Payout>>;
}
}
}

0 comments on commit 93cdffd

Please sign in to comment.