Skip to main content
Skip table of contents

Authentication

Note: All requests must be sent via the https transport protocol.

To use the Smobilpay S3P API each request must be authenticated according to the S3P Authorization Standard. This method ensures that each request is:

  • secure

  • unique

  • protected against malicious or unintentional duplication and/or replay requests

The core principle of the standard consists of the creation of a complex authentication string composed of multiple authentication elements, most notably a signature calculated from parts of the URL and request body. This authentication string is unique for every request and needs to be provided in the default Authorization header.

Example:

CODE
Authorization: s3pAuth,s3pAuth_nonce="634968823463411609",s3pAuth_signature="V5F+YLj2vQNTfZrmg3OYPFZJ4hw=",s3pAuth_signature_method="HMAC-SHA1",s3pAuth_timestamp="1361281946",s3pAuth_token="xvz1evFS4wEEPTGEFPHBog" 


Thus, the Authorization header value is a single string of authorization parameter key/value pairs joined by:

  1. The signature domain “s3pAuth”

  2. Parameter key followed by an = character (ASCII code 61) and a double quote " character (ASCII code 34)

  3. Parameter value followed by a double quote " character (ASCII code 34)

  4. Repeat 2+3 for all key/pairs, separating them with a comma character (ASCII code 44)

Credentials

Credentials are provided in form of a Public access token and access secret - provided as a pair and bound to an API user account in Smobilpay. This account is created and managed by the collector company administrator. The token and secret are displayed in the "APIs Access Details" section of the user profile after login. Both can and should be regularly regenerated. It is very important to note that this data is incredibly sensitive and should never be shared with anyone.

Authorization Header Elements

The Authorization is made up of the following elements

Element

Type

Description

Source

s3pAuth_nonce

String

The s3pAuth_nonce parameter requires a random unique string token to be generated for each request. S3P API will use this value to determine whether a request has been submitted multiple times. Using the same nonce in subsequent requests will result in an error.
Example:
AYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg

Generated per request by client

s3pAuth_signature

String

The s3pAuth_signature is obtained as the result of the cryptographic signature using the s3pAuth_signature_method algorithm.
The purpose of the signature is that S3P API can verify that the request has not been modified in transit, verify the user sending the request and verify that the application making the call has authorization to interact with the user's account.


Note: The process for computing the s3pAuth_signature for this request is described in the next section
Example:
V5F+YLj2vQNTfZrmg3OYPFZJ4hw=

CALCULATED per request by client

s3pAuth_signature_method

String

The s3pAuth_signature_method used by S3P API is the Keyed-Hash Message Authentication Code (HMAC).
Constant:
"HMAC-SHA1"

Fixed Value

s3pAuth_timestamp

Integer

The s3pAuth_timestamp parameter indicates when the request was created in UTC. This value needs to be a standard UNIX timestamp (number of seconds since the Unix epoch) at the point the request is generated, S3P API will reject requests which were created too far in the past (older than 300 seconds/5 Minutes)
Example:
1361281946 

Generated per request by client

s3pAuth_token

String

The s3pAuth_token parameter contains the public access token of the user sending the request. Provided by Smobilpay company administrator.
Example:
6ae69f6a-bcc5-11e4-8dfc-aa07a5b093db

Fixed Value per API User

Generate Authorization header

In order to generate the s3pAuth_signature signature, the following steps are necessary:

  1. Combine the http verb of the request endpoint you are calling, the endpoint FQDN, the alphabetically ordered authorization and request parameter keys and their corresponding values into a single string.

  2. percentage encode the resulting string to form the encoded string

  3. Calculate signature using the access secret

