emolero's picture
Upload folder using huggingface_hub
ab74ec2 verified
|
Raw
History Blame Contribute Delete
17.9 kB

Overview

The Carrier Billing Payment API provides programmable interface for developers and other users (capabilities consumers) to charge a digital content purchase or subscription to the mobile line invoice.

1. Introduction

The Carrier Billing Payment API is used by an application to charge an amount on the mobile line. It can be easily integrated and used through this secured API and allows end-users to buy digital content in an easy & secured way. The API provides management of a payment entity and its associated lifecycle.

The carrier billing Payment API is driven from Open Mobile Alliance standard.

2. Quick Start

The usage of the API is based on Payment resource, which can be created (in 1 or 2 steps process), confirmed (for 2-steps process), cancelled (for 2-steps process), queried and retrieved.

Before starting to use the API, the developer needs to know about the below specified details:

Payment service endpoint The URL pointing to the RESTful resource of the payment API. As we manage 1-step and 2-steps process we have defined 2 separate tags to explicitly distinct them in the swagger. A third tag 'payment' is defined for common operation for both process (query & retrieve)

Authentication Security access keys such as OAuth 2.0 client credentials used by Client applications to invoke the Carrier Billing Payment API.

1-Step & 2-Steps 1-Step process is very simple: The request intent is to charge an amount to the mobile line. When the server receives the request, it will check the user account associated with this line, and, if nothing prevents it, the amount is charged and will be either bill in next invoice or removed from current line credit.

For 2-steps, the first call is to request a payment preparation. The amount is not charged and the server has to be ready to get a confirmation or a cancellation to perform the payment. Only when the confirmation is done, payment is charged. Depending on business rules of the Telco operator, a 'prepared' payment could expire after a defined delay.

Identifier for the mobile line to be charged To identify the mobile line to be charged an identifier must be provided. This identifier is mapped to the endUserId attribute.

Notification URL Developers may provide a callback URL on which status change notifications, regarding the payment, can be received from the service provider. This is an optional parameter.

Sample API invocations are presented in Section 4.6.

3. Authentication and Authorization

The Carrier Billing Payment API makes use of the OAUTH 2.0 client credentials grant which is applicable for server to server use cases involving trusted partners or clients without any protected user data involved. In this method the API invoker client is registered as a confidential client with an authorization grant type of client_credentials [1].

4. API Documentation

4.1 API Version

0.7.0

4.2 Details

4.2.1 API sequencing

As described above, the API accommodates 2 distinct processes: one step process (direct request to charge) and two steps process (which requires an intermediate step to confirm/cancel a payment request)

Following diagram shows the API resources operation sequencing


PaymentSequence

4.2.1 API attributes

Attribute definition

Payment Class description:

Name Description Comment
endUserId Identify the mobile account to be charged - in general mobile number is provided Mandatory attribute in POST request
clientCorrelator Provided by the requester - Uniquely identifies this create charge request Optionally valued by requester
paymentAmount See PaymentAmount class table description Mandatory attribute in POST request
referenceCode Merchant generated payment reference to uniquely identify the request, for example the purchase or order identifier Mandatory attribute in POST request
transactionOperationStatus Specifies the payment status (example: Processing, Denied, Reserved, Succeeded, Cancelled) Must be valued by server side (not in POST request)
resourceURL URI of the created resource (same as in the Location header) Only valued (optionally) by server side (not in POST request)
serverReferenceCode Reference to the charge or refund, provided by the server, and meaningful to the server’s backend system for the purpose of reconciliation Only valued (optionally) by server side (not in POST request)
paymentCreationDate Date when the payment is created in server data base. This is a technically information Only valued (optionally) by server side (not in POST request)
paymentDate Date when the payment is effectively performed. This is a business information. Only valued (optionally) by server side (not in POST request)
notificationUrl Allows asynchronous delivery of purchase related events Optionally valued by requester - if used, customer needs to have a notification endpoint
notificationAuthToken Authentification token for callback API (if provided) Optionally valued by requester

PaymentAccount class description:

2 classes are defined:

ChargingInformation:

Name Description Comment
amount Amount to be charged or reserved (number) Mandatory attribute in POST request
currency Currency identifier as defined in [ISO4217] Mandatory attribute in POST request
description Description text to be used for information and billing text Mandatory attribute in POST request

ChargingMetaData

