Skip to content

Commit 7755f5d

Browse files
Set correct host based on env keys
1 parent e7d5037 commit 7755f5d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "checkout-sdk-node",
3-
"version": "1.0.25",
3+
"version": "1.0.26",
44
"description": "",
55
"main": "./dist/index.js",
66
"devDependencies": {

src/Checkout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default class Checkout {
7575
this.config = {
7676
sk: determineSecretKey(key),
7777
pk: determinePublicKey(options),
78-
host: determineHost(key, options),
78+
host: determineHost(determineSecretKey(key), options),
7979
timeout: options && options.timeout ? options.timeout : DEFAULT_TIMEOUT,
8080
agent: options && options.agent ? options.agent : undefined,
8181
};

test/payments/requestPayment.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ describe('Request a payment or payout', () => {
6666
delete process.env.CKO_PUBLIC_KEY;
6767
});
6868

69+
it('should set the live environment based on env key', () => {
70+
process.env.CKO_SECRET_KEY = 'sk_fghjovernsi764jybiuogokg7xz';
71+
const cko = new Checkout();
72+
expect(cko.config.host).to.equal('https://api.checkout.com');
73+
delete process.env.CKO_SECRET_KEY;
74+
});
75+
76+
it('should set the sandbox environment based on env key', () => {
77+
process.env.CKO_SECRET_KEY = SK;
78+
const cko = new Checkout();
79+
expect(cko.config.host).to.equal('https://api.sandbox.checkout.com');
80+
delete process.env.CKO_SECRET_KEY;
81+
});
82+
6983
it('should determine sandbox environemnt based on key', () => {
7084
const cko = new Checkout(SK);
7185
expect(cko.config.host).to.equal('https://api.sandbox.checkout.com');

0 commit comments

Comments
 (0)