@kuvarpay/sdk 1.2.1 → 1.2.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/index.js +8 -10
- package/index.mjs +6 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -221,13 +221,14 @@ class KuvarPayServer {
|
|
|
221
221
|
const payload = Object.assign({}, checkoutSessionData, {
|
|
222
222
|
businessId: checkoutSessionData.businessId || this.businessId,
|
|
223
223
|
});
|
|
224
|
-
// payload can include 'subaccount' (string) or 'split_code' (string)
|
|
225
|
-
// Guide says /api/v1/checkout-sessions
|
|
226
224
|
const data = await this._post('/api/v1/checkout-sessions', payload);
|
|
225
|
+
const body = data.data || data.checkoutSession || data;
|
|
227
226
|
return {
|
|
228
|
-
sessionId:
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
sessionId: body.sessionId || body.id || body.uid,
|
|
228
|
+
amount: body.amount,
|
|
229
|
+
currency: body.currency,
|
|
230
|
+
authToken: body.authToken,
|
|
231
|
+
approvalUrl: body.approvalUrl || body.approval_url,
|
|
231
232
|
raw: data,
|
|
232
233
|
};
|
|
233
234
|
}
|
|
@@ -274,15 +275,12 @@ class KuvarPayServer {
|
|
|
274
275
|
|
|
275
276
|
const session = await this.createCheckoutSession(sessionData);
|
|
276
277
|
|
|
277
|
-
// 2. Create Transaction using the
|
|
278
|
+
// 2. Create Transaction using the session. We omit toAmount/toCurrency
|
|
279
|
+
// to let the API use the values already locked into the session.
|
|
278
280
|
const transactionData = {
|
|
279
281
|
checkoutSessionId: session.sessionId,
|
|
280
282
|
fromCurrency: data.fromCurrency,
|
|
281
283
|
fromNetwork: data.fromNetwork,
|
|
282
|
-
toCurrency: data.toCurrency || data.currency,
|
|
283
|
-
toAmount: data.toAmount || data.amount,
|
|
284
|
-
subaccountCode: data.subaccountCode || data.subaccount,
|
|
285
|
-
splitCode: data.splitCode || data.split_code,
|
|
286
284
|
description: data.description,
|
|
287
285
|
metadata: data.metadata,
|
|
288
286
|
};
|
package/index.mjs
CHANGED
|
@@ -164,12 +164,14 @@ export class KuvarPayServer {
|
|
|
164
164
|
const payload = Object.assign({}, checkoutSessionData, {
|
|
165
165
|
businessId: checkoutSessionData.businessId || this.businessId,
|
|
166
166
|
});
|
|
167
|
-
// payload can include 'subaccount' (string) or 'split_code' (string)
|
|
168
167
|
const data = await this._post('/api/v1/checkout-sessions', payload);
|
|
168
|
+
const body = data.data || data.checkoutSession || data;
|
|
169
169
|
return {
|
|
170
|
-
sessionId:
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
sessionId: body.sessionId || body.id || body.uid,
|
|
171
|
+
amount: body.amount,
|
|
172
|
+
currency: body.currency,
|
|
173
|
+
authToken: body.authToken,
|
|
174
|
+
approvalUrl: body.approvalUrl || body.approval_url,
|
|
173
175
|
raw: data,
|
|
174
176
|
};
|
|
175
177
|
}
|
|
@@ -208,10 +210,6 @@ export class KuvarPayServer {
|
|
|
208
210
|
checkoutSessionId: session.sessionId,
|
|
209
211
|
fromCurrency: data.fromCurrency,
|
|
210
212
|
fromNetwork: data.fromNetwork,
|
|
211
|
-
toCurrency: data.toCurrency || data.currency,
|
|
212
|
-
toAmount: data.toAmount || data.amount,
|
|
213
|
-
subaccountCode: data.subaccountCode || data.subaccount,
|
|
214
|
-
splitCode: data.splitCode || data.split_code,
|
|
215
213
|
description: data.description,
|
|
216
214
|
metadata: data.metadata,
|
|
217
215
|
};
|