Name Description Comment
onBehalfOf Allows aggregators/partners to specify the actual payee Optionally valued by requester
purchaseCategoryCode Allows aggregators/partners to specify the actual payee Optionally valued by requester
channel Channel where the order occurred Optionally valued by requester
isTaxIncluded if true, the amount is tax included, if false the amount is provided without tax. In both case, taxAmount could be valued to provide tax amount. Optionally valued by requester
taxAmount The tax amount charged by the merchant if the charge has tax already included (number). This also provides an indicator to the downstream billing system Optionally valued by requester
serviceId Identifier of service related to the payment Optionally valued by requester
productId Identifier of product related to the payment Optionally valued by requester

Payment State engine

Follow schema provides information about the payment state engine (state description & transition)

PaymentState

4.3 Endpoint Definitions

Following table defines API endpoints of exposed REST based for Carrier Billing Payment API management operations.

Endpoint Operation Description
POST
<base-url>/payment/v0/payments
Create one step payment Create request for one step payment
POST
<base-url>/payment/v0/payments/prepare
Create two steps payment Create request for two steps payment
POST
<base-url>/payment/v0/payments/{paymentId}/confirm
Confirm a two steps payment Confirmation request for a prepared payment
POST
<base-url>/payment/v0/payments/{paymentId}/cancel
Cancel a two steps payment Cancellation request for a prepared payment
GET
<base-url>/payment/v0/payments
Query for payment Querying for payment(s) with criteria
GET
<base-url>/payment/v0/payments/{paymentId}
Retrieve payment Retrieve payment

Carrier Billing Payment Resource Operations:


Create payment resource (one step)
HTTP Request
POST <base-url>/payment/v0/payments
Query Parameters
No query parameters are defined.
Path Parameters
endUserId must be provided
Request Body Parameters
See above table for attribute definition.
Following attributes are mandatory in the request: endUserId; paymentAmount.chargingInformation.amount; paymentAmount.chargingInformation.currency ; paymentAmount.chargingInformation.description ; referenceCode.
Following attributes are only valued on server side and not present in POST request: transactionOperationStatus; resourceURL ; serverReferenceCode.


Response
201: payment created
Response body: A complete payment representation as described in above table is provided.
400: Invalid input.
401: Un-authorized.
403: Forbidden.

409: Conflict.
500: Server Error.
503: Service temporarily unavailable.

Create payment resource (two steps)
HTTP Request
POST <base-url>/payment/v0/payments/prepare
Query Parameters
No query parameters are defined.
Path Parameters
endUserId must be provided
Request Body Parameters
See above table for attribute definition. Following attributes are mandatory in the request: endUserId; paymentAmount.chargingInformation.amount; paymentAmount.chargingInformation.currency ; paymentAmount.chargingInformation.description ; referenceCode. Folowing attributes are only valued on server side and not present in POST request: transactionOperationStatus; resourceURL ; serverReferenceCode.

Response
201: payment created
Response body: A complete payment representation as described in above table is provided.
400: Invalid input.
401: Un-authorized.
403: Forbidden.

409: Conflict.
500: Server Error.
503: Service temporarily unavailable.

