API to handle Mobile Payments & Premium Number Messaging.
Overview
The Premium API allows you to accept one-time payments, and to implement premium subscription models, using a supported mobile payment method.
In addition, it handles subscriptions to your campaign for you and allows you to charge your subscribers either through direct carrier billing or through premium SMS. Finally, it supports the delivery of Free-to-end-user(FTEU) content. It supports multiple opt-in methods, e.g. through MO or through PIN verification, as well as automatic SMS opt-outs and API opt-outs.
The available options provided by the API are presented below. Please note that some of the capabilities mentioned may NOT be supported in your country, due to regulatory reasons.
High-Level Overview
The Premium API allows content / service providers to accept mobile payments from mobile network subscribers, through different mobile payment methods.
API handles all the complexity of managing subscriptions (opt-ins and opt-outs), so that the Content Provider (CP) or Service Provider (SP) never has to worry about sending unsolicited messages to consumers.
Subscriptions
It handles customer subscriptions, through 3 optin methods:
- MO SMS opt-in flow (customer sends SMS message from their phone to initiate subscription),
- Web opt-in flow (customer inserts their mobile number on a web page to initiate subscription),
- Web opt-in flow with SMS invitation (customer inserts their mobile number on a web page to initiate subscription).
It provides the merchant with the API methods to receive incoming MOs (Mobile Originated messages), as well as verify the subscription using a PIN code or SMS invitation.
Depending on the regulatory requirements for a suitable opt-in process to your premium service, you can choose one of these opt-in methods.
Subscription through SMS
Two variations exist, depending on the flow of SMS required for a subscription to be considered complete: Single SMS Opt-in and Double SMS Opt-in.
Single SMS Opt-in
The consumer simply texts in to immediately be considered an active subscriber / participant of the service. The only action required to complete the opt-in is the sending of the (MO) SMS by the consumer.
Double SMS Opt-in
The consumer starts the subscription process by texting in to a short code. When a double opt-in mechanism is required, our platform will automatically reply with a confirmation SMS to the consumer, asking them to confirm that by this action they will be participating in the specific service and informing them about any premium costs involved, e.g. recurring weekly costs, etc.
The consumer is asked to reply back confirming their participation, in order to be considered as fully opted-in to this particular service.
Subscription through Web, with PIN verification
The merchant can initiate the subscription of a customer, e.g. when the customer inserts their mobile phone number in the merchant's web form.
The merchant uses the PIN verification functionality offered by the API, through the “send PIN” API endpoint. API is then responsible for sending an SMS to the customer containing a one-time use PIN code. The merchant should then request the PIN code from the customer (e.g. through a form in the web site) and then try to verify it through the “verify PIN” API endpoint.
If the verification was successful, the customer will be subscribed to the particular service.
Subscription through Web, with SMS invitation and MO reply verification
The merchant can initiate the subscription of a customer, e.g. when the customer inserts their mobile phone number in the merchant's web form.
The merchant uses the SMS Invite verification functionality offered by the API, through the “sendInviteMessage” API endpoint, in order to send a message asking consumers to confirm by replying back with an SMS. With this action the merchant informs the users that they will be subscribing to the specific service, which involves the specific costs/MT charges, etc.
If the consumer replies back he is considered as fully opted-in to this particular service.
Unsubscription
The customer can unsubscribe from the merchant’s service by sending an MO with the STOP keyword. The MO will be forwarded to the merchant to the registered URL for receiving MOs.
Also, the merchant can initiate the unsubscription of a specific customer, by calling the opt- out API endpoint to unsubscribe a customer.
Subscriber Protection & Regulatory Compliance
One of the main value propositions of API is the mechanism it has in place in order to protect the mobile network subscribers from any actions that are against the local regulations.
In turn, this is also protection for the Service Provider (SP) against the regulating body. Fines could be imposed on the SP and any of its international partners (e.g. Content Providers (CP)), for such actions, whether they were performed on purpose, or by mistake, or accident. Therefore, all partners can have peace of mind, because the API is responsible for enforcing these rules.
In particular, API, offers the following features:
● No Unsolicited Messages
● Enforce Maximum Spending / Maximum Charge Limits
● Enforce Free MT ratio
Unsolicited Messages
One of the main concerns for the telecoms regulating bodies in most countries is that the mobile network subscribers might be contacted (e.g. receive SMS messages, etc) from Value- Added Services (VAS) to which they have not opted-in to.
API solves this problem by taking control of the automated subscription / unsubscription process and maintaining the subscriber base internally, in its database.
In addition to this, API only accepts content for delivery to a particular mobile phone number in relation to a particular service id. At that point, it can confirm that the intended recipient is indeed a valid subscriber to the particular service. If not, the content is rejected.
Enforce Maximum Spending / Maximum Charge Limits
Another common regulation is that any mobile network subscriber cannot exceed a certain spending limit over a certain period, for a particular service. For example, there might be a limit of a maximum charge of 25 EUR per month, per subscriber, for each VAS.
Because the API handles all the payments coming through for the particular service, it is also in a position to enforce that this limit is never exceeded. Any extra attempts for a payment that would be taking the subscriber over the limit are rejected.
Enforce Free MT ratio
A number of Mobile Network Operators offer a number of Mobile Terminated (MT) SMS that can be sent back to the mobile subscribers at no charge for the service provider. This is usually in place for Mobile Originated (MO) billing Premium SMS short codes, where the subscriber pays for the MO but receives back a free MT. In those cases, the MTs are also free of charge for the service provider, and are calculated based on an MO/MT ratio.
For example, in the case where the MNO offers an 1/2 MO/MT ratio, the service provider can send up to 2 free MTs for each billable MO SMS received on the particular short code.
API has a mechanism in place that, when enabled, can ensure that this ratio is never exceeded and that the SP is always protected against such extra charges from the MNO.
DLR Callback
This section describes the various messages the API will send to the merchant and the responses the merchant must send back by implementing the respective receivers on their side.
The "Forward DLR" function forwards to the merchant a Delivery Report (DLR) that has been received and it is related to an MT they have sent to a subscriber.
For each DLR, the merchant will receive a POST HTTP callback to the DLR callback URL defined for the service. Posted parameters are:
Parameters POST[ed]
| Parameter | Value | Description |
|---|---|---|
serviceId | int | unique identifier for the merchant’s service |
subscriberId | int | is the unique identifier of the subscriber who received the MT |
messageId | int | unique identifier of the MT the DLR is related with |
paymentId | int | unique identifier of the payment related to a premium MT. In case the DLR is not about a premium MT (i.e. it is about a free-to-end-user MT), this value will be null |
status | string | describes whether the messages has been successfully sent to the subscriber or not |
substatus | string | describes the detailed reason of a failure |
network | string | current network the msisdn of the subscriber belongs to |
To test your implementation:
curl -X POST "http://YOUR-DLR-URL"
-H "accept: */*"
-d "serviceId=0&subscriberId=0&messageId=0&paymentId=0&status=d&substatus=d&network=string"
Merchants must implement a DLR Receiver on their side that will accept the above requests and will reply with an HTTP status code "200 OK" if they managed to receive and process the DLR information properly or an error status code in any other case.
For more information about the possible values of the status and sub-status fields please refer to Appendix – Statuses and Sub-Statuses.
MO Callback
The "Forward MO" function forwards to the merchant an MO SMS that has been sent by a subscriber to one of their registered short codes.
For each MO, the merchant will receive a POST HTTP callback to the MO callback URL defined for the service. Posted parameters are:
Parameters POST[ed]
| Parameter | Value | Description |
|---|---|---|
serviceId | int | unique identifier for the merchant’s service |
subscriberId | int | is the unique identifier of the subscriber who received the MT |
moId | int | unique identifier of the received MO |
shortCode | string | the short code where the subscriber sent the MO to |
text | string | body of the received MO |
network | string | current network the msisdn of the subscriber belongs to |
amount | double | the amount of money the subscriber has been charged, e.g. in the case of a Premium MO SMS. If the MO was not sent to a free SMS Number, then this value will be 0.0. If the MO was sent to a premium SMS Number, then this value will be equal to the amount the subscriber was charged from their Mobile Network Operator. |
currencyCode | string | currency that is related with the amount of money the subscriber was charged, in ISO 4217 format, e.g EUR |
optout | string | optout parameter is optional. In case the MO is not opt out this parameter will be missing else if the MO is opt out the parameter “optout” will be “true”. |
msisdn | string | msisdn parameter is to forward the msisdn with the MO. This parameter is optional and will be missing. |
To test your implementation:
curl -X POST "http://YOUR-MO-URL"
-H "accept: */*"
-d "serviceId=0&subscriberId=0&shortCode=string&text=string&moId=0&network=string&amount=0¤cyCode=string&optout=string&msisdn=string"
Merchants must implement an MO Receiver on their side that will accept the above requests and will reply with an HTTP status code "200 OK" if they managed to receive and process the MO information properly or an error status code in any other case.
charges/charge
Direct charge of the subscriber
https://premium.easysms.gr/charges/charge
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
serviceId | int | unique identifier for the merchant’s service |
subscriberId | int | the unique identifier of the subscriber to charge |
amount | double | amount that the subscriber will be charged |
currencyCode | string | currency the end user will be charged to (ISO 4217 format) |
shortCode | string | short code that will appear as the sender of the message the user might receive |
Returns JSON
| Value | Description |
|---|---|
{ id, serviceId, statusCode, resultCode, code, reason, message, response} |
JSON Object Id of payment Id of service Payment status code Payment result code Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/charges/charge"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&serviceId=0&subscriberId=0&amount=1¤cyCode=EUR&shortCode=45678"
charges/reverse
Reverse charge performed to subscriber, either direct or sms
https://premium.easysms.gr/charges/reverse
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
messageId | int | id of the payment to be reversed |
Returns JSON
| Value | Description |
|---|---|
{ id, serviceId, statusCode, resultCode, code, reason, message, response} |
JSON Object Id of payment Id of service Payment status code Payment result code Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/charges/reverse"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&messageId=0"
messages/fteu
Send Free to end user message
https://premium.easysms.gr/messages/fteu
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
serviceId | int | unique identifier for the merchant’s service |
subscriberId | int | the unique identifier of the subscriber to send SMS |
sender | string | sender id for the message. Sender id limitation is 11 chars |
text | string | body of the SMS that will be sent to the end user |
encoding | string | encoding of the SMS that will be sent to the end user, either gsm (default) or ucs2 |
Returns JSON
| Value | Description |
|---|---|
{ serviceId, subscriberId, messageId, paymentId, amount, currencyCode, code, reason, message, response} |
JSON Object Id of service Id of subscriber Id of message Payment Id Paid amount Paid currency Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/messages/fteu"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&subscriberId=0&serviceId=0&sender=sender&text=text&encoding=gsm"
messages/premium
Send premium message to subscriber
https://premium.easysms.gr/messages/premium
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
serviceId | int | unique identifier for the merchant’s service |
subscriberId | int | the unique identifier of the subscriber to send SMS |
sender | string | sender id for the message. Sender id limitation is 11 chars |
text | string | body of the SMS that will be sent to the end user |
encoding | string | encoding of the SMS that will be sent to the end user, either gsm (default) or ucs2 |
amount | double | amount that the subscriber will be charged |
currencyCode | string | currency the end user will be charged to (ISO 4217 format) |
Returns JSON
| Value | Description |
|---|---|
{ serviceId, subscriberId, messageId, paymentId, amount, currencyCode, code, reason, message, response} |
JSON Object Id of service Id of subscriber Id of message Payment Id Paid amount Paid currency Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/messages/premium"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&subscriberId=0&serviceId=0&sender=sender&text=text&encoding=gsm"
messages/sendInviteMessage
Send invitation message to end-user
https://premium.easysms.gr/messages/sendInviteMessage
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
serviceId | int | unique identifier for the merchant’s service |
sender | string | sender id for the message. Sender id limitation is 11 chars |
msisdn | string | msisdn of the end user you will send the invitation |
text | string | body of the SMS that will be sent to the end user |
encoding | string | encoding of the SMS that will be sent to the end user, either gsm (default) or ucs2 |
triggerPendingOptin | boolean | whether this SMS invite should trigger the first step of a double opt-in flow |
Returns JSON
| Value | Description |
|---|---|
{ serviceId, subscriberId, messageId, paymentId, amount, currencyCode, code, reason, message, response} |
JSON Object Id of service MSISDN since not yet subscribed Id of message Payment Id Paid amount Paid currency Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/messages/sendInviteMessage"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&serviceId=0&sender=sender&text=text&encoding=gsm&msisdn=697&triggerPendingOptin=false"
pins/send
Send PIN via SMS, which can later be verified from a user, to become a subscriber
https://premium.easysms.gr/pins/send
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
serviceId | int | unique identifier for the merchant’s service |
msisdn | string | msisdn of the end user you will send the invitation |
sender | string | sender id for the message. Sender id limitation is 11 chars |
text | string | body of the SMS that will be sent to the end user |
encoding | string | encoding of the SMS that will be sent to the end user, either gsm (default) or ucs2 |
codeLength | string | length of the generated PIN code. It must at least 4 digits, default is 6 |
Returns JSON
| Value | Description |
|---|---|
{ serviceId, pinId, subscriberId, code, reason, message, response} |
JSON Object Id of service PIN Id to verify Id of subscriber Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/pins/send"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&serviceId=0&sender=sender&text=text&encoding=gsm&msisdn=697&codeLength=5"
pins/verify
Verify a PIN that was previously submitted via SMS, in order for the end user to become a subscriber
https://premium.easysms.gr/pins/verify
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
serviceId | int | unique identifier for the merchant’s service |
pinId | string | ID of the previously submitted PIN |
pin | string | PIN code the user entered, which must match what was submitted to the mobile number |
Returns JSON
| Value | Description |
|---|---|
{ serviceId, subscriberId, code, reason, message, response} |
JSON Object Id of service Id of subscriber Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/pins/verify"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&serviceId=0&pinId=12345&pin=1122"
subscribers/get
Get Subscriber information and details
https://premium.easysms.gr/subscribers/get
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
subscriberId | int | the unique identifier of the subscriber to send SMS |
serviceId | int | unique identifier for the merchant’s service |
Returns JSON
| Value | Description |
|---|---|
{ status, serviceId, lastBilled, lastBillingAttempStatus, lastBillingAttempt, code, reason, message, response} |
JSON Object Current status OPTED_IN or OPTED_OUTId of service Last billed Last billing status Last billing attempt Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/subscribers/get"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&serviceId=0&subscriberId=0"
subscribers/optout
Opt-out (unsubscribe) subscriber from service
https://premium.easysms.gr/subscribers/optout
Accepts
| Parameter | Value | Description |
|---|---|---|
key | string | your API Key for the service |
subscriberId | int | the unique identifier of the subscriber to send SMS |
serviceId | int | unique identifier for the merchant’s service |
Returns JSON
| Value | Description |
|---|---|
{ status, serviceId, lastBilled, lastBillingAttempStatus, lastBillingAttempt, code, reason, message, response} |
JSON Object Current status OPTED_IN or OPTED_OUTId of service Last billed Last billing status Last billing attempt Error code Error Description Error message Response code |
To test your implementation:
curl -X POST "https://premium.easysms.gr/subscribers/optout"
-H "accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d "key=YOUR-API-KEY&serviceId=0&subscriberId=0"
Error Responses
All error responses have the HTTP status code in the range of 4XX (for client errors) or 5XX (for server errors) passed into 'response' parameter within the JSON object. The error responses contain a JSON entity in the following format:
{ "code": 0, "message":"error description", "respose": 401 }
The possible values for the error responses can be found in the following table:
| Parameter | Description |
|---|---|
0 | Unauthorized: The provided apiKey is not valid |
1 | Forbidden: You are not authorized to access MPS |
2 | Internal Error: Internal server error. Please try again later. If the issue persists, please contact support |
3 | Service Unavailable: External service unavailable. Please try again later. If the issue persists, please contact support |
4 | Validation Error: One or more required parameters were missing |
5 | Json Parsing Error: Unable to process JSON |
6 | Client Error: Client disconnected before the server could process the request |
7 | Not Found:The resource was not found |
10 | Message Accepted:The message was accepted for further processing |
11 | Message Rejected:The destination phone number is invalid |
12 | Invalid Routing:The routing is invalid |
100 | Service id is not valid |
101 | Subscriber id is not valid |
102 | Subscriber cannot be charged based on the specified service id / sender / amount / currency combination |
103 | Amount specified cannot be used to charge subscriber |
104 | Charge provider specific parameters invalid |
105 | Payment id is not valid |
106 | Subscriber is not opted-in yet |
107 | Subscriber is opted-out |
108 | Subscriber does not have enough balance |
109 | Reversal of charge was rejected |
110 | Preauthorization request was rejected |
111 | The subscriber is blacklisted |
112 | The charge request is invalid. Daily/weekly/monthly limit reached |
113 | The charge request is rejected due to age restriction |
114 | Subscriber is already opted-in |
1000 | OTP id is not valid |
1001 | Sender value is not valid |
1002 | Mobile number is not valid |
1003 | Message text is not valid |
1004 | OTP code is not valid |
1005 | OTP has been verified previously |
1006 | OTP has expired |
1007 | Max attempts reached for OTP |
Statuses
Describes all values of the status and substatus parameters of a forwarded DLR via the callback DLR URL specified for each VAS.
The possible values for the message (sub)statuses can be found in the following table:
| Parameter | Value | Description |
|---|---|---|
status | d | MT has been delivered to the subscriber |
f | MT failed to be delivered | |
s | message has been submitted | |
| ||
substatus | d | delivered: the MT has been delivered to the subscriber |
s | sent: the message has been submitted | |
f | failed: the message was marked as failed | |
e | expired: the MT was stored by the provider until the expiration date of the message was passed | |
x | deleted: the MT has been deleted manually by the provider This is not supposed to happen, unless the operator detects a large amount of spam MT | |
u | undeliverable: the MT could not be delivered because it does not exist anymore, or because the operator could not find an appropriate route to this user | |
a | accepted:the message has been accepted to be delivered | |
r | rejected: the MT has been rejected because of syntactic or semantic problems with the MT parameters. | |
i | invalid amount: the provided amount during the MT dispatch was incorrect | |
k | insufficient balance: the subscriber has insufficient balance | |
n | unknown: an unknown error has occurred | |
m | no price set: the message failed because there is not any price set in the user’s pricelist | |
o | MNO Barring: The MT was rejected by the operator due to barring. | |
p | NOT authorized purchase: The MT was rejected by the operator as not authorized (e.g. pre-authorization rejected). | |
w | age restriction: The MT was rejected by the operator due to age restriction. | |
g | invalid purchase request: The MT was rejected by the operator due to exceeded usage limits. | |
y | billing failure: the sms failed. Please contact your administrator with error code #BSPFTB | |
j | not enough balance: The user does not have enough balance. | |
l | curfew period applied: The message marked to be sent after the defined curfew period | |
z | spam: The message marked as spam |