The following section demonstrates step-by-step how to generate the signature. NOTE: The URL used in the examples (https://dev.smobilpay.com) is for illustrations only - and not a valid S3P API URL.

Request Examples

Example for POST request

Example for GET request

API User Credentials (Public access token and access secret)

Public: xvz1evFS4wEEPTGEFPHBog

Secret: MySecretKey

Public: xvz1evFS4wEEPTGEFPHBog

Secret: MySecretKey

Scenario

Client wants to request a quote for a payment collection worth 1000.00for payment item id "SPAY-DEV-958-AES-100013333-10010"

Client wants to search for a bill by bill number “TestId” for the merchant “TESTMERC” and the service with id “99999

URL of Endpoint to call

https://dev.smobilpay.com/s3p/v2/quotestd

https://dev.smobilpay.com/s3p/v2/bill?serviceNumber=TestId&merchant=TESTMERC&serviceid=99999

HTTP Method API endpoint

POST

GET

Request Body

"payItemId":"SPAY-DEV-958-AES-100013333-10010","amount":"1000"

n/a (no body in GET requests)

s3pAuth_nonce

634968823463411609

634968823463411611

s3pAuth_signature_method

HMAC-SHA1

HMAC-SHA1

s3pAuth_timestamp

1361281946

1361281946

s3pAuth_token

xvz1evFS4wEEPTGEFPHBog

xvz1evFS4wEEPTGEFPHBog

Signature Calculation

Step 1: Generate parameter string by joining all components in alphabetical order (Note that for POST requests the parameters are taken from the BODY while for GET requests the parameters are taken from the query URL)

amount=1000&payItemId=SPAY-DEV-958-AES-100013333-10010&s3pAuth_nonce=634968823463411609&s3pAuth_signature_method=HMAC-SHA1&s3pAuth_timestamp=1361281946&s3pAuth_token=xvz1evFS4wEEPTGEFPHBog

merchant=TESTMERC&s3pAuth_nonce=634968823463411611&s3pAuth_signature_method=HMAC-SHA1&s3pAuth_timestamp=1361281946&s3pAuth_token=xvz1evFS4wEEPTGEFPHBog&serviceNumber=TestId&serviceid=99999

Step 2: Assemble Base String by joining in the HTTP Verb + FQDN and percentage encoding the entire string

POST&https%3A%2F%2Fdev.smobilpay.com%2Fs3p%2Fv2%2Fquotestd&amount%3D1000%26payItemId%3DSPAY-DEV-958-AES-100013333-10010%26s3pAuth_nonce%3D634968823463411609%26s3pAuth_signature_method%3DHMAC-SHA1%26s3pAuth_timestamp%3D1361281946%26s3pAuth_token%3Dxvz1evFS4wEEPTGEFPHBog

GET&https%3A%2F%2Fdev.smobilpay.com%2Fs3p%2Fv2%2Fbill&merchant%3DTESTMERC%26s3pAuth_nonce%3D634968823463411611%26s3pAuth_signature_method%3DHMAC-SHA1%26s3pAuth_timestamp%3D1361281946%26s3pAuth_token%3Dxvz1evFS4wEEPTGEFPHBog%26serviceNumber%3DTestId%26serviceid%3D99999

Step 3: Calculate Signature (hmac + access secret)

1CLm+TQLwelkE+5Za+Vi+7G5M8U=

wff4LW5sueJe0K4Uzk7fHrjElGk=

Resulting Authorization Header

s3pAuth,s3pAuth_nonce="634968823463411609", s3pAuth_signature="1CLm+TQLwelkE+5Za+Vi+7G5M8U=", s3pAuth_signature_method="HMAC-SHA1", s3pAuth_timestamp="1361281946",s3pAuth_token="xvz1evFS4wEEPTGEFPHBog"

Authorization: s3pAuth, s3pAuth_nonce="634968823463411611", s3pAuth_signature="wff4LW5sueJe0K4Uzk7fHrjElGk=", s3pAuth_signature_method="HMAC-SHA1", s3pAuth_timestamp="1361281946",s3pAuth_token="xvz1evFS4wEEPTGEFPHBog"

Hints

Step 1: Generating string by joining alphabetically ordered parameters

  1. Parameter keys and values are case sensitive

  2. Key and value are separated by the '=' character

  3. Separate key/value pairs with the '&' character

  4. Make sure white spaces are trimmed

  5. Make sure all parameters are sorted alphabetically (see http://www.asciitable.com) by the parameter keys (a,b,c…). Consider that uppercase values are smaller than lowercase values. Failing to do so will result in a wrong signature being computed

Alphabetical sorting example:

Parameter keys unsorted

Parameter Keys sorted in alphabetical order

  • s3pAuth_timestamp

  • s3pAuth_token

  • s3pAuth_nonce

  • s3pAuth_signature_method

  • payItemId

  • amount

  1. amount

  2. payItemId

  3. s3pAuth_nonce

  4. s3pAuth_signature_method

  5. s3pAuth_timestamp

  6. s3pAuth_token

Step 2: Assembling the base string

In this step, the three values collected so far (HTTP method, FQDN, Parameter string from step 1) must be joined to create a single string, from which the signature will be generated:

  1. Convert the HTTP Method to uppercase

  2. Append the '&' character

  3. Append the Percentage encoded FQDN

  4. Append the '&' character

  5. Append the Percentage encoded parameter string from step 1

For more on Percentage coding (URL encoding), refer to the following RFC: (http://tools.ietf.org/html/rfc3986.html)
Most programming languages offer functions to perform this task. For example:

Step 3: Signature calculation

The actual signature is calculated by passing the base string created in Step 2 and the access secret into the HMAC-SHA1 hashing algorithm. The details of the algorithm are explained in depth here http://en.wikipedia.org/wiki/HMAC.
Some support tools:

The output of the HMAC signing function is a binary string which must be base64 encoded to produce the final signature string to be used as the parameter value in "s3pAuth_signature".

Example

CODE
Base String: POST&https%3A%2F%2Fdev.smobilpay.com%2Fs3p%2Fv2%2Fquotestd&amount%3D1000%26payItemId%3DSPAY-DEV-958-AES-100013333-10010%26s3pAuth_nonce%3D634968823463411609%26s3pAuth_signature_method%3DHMAC-SHA1%26s3pAuth_timestamp%3D1361281946%26s3pAuth_token%3Dxvz1evFS4wEEPTGEFPHBog
Secret: MySecretKey 
Signatur (base64): 1CLm+TQLwelkE+5Za+Vi+7G5M8U=


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.