@drawbridge/drawbridge-stripe 0.1.22 → 0.1.24
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.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +170 -15
- package/dist/index.mjs +155 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { request } = require( '@drawbridge/drawbridge-utils/http' );
|
|
2
|
+
|
|
1
3
|
const lib = require( './lib' );
|
|
2
4
|
const stripe = require( 'stripe' )(
|
|
3
5
|
process.env.STRIPE_API_KEY,
|
|
@@ -10,6 +12,9 @@ module.exports = {
|
|
|
10
12
|
billing : lib.billing({
|
|
11
13
|
stripe
|
|
12
14
|
}),
|
|
15
|
+
fx : lib.fx({
|
|
16
|
+
request
|
|
17
|
+
}),
|
|
13
18
|
stripe,
|
|
14
19
|
subscription : lib.subscription({
|
|
15
20
|
stripe
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { request } = require( '@drawbridge/drawbridge-utils/http' );
|
|
2
|
+
|
|
1
3
|
const lib = require( './lib' );
|
|
2
4
|
const stripe = require( 'stripe' )(
|
|
3
5
|
process.env.STRIPE_API_KEY,
|
|
@@ -10,6 +12,9 @@ module.exports = {
|
|
|
10
12
|
billing : lib.billing({
|
|
11
13
|
stripe
|
|
12
14
|
}),
|
|
15
|
+
fx : lib.fx({
|
|
16
|
+
request
|
|
17
|
+
}),
|
|
13
18
|
stripe,
|
|
14
19
|
subscription : lib.subscription({
|
|
15
20
|
stripe
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
6
6
|
// lib/billing.js
|
|
7
7
|
var require_billing = __commonJS({
|
|
8
8
|
"lib/billing.js"(exports2, module2) {
|
|
9
|
-
var { request } = require("@drawbridge/drawbridge-utils/http");
|
|
9
|
+
var { request: request2 } = require("@drawbridge/drawbridge-utils/http");
|
|
10
10
|
var billing = "https://api.stripe.com/v2/billing";
|
|
11
11
|
module2.exports = ({
|
|
12
12
|
stripe: stripe2
|
|
@@ -30,7 +30,7 @@ var require_billing = __commonJS({
|
|
|
30
30
|
};
|
|
31
31
|
const billableItems = async () => {
|
|
32
32
|
var _a;
|
|
33
|
-
const components = await
|
|
33
|
+
const components = await request2({
|
|
34
34
|
url: billing + "/pricing_plans/" + process.env.STRIPE_PRICING_AI_PLAN_ID + "/components",
|
|
35
35
|
headers
|
|
36
36
|
});
|
|
@@ -39,7 +39,7 @@ var require_billing = __commonJS({
|
|
|
39
39
|
return (_a2 = plan == null ? void 0 : plan.rate_card) == null ? void 0 : _a2.id;
|
|
40
40
|
}).filter(Boolean);
|
|
41
41
|
const rateResults = await Promise.all(
|
|
42
|
-
rateCardIds.map((id) =>
|
|
42
|
+
rateCardIds.map((id) => request2({
|
|
43
43
|
url: billing + "/rate_cards/" + id + "/rates",
|
|
44
44
|
headers
|
|
45
45
|
}))
|
|
@@ -76,7 +76,7 @@ var require_billing = __commonJS({
|
|
|
76
76
|
payer.billing_profile_data.default_payment_method = default_payment_method;
|
|
77
77
|
}
|
|
78
78
|
;
|
|
79
|
-
const intent = await
|
|
79
|
+
const intent = await request2({
|
|
80
80
|
method: "POST",
|
|
81
81
|
url: billing + "/intents",
|
|
82
82
|
headers: withIdem(idempotencyKey, "intent.create"),
|
|
@@ -105,19 +105,19 @@ var require_billing = __commonJS({
|
|
|
105
105
|
]
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
|
-
await
|
|
108
|
+
await request2({
|
|
109
109
|
method: "POST",
|
|
110
110
|
url: billing + "/intents/" + (intent == null ? void 0 : intent.id) + "/reserve",
|
|
111
111
|
headers: withIdem(idempotencyKey, "intent.reserve"),
|
|
112
112
|
body: {}
|
|
113
113
|
});
|
|
114
|
-
await
|
|
114
|
+
await request2({
|
|
115
115
|
method: "POST",
|
|
116
116
|
url: billing + "/intents/" + (intent == null ? void 0 : intent.id) + "/commit",
|
|
117
117
|
headers: withIdem(idempotencyKey, "intent.commit"),
|
|
118
118
|
body: {}
|
|
119
119
|
});
|
|
120
|
-
const actions = await
|
|
120
|
+
const actions = await request2({
|
|
121
121
|
url: billing + "/intents/" + (intent == null ? void 0 : intent.id) + "/actions",
|
|
122
122
|
headers
|
|
123
123
|
});
|
|
@@ -178,12 +178,12 @@ var require_billing = __commonJS({
|
|
|
178
178
|
;
|
|
179
179
|
let stripePricingPlanSubscriptionNextBillingDate;
|
|
180
180
|
if (!default_payment_method) {
|
|
181
|
-
const subscription = await
|
|
181
|
+
const subscription = await request2({
|
|
182
182
|
url: billing + "/pricing_plan_subscriptions/" + stripePricingPlanSubscriptionId,
|
|
183
183
|
headers
|
|
184
184
|
});
|
|
185
185
|
if (subscription == null ? void 0 : subscription.billing_cadence) {
|
|
186
|
-
const cadence = await
|
|
186
|
+
const cadence = await request2({
|
|
187
187
|
url: billing + "/cadences/" + subscription.billing_cadence,
|
|
188
188
|
headers
|
|
189
189
|
});
|
|
@@ -211,7 +211,7 @@ var require_billing = __commonJS({
|
|
|
211
211
|
id,
|
|
212
212
|
idempotencyKey
|
|
213
213
|
}) => {
|
|
214
|
-
const data = await
|
|
214
|
+
const data = await request2({
|
|
215
215
|
method: "POST",
|
|
216
216
|
url: billing + "/intents",
|
|
217
217
|
headers: withIdem(idempotencyKey, "intent.create"),
|
|
@@ -230,13 +230,13 @@ var require_billing = __commonJS({
|
|
|
230
230
|
]
|
|
231
231
|
}
|
|
232
232
|
});
|
|
233
|
-
await
|
|
233
|
+
await request2({
|
|
234
234
|
method: "POST",
|
|
235
235
|
url: billing + "/intents/" + (data == null ? void 0 : data.id) + "/reserve",
|
|
236
236
|
headers: withIdem(idempotencyKey, "intent.reserve"),
|
|
237
237
|
body: {}
|
|
238
238
|
});
|
|
239
|
-
const commit = await
|
|
239
|
+
const commit = await request2({
|
|
240
240
|
method: "POST",
|
|
241
241
|
url: billing + "/intents/" + (data == null ? void 0 : data.id) + "/commit",
|
|
242
242
|
headers: withIdem(idempotencyKey, "intent.commit"),
|
|
@@ -290,10 +290,159 @@ var require_billing = __commonJS({
|
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
+
// lib/fx.js
|
|
294
|
+
var require_fx = __commonJS({
|
|
295
|
+
"lib/fx.js"(exports2, module2) {
|
|
296
|
+
"use strict";
|
|
297
|
+
var currencies = {
|
|
298
|
+
aed: "UAE Dirham",
|
|
299
|
+
afn: "Afghan Afghani",
|
|
300
|
+
all: "Albanian Lek",
|
|
301
|
+
amd: "Armenian Dram",
|
|
302
|
+
ang: "Netherlands Antillean Guilder",
|
|
303
|
+
aoa: "Angolan Kwanza",
|
|
304
|
+
aud: "Australian Dollar",
|
|
305
|
+
awg: "Aruban Florin",
|
|
306
|
+
azn: "Azerbaijani Manat",
|
|
307
|
+
bam: "Bosnia-Herzegovina Convertible Mark",
|
|
308
|
+
bbd: "Barbadian Dollar",
|
|
309
|
+
bdt: "Bangladeshi Taka",
|
|
310
|
+
bhd: "Bahraini Dinar",
|
|
311
|
+
bif: "Burundian Franc",
|
|
312
|
+
bmd: "Bermudian Dollar",
|
|
313
|
+
bnd: "Brunei Dollar",
|
|
314
|
+
bob: "Bolivian Boliviano",
|
|
315
|
+
brl: "Brazilian Real",
|
|
316
|
+
bsd: "Bahamian Dollar",
|
|
317
|
+
bwp: "Botswana Pula",
|
|
318
|
+
bzd: "Belize Dollar",
|
|
319
|
+
cad: "Canadian Dollar",
|
|
320
|
+
chf: "Swiss Franc",
|
|
321
|
+
clp: "Chilean Peso",
|
|
322
|
+
cny: "Chinese Yuan",
|
|
323
|
+
cop: "Colombian Peso",
|
|
324
|
+
crc: "Costa Rican Col\xF3n",
|
|
325
|
+
cve: "Cape Verdean Escudo",
|
|
326
|
+
czk: "Czech Koruna",
|
|
327
|
+
djf: "Djiboutian Franc",
|
|
328
|
+
dkk: "Danish Krone",
|
|
329
|
+
dop: "Dominican Peso",
|
|
330
|
+
dzd: "Algerian Dinar",
|
|
331
|
+
eur: "Euro",
|
|
332
|
+
fkp: "Falkland Islands Pound",
|
|
333
|
+
gbp: "British Pound",
|
|
334
|
+
gel: "Georgian Lari",
|
|
335
|
+
gip: "Gibraltar Pound",
|
|
336
|
+
gmd: "Gambian Dalasi",
|
|
337
|
+
gnf: "Guinean Franc",
|
|
338
|
+
gtq: "Guatemalan Quetzal",
|
|
339
|
+
gyd: "Guyanese Dollar",
|
|
340
|
+
hkd: "Hong Kong Dollar",
|
|
341
|
+
hnl: "Honduran Lempira",
|
|
342
|
+
htg: "Haitian Gourde",
|
|
343
|
+
huf: "Hungarian Forint",
|
|
344
|
+
idr: "Indonesian Rupiah",
|
|
345
|
+
ils: "Israeli New Shekel",
|
|
346
|
+
inr: "Indian Rupee",
|
|
347
|
+
isk: "Icelandic Kr\xF3na",
|
|
348
|
+
jmd: "Jamaican Dollar",
|
|
349
|
+
jod: "Jordanian Dinar",
|
|
350
|
+
jpy: "Japanese Yen",
|
|
351
|
+
kes: "Kenyan Shilling",
|
|
352
|
+
kgs: "Kyrgyzstani Som",
|
|
353
|
+
khr: "Cambodian Riel",
|
|
354
|
+
krw: "South Korean Won",
|
|
355
|
+
kwd: "Kuwaiti Dinar",
|
|
356
|
+
kyd: "Cayman Islands Dollar",
|
|
357
|
+
kzt: "Kazakhstani Tenge",
|
|
358
|
+
lkr: "Sri Lankan Rupee",
|
|
359
|
+
lrd: "Liberian Dollar",
|
|
360
|
+
mad: "Moroccan Dirham",
|
|
361
|
+
mdl: "Moldovan Leu",
|
|
362
|
+
mga: "Malagasy Ariary",
|
|
363
|
+
mkd: "Macedonian Denar",
|
|
364
|
+
mnt: "Mongolian T\xF6gr\xF6g",
|
|
365
|
+
mop: "Macanese Pataca",
|
|
366
|
+
mur: "Mauritian Rupee",
|
|
367
|
+
mvr: "Maldivian Rufiyaa",
|
|
368
|
+
mxn: "Mexican Peso",
|
|
369
|
+
myr: "Malaysian Ringgit",
|
|
370
|
+
mzn: "Mozambican Metical",
|
|
371
|
+
nad: "Namibian Dollar",
|
|
372
|
+
nok: "Norwegian Krone",
|
|
373
|
+
npr: "Nepalese Rupee",
|
|
374
|
+
nzd: "New Zealand Dollar",
|
|
375
|
+
omr: "Omani Rial",
|
|
376
|
+
pab: "Panamanian Balboa",
|
|
377
|
+
pen: "Peruvian Sol",
|
|
378
|
+
php: "Philippine Peso",
|
|
379
|
+
pkr: "Pakistani Rupee",
|
|
380
|
+
pln: "Polish Z\u0142oty",
|
|
381
|
+
pyg: "Paraguayan Guaran\xED",
|
|
382
|
+
qar: "Qatari Riyal",
|
|
383
|
+
ron: "Romanian Leu",
|
|
384
|
+
rsd: "Serbian Dinar",
|
|
385
|
+
rwf: "Rwandan Franc",
|
|
386
|
+
sar: "Saudi Riyal",
|
|
387
|
+
sek: "Swedish Krona",
|
|
388
|
+
sgd: "Singapore Dollar",
|
|
389
|
+
shp: "Saint Helena Pound",
|
|
390
|
+
std: "S\xE3o Tom\xE9 and Pr\xEDncipe Dobra",
|
|
391
|
+
thb: "Thai Baht",
|
|
392
|
+
tjs: "Tajikistani Somoni",
|
|
393
|
+
tnd: "Tunisian Dinar",
|
|
394
|
+
try: "Turkish Lira",
|
|
395
|
+
ttd: "Trinidad and Tobago Dollar",
|
|
396
|
+
twd: "New Taiwan Dollar",
|
|
397
|
+
tzs: "Tanzanian Shilling",
|
|
398
|
+
uah: "Ukrainian Hryvnia",
|
|
399
|
+
ugx: "Ugandan Shilling",
|
|
400
|
+
usd: "US Dollar",
|
|
401
|
+
uyu: "Uruguayan Peso",
|
|
402
|
+
uzs: "Uzbekistani Som",
|
|
403
|
+
vnd: "Vietnamese \u0110\u1ED3ng",
|
|
404
|
+
xaf: "Central African CFA Franc",
|
|
405
|
+
xcd: "East Caribbean Dollar",
|
|
406
|
+
xof: "West African CFA Franc",
|
|
407
|
+
xpf: "CFP Franc",
|
|
408
|
+
yer: "Yemeni Rial",
|
|
409
|
+
zar: "South African Rand",
|
|
410
|
+
zmw: "Zambian Kwacha"
|
|
411
|
+
};
|
|
412
|
+
module2.exports = ({ request: request2 }) => ({
|
|
413
|
+
currencies,
|
|
414
|
+
quote: async ({ from, to, lock = "five_minutes" }) => {
|
|
415
|
+
if (from === to) {
|
|
416
|
+
return { rate: 1, quoteId: null };
|
|
417
|
+
}
|
|
418
|
+
const auth = Buffer.from(process.env.STRIPE_API_KEY + ":").toString("base64");
|
|
419
|
+
const response = await request2({
|
|
420
|
+
body: {
|
|
421
|
+
to_currency: to,
|
|
422
|
+
"from_currencies[]": from,
|
|
423
|
+
lock_duration: lock
|
|
424
|
+
},
|
|
425
|
+
headers: {
|
|
426
|
+
"Authorization": "Basic " + auth,
|
|
427
|
+
"Stripe-Version": "2026-01-28.preview"
|
|
428
|
+
},
|
|
429
|
+
method: "POST",
|
|
430
|
+
type: "form",
|
|
431
|
+
url: "https://api.stripe.com/v1/fx_quotes"
|
|
432
|
+
});
|
|
433
|
+
return {
|
|
434
|
+
rate: response.rates[from].exchange_rate,
|
|
435
|
+
quoteId: response.id
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
|
|
293
442
|
// lib/subscription.js
|
|
294
443
|
var require_subscription = __commonJS({
|
|
295
444
|
"lib/subscription.js"(exports2, module2) {
|
|
296
|
-
var { request } = require("@drawbridge/drawbridge-utils/http");
|
|
445
|
+
var { request: request2 } = require("@drawbridge/drawbridge-utils/http");
|
|
297
446
|
var subscriptions = "https://api.stripe.com/v1/subscriptions";
|
|
298
447
|
module2.exports = ({
|
|
299
448
|
stripe: stripe2
|
|
@@ -686,7 +835,7 @@ var require_subscription = __commonJS({
|
|
|
686
835
|
idempotencyKey,
|
|
687
836
|
stripeSubscriptionId
|
|
688
837
|
}) => {
|
|
689
|
-
return await
|
|
838
|
+
return await request2({
|
|
690
839
|
method: "POST",
|
|
691
840
|
url: subscriptions + "/" + stripeSubscriptionId + "/pause",
|
|
692
841
|
type: "form",
|
|
@@ -708,7 +857,7 @@ var require_subscription = __commonJS({
|
|
|
708
857
|
idempotencyKey,
|
|
709
858
|
stripeSubscriptionId
|
|
710
859
|
}) => {
|
|
711
|
-
return await
|
|
860
|
+
return await request2({
|
|
712
861
|
method: "POST",
|
|
713
862
|
url: subscriptions + "/" + stripeSubscriptionId + "/resume",
|
|
714
863
|
type: "form",
|
|
@@ -1038,15 +1187,18 @@ var require_subscription = __commonJS({
|
|
|
1038
1187
|
var require_lib = __commonJS({
|
|
1039
1188
|
"lib/index.js"(exports2, module2) {
|
|
1040
1189
|
var billing = require_billing();
|
|
1190
|
+
var fx = require_fx();
|
|
1041
1191
|
var subscription = require_subscription();
|
|
1042
1192
|
module2.exports = {
|
|
1043
1193
|
billing,
|
|
1194
|
+
fx,
|
|
1044
1195
|
subscription
|
|
1045
1196
|
};
|
|
1046
1197
|
}
|
|
1047
1198
|
});
|
|
1048
1199
|
|
|
1049
1200
|
// index.js
|
|
1201
|
+
var { request } = require("@drawbridge/drawbridge-utils/http");
|
|
1050
1202
|
var lib = require_lib();
|
|
1051
1203
|
var stripe = require("stripe")(
|
|
1052
1204
|
process.env.STRIPE_API_KEY,
|
|
@@ -1058,6 +1210,9 @@ module.exports = {
|
|
|
1058
1210
|
billing: lib.billing({
|
|
1059
1211
|
stripe
|
|
1060
1212
|
}),
|
|
1213
|
+
fx: lib.fx({
|
|
1214
|
+
request
|
|
1215
|
+
}),
|
|
1061
1216
|
stripe,
|
|
1062
1217
|
subscription: lib.subscription({
|
|
1063
1218
|
stripe
|
package/dist/index.mjs
CHANGED
|
@@ -296,6 +296,155 @@ var require_billing = __commonJS({
|
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
+
// lib/fx.js
|
|
300
|
+
var require_fx = __commonJS({
|
|
301
|
+
"lib/fx.js"(exports, module) {
|
|
302
|
+
"use strict";
|
|
303
|
+
var currencies = {
|
|
304
|
+
aed: "UAE Dirham",
|
|
305
|
+
afn: "Afghan Afghani",
|
|
306
|
+
all: "Albanian Lek",
|
|
307
|
+
amd: "Armenian Dram",
|
|
308
|
+
ang: "Netherlands Antillean Guilder",
|
|
309
|
+
aoa: "Angolan Kwanza",
|
|
310
|
+
aud: "Australian Dollar",
|
|
311
|
+
awg: "Aruban Florin",
|
|
312
|
+
azn: "Azerbaijani Manat",
|
|
313
|
+
bam: "Bosnia-Herzegovina Convertible Mark",
|
|
314
|
+
bbd: "Barbadian Dollar",
|
|
315
|
+
bdt: "Bangladeshi Taka",
|
|
316
|
+
bhd: "Bahraini Dinar",
|
|
317
|
+
bif: "Burundian Franc",
|
|
318
|
+
bmd: "Bermudian Dollar",
|
|
319
|
+
bnd: "Brunei Dollar",
|
|
320
|
+
bob: "Bolivian Boliviano",
|
|
321
|
+
brl: "Brazilian Real",
|
|
322
|
+
bsd: "Bahamian Dollar",
|
|
323
|
+
bwp: "Botswana Pula",
|
|
324
|
+
bzd: "Belize Dollar",
|
|
325
|
+
cad: "Canadian Dollar",
|
|
326
|
+
chf: "Swiss Franc",
|
|
327
|
+
clp: "Chilean Peso",
|
|
328
|
+
cny: "Chinese Yuan",
|
|
329
|
+
cop: "Colombian Peso",
|
|
330
|
+
crc: "Costa Rican Col\xF3n",
|
|
331
|
+
cve: "Cape Verdean Escudo",
|
|
332
|
+
czk: "Czech Koruna",
|
|
333
|
+
djf: "Djiboutian Franc",
|
|
334
|
+
dkk: "Danish Krone",
|
|
335
|
+
dop: "Dominican Peso",
|
|
336
|
+
dzd: "Algerian Dinar",
|
|
337
|
+
eur: "Euro",
|
|
338
|
+
fkp: "Falkland Islands Pound",
|
|
339
|
+
gbp: "British Pound",
|
|
340
|
+
gel: "Georgian Lari",
|
|
341
|
+
gip: "Gibraltar Pound",
|
|
342
|
+
gmd: "Gambian Dalasi",
|
|
343
|
+
gnf: "Guinean Franc",
|
|
344
|
+
gtq: "Guatemalan Quetzal",
|
|
345
|
+
gyd: "Guyanese Dollar",
|
|
346
|
+
hkd: "Hong Kong Dollar",
|
|
347
|
+
hnl: "Honduran Lempira",
|
|
348
|
+
htg: "Haitian Gourde",
|
|
349
|
+
huf: "Hungarian Forint",
|
|
350
|
+
idr: "Indonesian Rupiah",
|
|
351
|
+
ils: "Israeli New Shekel",
|
|
352
|
+
inr: "Indian Rupee",
|
|
353
|
+
isk: "Icelandic Kr\xF3na",
|
|
354
|
+
jmd: "Jamaican Dollar",
|
|
355
|
+
jod: "Jordanian Dinar",
|
|
356
|
+
jpy: "Japanese Yen",
|
|
357
|
+
kes: "Kenyan Shilling",
|
|
358
|
+
kgs: "Kyrgyzstani Som",
|
|
359
|
+
khr: "Cambodian Riel",
|
|
360
|
+
krw: "South Korean Won",
|
|
361
|
+
kwd: "Kuwaiti Dinar",
|
|
362
|
+
kyd: "Cayman Islands Dollar",
|
|
363
|
+
kzt: "Kazakhstani Tenge",
|
|
364
|
+
lkr: "Sri Lankan Rupee",
|
|
365
|
+
lrd: "Liberian Dollar",
|
|
366
|
+
mad: "Moroccan Dirham",
|
|
367
|
+
mdl: "Moldovan Leu",
|
|
368
|
+
mga: "Malagasy Ariary",
|
|
369
|
+
mkd: "Macedonian Denar",
|
|
370
|
+
mnt: "Mongolian T\xF6gr\xF6g",
|
|
371
|
+
mop: "Macanese Pataca",
|
|
372
|
+
mur: "Mauritian Rupee",
|
|
373
|
+
mvr: "Maldivian Rufiyaa",
|
|
374
|
+
mxn: "Mexican Peso",
|
|
375
|
+
myr: "Malaysian Ringgit",
|
|
376
|
+
mzn: "Mozambican Metical",
|
|
377
|
+
nad: "Namibian Dollar",
|
|
378
|
+
nok: "Norwegian Krone",
|
|
379
|
+
npr: "Nepalese Rupee",
|
|
380
|
+
nzd: "New Zealand Dollar",
|
|
381
|
+
omr: "Omani Rial",
|
|
382
|
+
pab: "Panamanian Balboa",
|
|
383
|
+
pen: "Peruvian Sol",
|
|
384
|
+
php: "Philippine Peso",
|
|
385
|
+
pkr: "Pakistani Rupee",
|
|
386
|
+
pln: "Polish Z\u0142oty",
|
|
387
|
+
pyg: "Paraguayan Guaran\xED",
|
|
388
|
+
qar: "Qatari Riyal",
|
|
389
|
+
ron: "Romanian Leu",
|
|
390
|
+
rsd: "Serbian Dinar",
|
|
391
|
+
rwf: "Rwandan Franc",
|
|
392
|
+
sar: "Saudi Riyal",
|
|
393
|
+
sek: "Swedish Krona",
|
|
394
|
+
sgd: "Singapore Dollar",
|
|
395
|
+
shp: "Saint Helena Pound",
|
|
396
|
+
std: "S\xE3o Tom\xE9 and Pr\xEDncipe Dobra",
|
|
397
|
+
thb: "Thai Baht",
|
|
398
|
+
tjs: "Tajikistani Somoni",
|
|
399
|
+
tnd: "Tunisian Dinar",
|
|
400
|
+
try: "Turkish Lira",
|
|
401
|
+
ttd: "Trinidad and Tobago Dollar",
|
|
402
|
+
twd: "New Taiwan Dollar",
|
|
403
|
+
tzs: "Tanzanian Shilling",
|
|
404
|
+
uah: "Ukrainian Hryvnia",
|
|
405
|
+
ugx: "Ugandan Shilling",
|
|
406
|
+
usd: "US Dollar",
|
|
407
|
+
uyu: "Uruguayan Peso",
|
|
408
|
+
uzs: "Uzbekistani Som",
|
|
409
|
+
vnd: "Vietnamese \u0110\u1ED3ng",
|
|
410
|
+
xaf: "Central African CFA Franc",
|
|
411
|
+
xcd: "East Caribbean Dollar",
|
|
412
|
+
xof: "West African CFA Franc",
|
|
413
|
+
xpf: "CFP Franc",
|
|
414
|
+
yer: "Yemeni Rial",
|
|
415
|
+
zar: "South African Rand",
|
|
416
|
+
zmw: "Zambian Kwacha"
|
|
417
|
+
};
|
|
418
|
+
module.exports = ({ request }) => ({
|
|
419
|
+
currencies,
|
|
420
|
+
quote: async ({ from, to, lock = "five_minutes" }) => {
|
|
421
|
+
if (from === to) {
|
|
422
|
+
return { rate: 1, quoteId: null };
|
|
423
|
+
}
|
|
424
|
+
const auth = Buffer.from(process.env.STRIPE_API_KEY + ":").toString("base64");
|
|
425
|
+
const response = await request({
|
|
426
|
+
body: {
|
|
427
|
+
to_currency: to,
|
|
428
|
+
"from_currencies[]": from,
|
|
429
|
+
lock_duration: lock
|
|
430
|
+
},
|
|
431
|
+
headers: {
|
|
432
|
+
"Authorization": "Basic " + auth,
|
|
433
|
+
"Stripe-Version": "2026-01-28.preview"
|
|
434
|
+
},
|
|
435
|
+
method: "POST",
|
|
436
|
+
type: "form",
|
|
437
|
+
url: "https://api.stripe.com/v1/fx_quotes"
|
|
438
|
+
});
|
|
439
|
+
return {
|
|
440
|
+
rate: response.rates[from].exchange_rate,
|
|
441
|
+
quoteId: response.id
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
299
448
|
// lib/subscription.js
|
|
300
449
|
var require_subscription = __commonJS({
|
|
301
450
|
"lib/subscription.js"(exports, module) {
|
|
@@ -1044,9 +1193,11 @@ var require_subscription = __commonJS({
|
|
|
1044
1193
|
var require_lib = __commonJS({
|
|
1045
1194
|
"lib/index.js"(exports, module) {
|
|
1046
1195
|
var billing = require_billing();
|
|
1196
|
+
var fx = require_fx();
|
|
1047
1197
|
var subscription = require_subscription();
|
|
1048
1198
|
module.exports = {
|
|
1049
1199
|
billing,
|
|
1200
|
+
fx,
|
|
1050
1201
|
subscription
|
|
1051
1202
|
};
|
|
1052
1203
|
}
|
|
@@ -1055,6 +1206,7 @@ var require_lib = __commonJS({
|
|
|
1055
1206
|
// index.js
|
|
1056
1207
|
var require_index = __commonJS({
|
|
1057
1208
|
"index.js"(exports, module) {
|
|
1209
|
+
var { request } = __require("@drawbridge/drawbridge-utils/http");
|
|
1058
1210
|
var lib = require_lib();
|
|
1059
1211
|
var stripe = __require("stripe")(
|
|
1060
1212
|
process.env.STRIPE_API_KEY,
|
|
@@ -1066,6 +1218,9 @@ var require_index = __commonJS({
|
|
|
1066
1218
|
billing: lib.billing({
|
|
1067
1219
|
stripe
|
|
1068
1220
|
}),
|
|
1221
|
+
fx: lib.fx({
|
|
1222
|
+
request
|
|
1223
|
+
}),
|
|
1069
1224
|
stripe,
|
|
1070
1225
|
subscription: lib.subscription({
|
|
1071
1226
|
stripe
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@drawbridge/drawbridge-agents": "0.0.
|
|
4
|
-
"@drawbridge/drawbridge-utils": "0.0.
|
|
3
|
+
"@drawbridge/drawbridge-agents": "0.0.10",
|
|
4
|
+
"@drawbridge/drawbridge-utils": "0.0.26",
|
|
5
5
|
"stripe": "20.4.0",
|
|
6
6
|
"tsup": "8.5.1",
|
|
7
7
|
"typescript": "5.9.3"
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"build": "tsup ./index.js && npm publish"
|
|
27
27
|
},
|
|
28
28
|
"types": "dist/index.d.ts",
|
|
29
|
-
"version": "0.1.
|
|
29
|
+
"version": "0.1.24"
|
|
30
30
|
}
|