Nhảy tới nội dung
Phiên bản: Lastest

API Mua mã thẻ

Endpoint: /api/v1/service/shopcard/buy

Method: POST

Header: Cách tạo JWT_TOKEN

{
"X-APPOTAPAY-AUTH": Bearer JWT_TOKEN,
"Content-Type": "application/json"
}

Tham số

Tham sốYêu cầuKiểu dữ liệuMô tả
partnerRefIdStringMã giao dịch phía đối tác, duy nhất cho mỗi giao dịch
productCodeStringMã sản phẩm (xem thêm phần Phụ Lục bảng mã sản phẩm)
typeStringHình thức mua thẻ. Mặc định là "normal".
Normal: Thẻ mua sẽ được trả trực tiếp.
SMS: Thẻ mua sẽ được gửi trực tiếp qua tin nhắn SMS đến số điện thoại của người dùng.
customer_phoneStringLà số điện thoại (định dạng: 09x, 08x...) sẽ sử dụng để nhận thông tin thẻ cào gửi đến với hình thức mua thẻ là SMS
quantityIntegerSố lượng thẻ mua
Tối đa 100 thẻ /1 lần mua với hình thức mua thẻ normal
Tối đa 1 thẻ/1 lần mua với hình thức mua thẻ sms
signatureStringChữ ký các tham số truyền lên API, các tham số được đưa vào chữ ký theo thứ tự bao gồm: partnerRefId + productCode + quantity (xem thêm phần cách tạo signature)

Dữ liệu trả về

Tham sốKiểu dữ liệuMô tả
errorCodeIntegerMã lỗi trả về
messageStringMô tả chi tiết mã lỗi
cardsArray of ObjectThông tin thẻ
cards[].codeStringMã thẻ (ở dạng đã mã hoá)
cards[].serialStringSerial thẻ
cards[].vendorStringVendor thẻ
cards[].valueIntegerGiá trị thẻ
cards[].expiryStringHạn sử dụng thẻ (dang: y-m-d, vd: 29-09-2023)
transactionObjectThông tin giao dịch
transaction.appotapayTransIdStringMã giao dịch phía AppotaPay
amountIntegerSố tiền giao dịch
timeStringThời gian giao dịch (dạng: d-m-Y H:i:s)
accountObjectThông tin tài khoản
account.balanceIntegerSố dư tài khoản sau giao dịch

Ví dụ

Request

{
"partnerRefId": "AB123",
"productCode": "AC100",
"quantity": 10,
"signature": "b10294bae53e89919b3efd62a763bf3..."
}

Với type: "sms"

{
"partnerRefId": "AB123",
"productCode": "VT10",
"type": "sms",
"quantity": 1,
"customer_phone": "0912345678",
"signature": "b10294bae53e89919b3efd62a763bf3..."
}

Response

{
"errorCode": 0,
"message": "Thành công",
"cards": [
{
"code": "b10294bae53e89919b3efd62a763bf3",
"serial": "OTA123456789",
"vendor": "appota",
"value": 100000,
"expiry": "29-09-2023"
},
...
],
"transaction": {
"amount": 100000,
"appotapayTransId": "AP12adf21121",
"time": "10-04-2020 10:10:10",
},
"account": {
"balance": "121000000"
}
}

Với type: "sms"

{
"errorCode": 0,
"message": "Thành công",
"cards": [],
"transaction": {
"amount": 100000,
"appotapayTransId": "AP12adf21121",
"time": "10-04-2020 10:10:10",
},
"account": {
"balance": "121000000"
}
}