Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
• Add documentation about `available_refund_amount_insufficient` error • Allow updating `retry_if_possible` field on subscriptions • Added support for applying tax to transaction and surcharge fees. • Added `taxes` to payout_items. • Added `tax_currency` to payout. • Added `tax_rates` endpoint. • Added a `payout tax_exchange_rates_confirmed` webhook to know when the exchange rate has been finalised for all fees in the payout.
- Loading branch information
1 parent
fecd564
commit 2fcfb14
Showing
11 changed files
with
421 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
'use strict'; | ||
|
||
import { Api } from '../api/api'; | ||
import * as Types from '../types/Types'; | ||
|
||
interface TaxRateResponse extends Types.TaxRate, Types.APIResponse {} | ||
|
||
interface TaxRateListResponse extends Types.APIResponse { | ||
tax_rates: Types.TaxRate[]; | ||
meta: Types.ListMeta; | ||
} | ||
|
||
interface TaxRateListRequest { | ||
// Cursor pointing to the start of the desired set. | ||
after?: string; | ||
|
||
// Cursor pointing to the end of the desired set. | ||
before?: string; | ||
|
||
// The jurisdiction this tax rate applies to | ||
jurisdiction?: string; | ||
} | ||
|
||
export class TaxRateService { | ||
private api: Api; | ||
|
||
constructor(api) { | ||
this.api = api; | ||
} | ||
|
||
async list( | ||
requestParameters: TaxRateListRequest | ||
): Promise<TaxRateListResponse> { | ||
const urlParameters = []; | ||
const requestParams = { | ||
path: '/tax_rates', | ||
method: 'get', | ||
urlParameters, | ||
requestParameters, | ||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: TaxRateListResponse = { | ||
...response.body, | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
|
||
async *all( | ||
requestParameters: TaxRateListRequest | ||
): AsyncGenerator<Types.TaxRate, void, unknown> { | ||
let cursor = undefined; | ||
do { | ||
const list = await this.list({ ...requestParameters, after: cursor }); | ||
|
||
for (const taxrate of list.tax_rates) { | ||
yield taxrate; | ||
} | ||
|
||
cursor = list.meta.cursors.after; | ||
} while (cursor); | ||
} | ||
|
||
async find(identity: string): Promise<TaxRateResponse> { | ||
const urlParameters = [{ key: 'identity', value: identity }]; | ||
const requestParams = { | ||
path: '/tax_rates/:identity', | ||
method: 'get', | ||
urlParameters, | ||
|
||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: TaxRateResponse = { | ||
...response.body['tax_rates'], | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
} |
Oops, something went wrong.