mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
⚡ Enable sandbox env in Paddle (#1777)
* Enable sandbox env in Paddle * Change sandbox option displayName
This commit is contained in:
parent
6460ce3965
commit
779da62845
|
@ -20,5 +20,11 @@ export class PaddleApi implements ICredentialType {
|
||||||
type: 'string' as NodePropertyTypes,
|
type: 'string' as NodePropertyTypes,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Use Sandbox environment API',
|
||||||
|
name: 'sandbox',
|
||||||
|
type: 'boolean' as NodePropertyTypes,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,21 @@ import {
|
||||||
|
|
||||||
export async function paddleApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
export async function paddleApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = this.getCredentials('paddleApi');
|
const credentials = this.getCredentials('paddleApi');
|
||||||
|
const productionUrl = 'https://vendors.paddle.com/api';
|
||||||
|
const sandboxUrl = 'https://sandbox-vendors.paddle.com/api';
|
||||||
|
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'Could not retrieve credentials!');
|
throw new NodeOperationError(this.getNode(), 'Could not retrieve credentials!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isSandbox = credentials.sandbox;
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
},
|
},
|
||||||
uri: `https://vendors.paddle.com/api${endpoint}`,
|
uri: `${isSandbox === true ? sandboxUrl : productionUrl}${endpoint}`,
|
||||||
body,
|
body,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue