SendPayCommand
The POS device calls the SendPayCommand API to send a command to the BlueTap device to generate an NFC link with the specified payment method.
Method signature
/**
* Send pay command to the BlueTap device
*/
ResultCode SendPayCommand(PayCommand payCommand);Request parameter
Item | Type | Description | Required |
payCommand | The command sent to the BlueTap device to generate the NFC link. | M |
PayCommand
Item | Type | Length | Description | Required |
PaymentMethod | String | 12 | The wallet selected by cashier on the POS device. Valid values are:
| M |
Amount | String | 8 | The order amount that the cashier collects. | O |
OrderId | String | 16 | The order ID created by the POS device to identify an order. | O |
ExpiryTime | int | / | The order expiration time in seconds. The default value is 900 seconds. | O |
Response parameter
Item | Type | Description | Required |
/ | The result code that indicates the result of the command sending. For more information about the result code, see the ResultCode section. | M |
ResultCode
ResultCode | Description |
| Success. |
| The BlueTap device is disconnected. |
| The parameter values are invalid. |
| Failed to send the command. |
| System exception. |
Sample
C#
The following sample shows how to use the SendPayCommand API in C#.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using BluetapLib;
namespace BluetapTest
{
static class Program
{
private static void Main(string[] args)
{
TinyCommand tinyCommand = new TinyCommand();
/* Send TRUEMONEY PayCommand*/
PayCommand payCommand = new PayCommand { PaymentMethod = PaymentMethod.TRUEMONEY.ToString() };
ResultCode result = tinyCommand.SendPayCommand(payCommand);
Debug.Assert(result == ResultCode.SUCCESS);
/* Send 7-11 PayCommand*/
payCommand = new PayCommand { PaymentMethod = PaymentMethod.SEVEN_11.ToString() };
result = tinyCommand.SendPayCommand(payCommand);
/* Send Alipay+ wallet PayCommand*/
payCommand = new PayCommand { PaymentMethod = PaymentMethod.ALIPAY_PLUS.ToString() };
result = tinyCommand.SendPayCommand(payCommand);
/* Test invalid PayCommand*/
payCommand = new PayCommand { PaymentMethod = "Test" };
result = tinyCommand.SendPayCommand(payCommand);
Debug.Assert(result == ResultCode.PARAM_ILLEGAL);
}
}
}Note: Contact your Alipay+ Solution Architect to obtain the
BluetapLib.dllfile.
Python
The following sample shows how to use the SendPayCommand API in Python.
import hid
import bluetaplib
tinyCommand = bluetaplib.TinyCommand()
payCommand = bluetaplib.PayCommand(bluetaplib.PaymentMethod.TRUEMONEY)
tinyCommand.SendPayCommand(payCommand)
payCommand = bluetaplib.PayCommand(bluetaplib.PaymentMethod.SEVEN_11)
tinyCommand.SendPayCommand(payCommand)Python code requires hid and bluetaplib to execute. Use the command below in terminal to install them.
pip install hidapi
pip install bluetaplib-1.0.0-py3-none-any.whlNote: Contact your Alipay+ Solution Architect to obtain the
bluetaplib-x.x.x-py3-none-any.whlfile.