Confirm payment task (only for two steps process)
HTTP Request
POST <base-url>/payment/v0/payments/confirm/{paymentId
Query Parameters
No query parameters are defined.
Path Parameters
PaymentId must be provided
Request Body Parameters
endUserId must be provided

Response
200: payment confirmation accepted
Response body: None

400: Invalid input.
401: Un-authorized.
403: Forbidden.

409: Conflict.
500: Server Error.
503: Service temporarily unavailable.

Cancel payment task (only for two steps process)
HTTP Request
POST <base-url>/payment/v0/payments/cancel/{paymentId}
Query Parameters
No query parameters are defined.
Path Parameters
endUserId and PaymentId must be provided
Request Body Parameters
endUserId must be provided

Response
202: payment cancellation accepted
Response body: None

400: Invalid input.
401: Un-authorized.
403: Forbidden.

409: Conflict.
500: Server Error.
503: Service temporarily unavailable.

Query for payment resource

Quering payment Resource /id information
HTTP Request
GET<base-url>/payment/v0/payments/{paymentId}
Query Parameters
No query parameters are defined.
Path Parameters
paymentId: paymentId id that was obtained from the Create payment operation.
Request Body Parameters
No request body parameters are defined.
Response

200: Payment information returned.
Response body:
Complete payment representation as defined in the above table.

401: Un-authorized.
403: Forbidden.
404: Payment not found.
503: Service temporarily unavailable.

Quering payment Resource /list information
HTTP Request
GET<base-url>/payment/v0/payments/{paymentId}
Query Parameters
No query parameters are defined.
Path Parameters
endUserId: Identify the mobile account charged - in general mobile number is provided
fields: Comma-separated attributes to be provided in response
offset: Requested index for start of resources to be provided in response
limit: Requested number of resources to be provided in response
Request Body Parameters
No request body parameters are defined.
Response

200: a list of payment(s).
Response body:
An array of payment representation (could be a subset of a complete representation depending on fields filtering).
Note: It could be empty list if no payment match search criteria.

401: Un-authorized.
403: Forbidden.

503: Service temporarily unavailable.

4.4 Errors

Since CAMARA Carrier Billing Payment API is based on REST design principles and blueprints, well defined HTTP status codes and families specified by community are followed [2].

Details of HTTP based error/exception codes for the Carrier Billing Payment API are described in Section 4.3 of each API REST based method. Following table provides an overview of common error names, codes, and messages applicable to Carrier Billing Payment API.

No Error Name Error Code Error Message
1 400 INVALID_INPUT "Expected property is missing: endUserId"
2 400 INVALID_INPUT "Expected property is missing: referenceCode"
3 400 INVALID_INPUT "Expected property is missing: paymentAmount.chargingInformation.amount"
4 400 INVALID_INPUT "Expected property is missing: paymentAmount.chargingInformation.currency"
5 400 INVALID_INPUT "Expected property is missing: paymentAmount.chargingInformation.description"
6 400 INVALID_INPUT "Expected property is missing: paymentId"
7 400 INVALID_INPUT "Expected property is missing: qos"
8 400 INVALID_INPUT "Payment status does not allow to confirm it"
9 400 INVALID_INPUT "Payment status does not allow to cancel it"
10 401 UNAUTHORIZED "No authorization to invoke operation"
11 403 FORBIDDEN "Operation not allowed"
12 404 NOT_FOUND "Payment Id does not exist"
13 409 CONFLICT "Another payment is created for the same client correlator"
14 500 INTERNAL "Payment could not be created"
15 503 SERVICE_UNAVAILABLE "Service unavailable"

4.5 Policies

N/A

4.6 Code Snippets


Snippet 1, elaborates REST based API call with "*curl"* to create a payment for a Video on demand payment

Please note, the credentials for API authentication purposes need to be adjusted based on target security system configuration.

Snippet 1. Create Payment resource
curl -X 'POST' https://sample-base-url/payment/v0/payments
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbG...."
-d '{
"amountTransaction": {
"endUserId": "+33068741256+d",
"paymentAmount": { "chargingInformation": { "amount": 2.99, "currency": "EUR", "description": "VOD charge" },
"chargingMetaData": {
"onBehalfOf":"VOD Service",
"purchaseCategoryCode": "Purchase Movie",
"channel": "TV",
"taxAmount": 0.84,
"isTaxIncluded": true,
"serviceId": "N/A",
"productId": "vod-47" }
},
"referenceCode": "vod081220225698",
"clientCorrelator": "78g9-dfg6-fgtr6" },
"notificationUrl": "https://callback..."
response will be:
201
-d '{
"amountTransaction": {
"endUserId": "+33068741256+d",
"paymentAmount": { "chargingInformation": { "amount": 2.99, "currency": "EUR", "description": "VOD charge" },
"chargingMetaData": {
"onBehalfOf":"VOD Service",
"purchaseCategoryCode": "Purchase Movie",
"channel": "TV",
"taxAmount": 0.84,
"isTaxIncluded": true,
"serviceId": "N/A",
"productId": "vod-47" }
},
"referenceCode": "vod081220225698",
"clientCorrelator": "78g9-dfg6-fgtr6",
"transactionOperationStatus": "succeeded",
"resourceURL": "https://localhost:9091/payment/v0/payments/7896321",
"serverReferenceCode": "7896321" },
"paymentCreationDate" : "2023-03-10T15:30:58.139Z",
"paymentDate" : "2023-03-10T15:31:04.139Z",
"notificationUrl": "https://callback..." }'

4.7 FAQ's

(FAQs will be added in a later version of the documentation)

4.8 Terms

N/A

4.9 Release Notes

0.6 Release note

  • Added status attribute in Error
  • Added attribute notificationAuthToken

0.7 Release note

  • Added paymentCreationDate & PaymentDate
  • Added isTaxIncluded flag

References

[1] CAMARA Commonalities : Authentication and Authorization Concept for Service APIs
[2] HTTP Status codes spec