@lavapayments/nodejs 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -159,7 +159,7 @@ var Lava = class {
|
|
|
159
159
|
constructor(secretKey, config) {
|
|
160
160
|
this.secretKey = secretKey;
|
|
161
161
|
this.apiVersion = config.apiVersion;
|
|
162
|
-
const isTestMode = secretKey.startsWith("
|
|
162
|
+
const isTestMode = secretKey.startsWith("aks_test_");
|
|
163
163
|
this.baseUrl = config.baseUrl || (isTestMode ? "https://sandbox-api.lavapayments.com/v1/" : "https://api.lavapayments.com/v1/");
|
|
164
164
|
this.checkout = new Resources.CheckoutResource(this);
|
|
165
165
|
this.connections = new Resources.ConnectionsResource(this);
|
|
@@ -202,8 +202,9 @@ var Lava = class {
|
|
|
202
202
|
const response = await fetch(url.toString(), requestOptions);
|
|
203
203
|
if (!response.ok) {
|
|
204
204
|
const errorJson = await response.json().catch(() => ({}));
|
|
205
|
+
const errorMessage = typeof errorJson.error === "object" ? JSON.stringify(errorJson.error) : errorJson.error || "Unknown error";
|
|
205
206
|
throw new Error(
|
|
206
|
-
`Lava API Error: ${response.status} ${response.statusText} - ${
|
|
207
|
+
`Lava API Error: ${response.status} ${response.statusText} - ${errorMessage}`
|
|
207
208
|
);
|
|
208
209
|
}
|
|
209
210
|
return response.json();
|
package/dist/index.mjs
CHANGED
|
@@ -132,7 +132,7 @@ var Lava = class {
|
|
|
132
132
|
constructor(secretKey, config) {
|
|
133
133
|
this.secretKey = secretKey;
|
|
134
134
|
this.apiVersion = config.apiVersion;
|
|
135
|
-
const isTestMode = secretKey.startsWith("
|
|
135
|
+
const isTestMode = secretKey.startsWith("aks_test_");
|
|
136
136
|
this.baseUrl = config.baseUrl || (isTestMode ? "https://sandbox-api.lavapayments.com/v1/" : "https://api.lavapayments.com/v1/");
|
|
137
137
|
this.checkout = new Resources.CheckoutResource(this);
|
|
138
138
|
this.connections = new Resources.ConnectionsResource(this);
|
|
@@ -175,8 +175,9 @@ var Lava = class {
|
|
|
175
175
|
const response = await fetch(url.toString(), requestOptions);
|
|
176
176
|
if (!response.ok) {
|
|
177
177
|
const errorJson = await response.json().catch(() => ({}));
|
|
178
|
+
const errorMessage = typeof errorJson.error === "object" ? JSON.stringify(errorJson.error) : errorJson.error || "Unknown error";
|
|
178
179
|
throw new Error(
|
|
179
|
-
`Lava API Error: ${response.status} ${response.statusText} - ${
|
|
180
|
+
`Lava API Error: ${response.status} ${response.statusText} - ${errorMessage}`
|
|
180
181
|
);
|
|
181
182
|
}
|
|
182
183
|
return response.json();
|