Skip to main content

send-payment-request

POST https://chatapi.viber.com/pa/send_message

To request a payment from one of your bot subscribers you need to use the send message
endpoint and specify the payment message type.
When sending the payment request the user will be presented with a payment button,
continue to checkout that will expire after 15 minutes.
See the figure below to understand the flow of the payment request.

Payment Request Flow

Payment Request

Headers


Content-Type: application/json
Authorization: X-Viber-Auth-Token: YOUR_AUTHENTICATION_TOKEN

Parameters


NameTypeDescriptionNotes
receiverstringThe id of the subscriber.
sender.namestringThe name of the bot.Required. Max 28 characters.
sender.avatarstringThe avatar of the bot.Optional. the avatar size should not exceed 100KB. The recommended dimensions for the avatar are 720x720.
min_api_versionintegerThe minimum API version of the subscriber.Required. Payment request are supported from v10 and above
typestringThe type of the message.Required. Must be payment
paymentobjectThe payment object.Required.
payment.typestringThe type of the payment.Required. . Currently only “GooglePay” for Android devices and “ApplePay” for iOS devices are valid.
payment.descriptionstringThe description of the payment.Optional.
payment.total_pricefloatThe total price of the payment.Required. For example 30.56
payment.currency_codestringThe currency code of the payment.Required. Currency string according to ISO 4217 format (e.g American dollar would be USD).
payment.payment_parametersobjectThe payment parameters object.Required. The payment paramters are different for each payment service provider. You can learn more about them and how to get them in the Setup Payment Account section
Example
curl -X POST https://chatapi.viber.com/pa/send_message -H "X-Viber-Auth-Token: YOUR_AUTHENTICATION_TOKEN" -d
'{"auth_token": "445da6az1s345z78-dazcczb2542zv51a-e0vc5fva17480im9", "receiver": "01234567890A==" "min_api_version": 10, "type": "payment", "payment": {"type": "GooglePay", "description":"2 shirts XL", "total_price": 1.85, "currency_code": "EUR", "payment_parameters":[{"key": "gateway", "value": "liqpay"}, {"key": "gatewayMerchantId", "value": "abc123"}, {"key": "url", "value": "https://www.liqpay.ua/api/viber"}, {"key": "data", "value": "qwerty12345"}, {"key": "signature", "value": "123abc" }, {"key":"payeeId","value":"abc123"}]}}'

Response

Attributes


NameTypeDescriptionNotes
statusintegerThe status of the request.0 for success. In case of failure - appropriate failure status number. See common errors for more information
status_messagestringThe status message of the request.Success: ok. Failure: invalidUrl, invalidAuthToken, badData, missingData and failure. See common errors for more information
message_tokenintegerUnique id of the message
chat_hostnamestringThe name of ther server that host your botfor internal use
billing_statusstringAn indication of how this message is categorized for billing purposes, allowing you to know if it was charged or not, or whether it counts toward. Read more about bots billing hereAn integer between 0 and 5. See the table in billing statuses section below for more information
Example
{
"status": 0,
"status_message": "ok",
"message_token": 1234567890,
"chat_hostname": "chatapi.viber.com",
"billing_status": 0
}

Billing Statuses


ValueNameDescription
0freeDefault for all cases other than the ones listed below: chat extension, reply to open conversation, etc.
1inSessionNonBillableBot1:1 message/keyboard sent in a session from a non-billable bot
2inSessionForBillableBot1:1 message/keyboard sent in a session from a billable bot
3outOfSessionFreeMessageNonBillableBotFree out of session 1:1 message/keyboard sent by a non-billable bot
4outOfSessionFreeMessageForBillableBotFree out of session 1:1 message/keyboard sent by a billable bot
5outOfSessionBilledMessageCharged out of session 1:1 message/keyboard sent by a billable bot