Card Info - API v2 documentation

Last update: March 8th, 2017

Summary

  1. Introduction
  2. Prerequisites
  3. Authentication
  4. Web Service Endpoints
  5. Response parameters description
  6. Libraries

1. Introduction

Card Info API represents the automated way of retrieving informations abount a given card.

2. Prerequisites

You should confirm with PayU that all necessary settings and configurations are correct on your merchant account and terminal.

3. Authentication

To authenticate your request you will need to provide:


Authentication can be done as following

1. Request parameter authentication
This implies to send two additional parameters in the POST request
  • merchant = your vendor code
  • signature = the signature hash
Curl post example request with a card number:
                curl https://secure.payu.ro/api/card-info/v2/ \
                -d cc_cvv=123 \
                -d cc_number=4111111111111111 \
                -d cc_owner=Daniel \
                -d dateTime=2017-03-02T12:04:24+00:00 \
                -d exp_month=12 \
                -d exp_year=2018 \
                -d merchant=CC1 \
                -d extraInfo=true \
                -d signature=7bad10e73f4ae85f41a03e846dba068647a795a4267772e71710bf91fbf50491
            

Curl post example request with a token:
                curl https://secure.payu.ro/api/card-info/v2/ \
                -d token=12334234 \
                -d dateTime=2017-03-02T12:04:24+00:00 \
                -d merchant=CC1 \
                -d extraInfo=true \
                -d signature=7bad10e73f4ae85f41a03e846dba068647a795a4267772e71710bf91fbf50491
            
 

Signature calculation

For security reason, each HTTP request must carry a unique signature. The signature is calculated using data from all parameters sent in the HTTP (excepting "signature", and including the authentication parameters), the Merchant's secret key and the HMAC method with SHA256 algorithm to encrypt data.

For example, let's consider that a Merchant (CC1 with secret key SECRET_KEY) sends the HTTP request to the API containing the following parameters and values:

        'cc_cvv' => '123'
        'cc_number' => '4111111111111111'
        'cc_owner' => 'Daniel'
        'exp_month' => '12'
        'exp_year' => '2018'
        'merchant' => 'CC1'
        'dateTime' => '2017-03-02T12:04:24+00:00'
    
or for Token method
        'merchant' => 'CC1'
        'token' => '2f69630c68a42f53da11b46e7e4ed0d3'
        'dateTime' => '2017-03-02T12:04:24+00:00'
    

Step 1: Sort the parameters sent in the HTTP POST request alphabetically by parameter name

NOTE Parameters should be sorted by their name (key), NOT their values.

Using the example, this is the order of significant parameters after the sort:

        'cc_cvv' => '123'
        'cc_number' => '4111111111111111'
        'cc_owner' => 'Daniel'
        'dateTime' => '2017-03-02T12:04:24+00:00'
        'exp_month' => '12'
        'exp_year' => '2018'
        'merchant' => 'CC1'
        
or for Token method
        'merchant' => 'CC1'
        'dateTime' => '2017-03-02T12:04:24+00:00'
        'token' => '2f69630c68a42f53da11b46e7e4ed0d3'
        

Step 2: Compose the source string by concatenating the values of each HTTP POST parameter above. Each value should be prepended by an integer representing its length

Now, based on this, the entire source string for the values of the sorted parameters at Step 1 will be:

31231641111111111111116Daniel252017-03-02T12:04:24+00:00212420183CC1
or for Token method
3CC1252017-03-02T12:04:24+00:00322f69630c68a42f53da11b46e7e4ed0d3

Step 3: Calculate the signature using HMAC with SHA256 as a hashing algorithm applied to the source string

For the calculated source string, the signature value will be:

            3d0c2e7dd853185fb1bad3b7de778c9330c8515c93ef400c5019a3ce23ee78a1
        
or for Token method
            c78208eed51af0f002f047b7ee4b1f88225bea5fe314c7d89b45848616187bb8
        

Step 4: Add the calculated signature value to the HTTP request before sending it to PayU

See Authentication for more information on how to send authentication credentials

