@@ -13,6 +13,7 @@ import { Response } from 'node-fetch'
13
13
14
14
import {
15
15
EDGE_APP_START_DATE ,
16
+ FiatPaymentType ,
16
17
PartnerPlugin ,
17
18
PluginParams ,
18
19
PluginResult ,
@@ -32,6 +33,7 @@ export const asBanxaParams = asObject({
32
33
} )
33
34
} )
34
35
36
+ type BanxaStatus = ReturnType < typeof asBanxaStatus >
35
37
const asBanxaStatus = asMaybe (
36
38
asValue (
37
39
'complete' ,
@@ -44,15 +46,18 @@ const asBanxaStatus = asMaybe(
44
46
'other'
45
47
)
46
48
49
+ type BanxaTx = ReturnType < typeof asBanxaTx >
47
50
const asBanxaTx = asObject ( {
48
51
id : asString ,
49
52
status : asBanxaStatus ,
50
53
created_at : asString ,
54
+ country : asString ,
51
55
fiat_amount : asNumber ,
52
56
fiat_code : asString ,
53
57
coin_amount : asNumber ,
54
58
coin_code : asString ,
55
59
order_type : asString ,
60
+ payment_type : asString ,
56
61
wallet_address : asMaybe ( asString , '' )
57
62
} )
58
63
@@ -67,9 +72,6 @@ const PAGE_LIMIT = 100
67
72
const ONE_DAY_MS = 1000 * 60 * 60 * 24
68
73
const ROLLBACK = ONE_DAY_MS * 7 // 7 days
69
74
70
- type BanxaTx = ReturnType < typeof asBanxaTx >
71
- type BanxaStatus = ReturnType < typeof asBanxaStatus >
72
-
73
75
const statusMap : { [ key in BanxaStatus ] : Status } = {
74
76
complete : 'complete' ,
75
77
expired : 'expired' ,
@@ -263,13 +265,21 @@ export function processBanxaTx(rawTx: unknown): StandardTx {
263
265
payoutAddress = banxaTx . wallet_address
264
266
}
265
267
268
+ const direction = banxaTx . order_type === 'CRYPTO-SELL' ? 'sell' : 'buy'
269
+
270
+ const paymentType = getFiatPaymentType ( banxaTx )
271
+
266
272
const standardTx : StandardTx = {
267
273
status : statusMap [ banxaTx . status ] ,
268
274
orderId : banxaTx . id ,
275
+ countryCode : banxaTx . country ,
269
276
depositTxid : undefined ,
270
277
depositAddress : undefined ,
271
278
depositCurrency : inputCurrency ,
272
279
depositAmount : inputAmount ,
280
+ direction,
281
+ exchangeType : 'fiat' ,
282
+ paymentType,
273
283
payoutTxid : undefined ,
274
284
payoutAddress,
275
285
payoutCurrency : outputCurrency ,
@@ -282,3 +292,45 @@ export function processBanxaTx(rawTx: unknown): StandardTx {
282
292
283
293
return standardTx
284
294
}
295
+
296
+ function getFiatPaymentType ( tx : BanxaTx ) : FiatPaymentType {
297
+ switch ( tx . payment_type ) {
298
+ case 'AusPost Retail' :
299
+ return 'auspost'
300
+ case 'BPay' :
301
+ return 'bpay'
302
+ case 'Blueshyft Online' :
303
+ return 'blueshyft'
304
+ case 'POLi Transfer' :
305
+ return 'poli'
306
+ case 'Sofort Transfer' :
307
+ return 'sofort'
308
+ case 'Checkout Credit Card' :
309
+ case 'WorldPay Credit Card' :
310
+ return 'credit'
311
+ case 'ClearJunction Fast Pay' :
312
+ case 'ClearJunction Sell Fast Pay' :
313
+ return 'fasterpayments'
314
+ case 'ClearJunction Sepa' :
315
+ case 'Ten31 Sepa' :
316
+ return 'sepa'
317
+ case 'DCBank Interac' :
318
+ case 'DCBank Interac Sell' :
319
+ return 'interac'
320
+ case 'Enumis Transfer' :
321
+ return 'fasterpayments'
322
+ case 'Monoova Sell' :
323
+ return 'banktransfer'
324
+ case 'NPP PayID' :
325
+ case 'PayID via Monoova' :
326
+ return 'payid'
327
+ case 'WorldPay ApplePay' :
328
+ return 'applepay'
329
+ case 'WorldPay GooglePay' :
330
+ return 'googlepay'
331
+ case 'iDEAL Transfer' :
332
+ return 'ideal'
333
+ default :
334
+ throw new Error ( `Unknown payment method: ${ tx . payment_type } for ${ tx . id } ` )
335
+ }
336
+ }
0 commit comments