Alipay+ DocsAlipay+ Docs

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

copy
/**
 * Send pay command to the BlueTap device
 */
ResultCode SendPayCommand(PayCommand payCommand);

Request parameter

Item

Type

Description

Required

payCommand

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:

  • TRUEMONEY: TrueMoney Wallet
  • SEVEN_11: 7-Eleven Wallet
  • ALIPAY_CN: AlipayCN Wallet
  • ALIPAY_PLUS: Other wallets integrated with Alipay+.

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

/

ResultCode

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

Success.

DEVICE_DISCONNECTED

The BlueTap device is disconnected.

PARAM_ILLEGAL

The parameter values are invalid.

PROCESS_FAIL

Failed to send the command.

UNKNOWN_EXCEPTION

System exception.

Sample

C#

The following sample shows how to use the SendPayCommand API in C#.

copy
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.dll file.

Python

The following sample shows how to use the SendPayCommand API in Python.

copy
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.

copy
pip install hidapi
pip install bluetaplib-1.0.0-py3-none-any.whl

Note: Contact your Alipay+ Solution Architect to obtain the bluetaplib-x.x.x-py3-none-any.whl file.