PayU will also calculate the signature on its side using the data received, and it will match it against the signature sent by the Marketplace master account.

 

4. Web Service Endpoint

The Card Info Web Service is a REST-ful web service.

Get Card Info By card number

Description:
Get information about a card number.
API endpoint:
https://secure.payu.ro/api/card-info/v2/
Method:
POST
Parameters:
Field Type Description
merchant String The Merchant's code, available in Control Panel ([Account Management / Account Settings](https://secure.payu.ro/cpanel/account_settings.php))
dateTime String Time of the request in UTC. Format according to ISO_8601 (ex: 2017-02-21T15:17:47Z)
signature String HMAC_SHA256 signature applied on all parameters from the request. Source string for HMAC_SHA256 will be calculated by adding the length of each field value at the beginning of field value. A common key shared between PayU and the merchant is used for the signature. Find more details on how is HASH generated by clicking HERE.
cc_cvv String The CCV/CVV2 code for the card. For some card types this can be empty, otherwise it should have a numerical value.
cc_owner String The cardholder name of the card. For most of the cards, this can be omitted. When specified, it must be included in the hash calculation and will be used at hash validation on API side.
exp_year String The year in which the card used expires
exp_month String The month in which the card used expires
cc_number String Card Number - missing if token provide
extraInfo String This field is optional. If it is set to 'true', the response will contain extra info (if available) about the card (eg. Loyalty points). Not setting it or setting another value beside 'true' has the same effect. Nowever, if it is set, it must be included in the signature calculation.
Request:

Curl request example with request authentication parameters:

                curl https://secure.payu.ro/api/card-info/v2/ \
                -d cc_cvv=123 \
                -d cc_number=4111111111111111 \
                -d cc_owner=Daniel \
                -d dateTime=2017-03-02T11%3A58%3A45%2B00%3A00 \
                -d exp_month=12 \
                -d exp_year=2018 \
                -d merchant=CC1 \
                -d extraInfo=true \
                -d signature=7bad10e73f4ae85f41a03e846dba068647a795a4267772e71710bf91fbf50491
            
Response:

Returns card information for a given cardBin.

Response example:
            {
               "meta":{
                  "code":200,
                  "message":"success"
               },
               "cardInfo":{
                  "cardMask":"4111-xxxx-xxxx-1111",
                  "binNumber":"411111",
                  "cardBrand":"VISA",
                  "issuerBank":"BRD Groupe Societe Generale",
                  "issuerCountry":"Romania",
                  "cardType":"DEBIT",
                  "cardProfile":"CONSUMER",
                  "cardProgram":"",
                  "installmentOptions":[

                  ],
                  "loyaltyPoints":[

                  ]
               }
            }
        
HTTP Errors:
401 Unauthorized - See Authentication
500 Internal Server Error - please contact us if this error persists.

Error response example:
            {
               "meta":{
                  "code":401,
                  "message":"Missing datetime parameter."
               }
            }
        
The message parameter from response contains information about error.
Some possible values are:
  • Missing datetime parameter.
  • Request expired. Please make a new request.
  • Access denied. "merchant" not set.
  • Access denied. "signature" not set.
  • Access denied. Unauthorized access.
  • Account could not be found.
  • Provided card or token were not valid.
  • Invalid card expiration date.
  • Invalid CVV2/CVC2 code.
  • Invalid card number.

Get Card Info By Merchant Token

Description:
Get information about a card bin using merchant token.
API endpoint:
https://secure.payu.ro/api/card-info/v2
Method:
POST
Parameters:
Field Type Description
merchant String Merchant Identifier provided by PayU
dateTime String Time of the request in UTC. Format according to ISO_8601 (ex: 2017-02-21T15:17:47Z)
signature String Calculated signature according to above described algorithm
token String Card token. If specified exp informations are not required.
extraInfo String This field is optional. If it is set to 'true', the response will contain extra info (if available) about the card (eg. Loyalty points, Fx Info). Not setting it or setting another value beside 'true' has the same effect. Nowever, if it is set, it must be included in the signature calculation.
Request:

