mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-09-01 06:45:41 +00:00
src/telegram: Support API v3 Payments (#335)
References: * API v3 Payments: https://core.telegram.org/bots/payments * PR: https://github.com/yagop/node-telegram-bot-api/pull/335 * PR-by: @kamikazechaser * API v3 progress tracker: https://github.com/yagop/node-telegram-bot-api/issues/332
This commit is contained in:
committed by
Gocho Mugo
parent
07a6e5ff23
commit
fe527957e0
@@ -13,6 +13,9 @@ export TEST_GROUP_ID=<GROUP_ID>
|
||||
# Game short name which to use in some of the tests, e.g. TelegramBot#sendGame()
|
||||
export TEST_GAME_SHORT_NAME=<GAME_SHORT_NAME>
|
||||
|
||||
# Payment provider token to be used
|
||||
export TEST_PROVIDER_TOKEN=<YOUR_PROVIDER_TOKEN>
|
||||
|
||||
# Run ALL tests
|
||||
npm run test
|
||||
|
||||
|
@@ -16,6 +16,11 @@ if (!TOKEN) {
|
||||
throw new Error('Bot token not provided');
|
||||
}
|
||||
|
||||
const PROVIDER_TOKEN = process.env.TEST_PROVIDER_TOKEN;
|
||||
if (!PROVIDER_TOKEN) {
|
||||
throw new Error('Provider token not supplied');
|
||||
}
|
||||
|
||||
// Telegram service if not User Id
|
||||
const USERID = process.env.TEST_USER_ID || 777000;
|
||||
const GROUPID = process.env.TEST_GROUP_ID || -1001075450562;
|
||||
@@ -1206,4 +1211,28 @@ describe('TelegramBot', function telegramSuite() {
|
||||
return bot.sendPhoto(USERID, stream);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#sendInvoice', function sendInvoiceSuite() {
|
||||
before(function before() {
|
||||
utils.handleRatelimit(bot, 'sendInvoice', this);
|
||||
});
|
||||
it('should send an invoice', function test() {
|
||||
const title = 'Demo product';
|
||||
const description = 'our test product';
|
||||
const payload = 'sku-p001';
|
||||
const providerToken = PROVIDER_TOKEN;
|
||||
const startParameter = 'pay';
|
||||
const currency = 'KES';
|
||||
const prices = [{ label: 'product', amount: 11000 }, { label: 'tax', amount: 11000 }];
|
||||
return bot.sendInvoice(USERID, title, description, payload, providerToken, startParameter, currency, prices).then(resp => {
|
||||
assert.ok(is.object(resp));
|
||||
assert.ok(is.object(resp.invoice));
|
||||
assert.ok(is.number(resp.invoice.total_amount));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip('#answerShippingQuery', function answerShippingQuerySuite() {});
|
||||
|
||||
describe.skip('#answerPreCheckoutQuery', function answerPreCheckoutQuerySuite() {});
|
||||
}); // End Telegram
|
||||
|
Reference in New Issue
Block a user