Skip to content

Commit 5d6bc95

Browse files
authored
Merge pull request #106 from bcProFoundation/fb-takyoon-tx-qpay-to-google-sheet
Fb takyoon tx qpay to google sheet
2 parents 723305c + f024fca commit 5d6bc95

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

packages/bitcore-wallet-service/src/lib/expressapp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2448,7 +2448,7 @@ export class ExpressApp {
24482448
});
24492449
setTimeout(() => {
24502450
server.checkOrderInSwapQueue();
2451-
// server.initCheckQueue();
2451+
server.initCheckQueue();
24522452
}, 10000);
24532453
return cb();
24542454
});

packages/bitcore-wallet-service/src/lib/model/merchantorder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface IQpayInfoForEmail {
1818
dateFormatted: string;
1919
date: Date;
2020
taxId?: string;
21+
idNumber?: string;
2122
}
2223

2324
export interface IMerchantOrder {

packages/bitcore-wallet-service/src/lib/server.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5375,7 +5375,6 @@ export class WalletService {
53755375
this._handleSendSuccesMerchantOrder(
53765376
amountCoinUserSentToServer,
53775377
amountElps,
5378-
txId,
53795378
merchantOrder,
53805379
merchant.name
53815380
);
@@ -5418,7 +5417,6 @@ export class WalletService {
54185417
this._handleSendSuccesMerchantOrder(
54195418
amountCoinUserSentToServer,
54205419
amountElps,
5421-
txId,
54225420
merchantOrder,
54235421
merchant.name
54245422
);
@@ -5464,9 +5462,9 @@ export class WalletService {
54645462
async _handleSendSuccesMerchantOrder(
54655463
amountCoinUserSentToServer,
54665464
amountElps,
5467-
txId,
54685465
merchantOrder: MerchantOrder,
5469-
merchantName
5466+
merchantName,
5467+
isPaidByUser = false
54705468
) {
54715469
if (amountCoinUserSentToServer > 0) {
54725470
bot.sendMessage(
@@ -5504,8 +5502,13 @@ export class WalletService {
55045502
config.conversion.tokenCodeUnit +
55055503
' to ' +
55065504
merchantName +
5505+
(isPaidByUser ? ' :: is Paid by user' : '') +
55075506
'\n\n' +
5508-
this._addExplorerLinkIntoTxIdWithCoin(merchantOrder.txIdMerchantPayment, 'xec', 'View tx on the Explorer'),
5507+
this._addExplorerLinkIntoTxIdWithCoin(
5508+
isPaidByUser ? merchantOrder.txIdFromUser : merchantOrder.txIdMerchantPayment,
5509+
'xec',
5510+
'View tx on the Explorer'
5511+
),
55095512
{ parse_mode: 'HTML' }
55105513
);
55115514
}
@@ -6265,21 +6268,31 @@ export class WalletService {
62656268
return cb(new Error('Can not find config for conversion'));
62666269
}
62676270
const merchantOrder = MerchantOrder.create(opts);
6271+
const listMerchant = this.getListMerchantInfo();
6272+
if (!listMerchant || listMerchant.length < 1) {
6273+
return cb('Can not find list merchant on server');
6274+
}
6275+
const merchantSelected = listMerchant.find(merchant => merchant.code === merchantOrder.merchantCode);
6276+
if (!merchantSelected) {
6277+
return cb('Can not find selected merchant on server');
6278+
}
62686279
if (merchantOrder.isPaidByUser) {
62696280
merchantOrder.paymentType = PaymentType.SEND;
62706281
this.storage.storeMerchantOrder(merchantOrder, async (err, result) => {
62716282
if (err) return cb(err);
62726283
// let order into queue
62736284
try {
6274-
await this._handleEmailNotificationForMerchantOrder(merchantOrder);
6285+
const amountToken =
6286+
merchantOrder.qpayInfoForEmail.amountToken === 0
6287+
? merchantOrder.qpayInfoForEmail.amountPay
6288+
: merchantOrder.qpayInfoForEmail.amountToken;
6289+
await this._handleSendSuccesMerchantOrder(0, amountToken, merchantOrder, merchantSelected.name, true);
62756290
} catch (e) {
62766291
logger.debug('email sent to user error: ', e);
62776292
}
62786293
return cb(null, true);
62796294
});
62806295
} else {
6281-
const listMerchant = this.getListMerchantInfo();
6282-
const merchantSelected = listMerchant.find(merchant => merchant.code === merchantOrder.merchantCode);
62836296
if (!merchantSelected.isElpsAccepted) {
62846297
merchantOrder.paymentType = PaymentType.BURN;
62856298
if (!opts.signature) {
@@ -6359,7 +6372,7 @@ export class WalletService {
63596372
await googleSheets.spreadsheets.values.append({
63606373
auth,
63616374
spreadsheetId,
6362-
range: sheetName + '!A:M',
6375+
range: sheetName + '!A:R',
63636376
valueInputOption: 'USER_ENTERED',
63646377
resource: {
63656378
values: [
@@ -6368,6 +6381,7 @@ export class WalletService {
63686381
merchantOrder.userAddress,
63696382
merchantOrder.userEmailAddress,
63706383
merchantOrder.qpayInfoForEmail.taxId || '',
6384+
merchantOrder.qpayInfoForEmail.idNumber || '',
63716385
merchantOrder.qpayInfoForEmail.street || '',
63726386
merchantOrder.qpayInfoForEmail.unitNumber || '',
63736387
merchantOrder.qpayInfoForEmail.paymentReason || '',

0 commit comments

Comments
 (0)