Request example with request authentication parameters:

                curl https://secure.payu.ro/api/card-info/v2/ \
                -d dateTime=2017-03-02T11%3A58%3A45%2B00%3A00 \
                -d merchant=CC1 \
                -d extraInfo=true \
                -d signature=7bad10e73f4ae85f41a03e846dba068647a795a4267772e71710bf91fbf50491
            
Response:

Returns card information for a given cardBin.

Response example:
            {
               "meta":{
                  "code":200,
                  "message":"success"
               },
               "cardInfo":{
                  "cardMask":"4111-xxxx-xxxx-1111",
                  "binNumber":"411111",
                  "cardBrand":"VISA",
                  "issuerBank":"BRD Groupe Societe Generale",
                  "issuerCountry":"Romania",
                  "cardType":"DEBIT",
                  "cardProfile":"CONSUMER",
                  "cardProgram":"",
                  "installmentOptions":[

                  ],
                  "loyaltyPoints":[

                  ],
                  "fxInfo": [

                  ],
                  "paymentMethod":"CCVISAMC"
               }
            }
        
HTTP Errors:
401 Unauthorized - See Authentication
404 Not Found - The information about token is not ready yet; please retry the request.
500 Internal Server Error - please contact us if this error persists.
            {
               "meta":{
                  "code":401,
                  "message":"Provided card or token were not valid."
               }
            }
        
The message parameter from response contains information about error.
  • Missing datetime parameter.
  • Request expired. Please make a new request.
  • Access denied. "merchant" not set.
  • Access denied. "signature" not set.
  • Access denied. Unauthorized access.
  • Account could not be found.
  • Provided card or token were not valid.

5. Response parameters description

Response example:
        {
           "meta": { // (mandatory) Meta data related to the status of the request

              "code":200, // (m) Response code. Possible values are 200  for success, 401 for error

              "message":"success" // (m) Response message. Possible values are "success" for response code 200 or error description for response code 401

           },
           "cardInfo":{ // (optional) Object containing the requested information. This will be missing in case response code is not 200

              "cardMask":"411111**********", // (m) Masked card number

              "binNumber":"411111", // (m) BIN(first 6 digits) of the requested card

              "cardBrand":"VISA", // (m) Possible values: VISA, MASTERCARD etc

              "issuerBank":"BRD Groupe Societe Generale", // (m) Name of the bank that issued the card

              "issuerCountry":"Romania", // (m) Name of the country where the card was issued

              "cardType":"DEBIT", // (m) Possible values: DEBIT, CREDIT

              "cardProfile":"CONSUMER", // (m) Possible values: CONSUMER, COMMERCIAL, UNKNOWN, NOT_FOUND, BOTH

              "cardProgram":"Name of the program", // (m) Name of the program in which the card is enrolled. Comes empty if the card is not enrolled in any.

              "installmentOptions":[ // (m) Array containing the installment plans (if any is available).
                    {
                        "installmentNumber": 1, // Number of installments for this installment plan

                        "installmentAditionalCostPercent": 0.00 // The additional cost aplied to the price for using this installment plan. eg: 0.05 translates to a 5% added to the price
                    },
                    {
                        "installmentNumber": 6,
                        "installmentAditionalCostPercent": 0.05
                    }
              ],
              "loyaltyPoints":[ // (m) Array containing the number and types of available loyalty points
                    {
                        "type": "FBB", // (m) Loyalty point type

                        "number": "60", // (m) Number of loyalty points
                        "moneyValue": {
                            "amount": "30", // (m) The value in money of those points. The value for the same number of points is different for each type of loyalty points

                            "currency": "USD" // (m) The currency in which the amount is converted
                        }
                    },
                    {
                        "type": "BNS",
                        "number": "40".
                        "moneyValue": {
                            "amount": "10",
                            "currency": "EUR"
                        {
                    }
              ],
              "fxInfo":[ // Array containing informatiom about the FX feature from the original order
                    "selectedCurrency": "EUR" // exchange currency used for the original order
              ],
              "paymentMethod":"CCVISAMC" //the payment method to be used for payments with this card
           }
        }
    

6. Libraries