Webpay API

Webpay provides a REST API for clients to interact with the server.

All API’s use JSON for request and responses.

PIN

The PIN API lets you check, create and update the PIN through Webpay.

Note

This API Requires authentication through Persona prior to access.

GET /mozpay/v1/api/pin/

Returns information about the PIN for the current user. Will not return the actual PIN.

Response

Example:

{
    "pin": true,
    "pin_locked_out": null,
    "pin_is_locked_out": false,
    "pin_was_locked_out": false
}
Status Codes:
  • 200 – successfully completed.
  • 403 – not authenticated.
Parameters:
  • pin (boolean) – if a PIN exists or not
  • pin_locked_out (date time) – if a PIN is locked out, this is when it occured
  • pin_is_locked_out (boolean) – if a PIN is locked out
  • pin_was_locked_out (boolean) – if a PIN has been locked out
POST /mozpay/v1/api/pin/

Creates a PIN for the current user.

Request

Parameters:
  • pin (string) – 4 numbers in the range 0-9 as a string

Response

Status Codes:
  • 204 – successfully created.
  • 400 – invalid form data.
  • 403 – not authenticated.
PATCH /mozpay/v1/api/pin/

Updates a PIN for the current user.

Request

Parameters:
  • pin (string) – 4 numbers in the range 0-9 as a string

Response

Status Codes:
  • 204 – successfully updated.
  • 400 – invalid form data.
  • 403 – not authenticated.

Pin Check

POST /mozpay/v1/api/pin/check/

Checks a posted PIN against a stored pin.

Request

Parameters:
  • pin (string) – 4 numbers in the range 0-9 as a string

Response

Example:

{
    "pin": true,
    "pin_locked_out": null,
    "pin_is_locked_out": null,
    "pin_was_locked_out": null
}
Status Codes:
  • 200 – successfully completed.
  • 400 – incorrect PIN.
  • 403 – not authenticated.
  • 404 – no user exists.

The response is the same as for the PIN API.

Pay

The Pay API lets you start a purchase.

POST /mozpay/v1/api/pay/

Start a purchase.

Request

Parameters:
  • req (str) – the JWT request for starting a payment
  • mnc (str) – the MNC (mobile network code) for the device (optional)
  • mcc (str) – The MCC (mobile country code) for the device (optional)

Response

Parameters:
  • status (str) – “ok” if successful
  • simulation (dict) – Indicates the type of simulated payment. If this is a normal payment, not a simulation, it will be False. Otherwise it will be one of the valid simulation results such as {"result": "postback"}.
{
    "status": "ok",
    "simulation": {"result": "postback"}
}
Status Codes:
  • 200 – successful.
  • 400 – invalid form data.
GET /mozpay/v1/api/pay/

Get information about your purchase.

Response

{
    "provider": "bango",
    "pay_url": "https://url.to-start.the/transaction"
}
Status Codes:
  • 200 – successfully completed.
  • 400 – trans_id is not set in the session.
  • 404 – transaction could not be found.

Simulate

If a simulated payment is pending in the current session, as indicated by the Pay API, you can use this API to execute the simulated payment. This sends a server notice to the app that initiated the purchase so it can fulfill the simulated purchase.

POST /mozpay/v1/api/simulate/

Execute a pending simulated payment.

Request

(no parameters)

Response

(no parameters)

Status Codes:
  • 204 – successful.
  • 400 – invalid request.
  • 403 – no pending simulation in the current session or invalid user permissions.