Welcome to our support center
Developers
Creating Tokens
Prerequistes
This section expects prior knowledge and understanding from the sections indicated below. Please note that these areas are essential to obtaining a successful response and notifying your server upon completion.
- Tokenization
- API Key and Merchant ID
Overview
This API will securely store a credit card and customer details then return a unique token for that card. After creating a token this may then be passed into chargeToken, where the calling server can charge the card one or more times.
Parameters
This API takes the following parameters only as POST data:
- merchant_id - The merchant ID that can be found within the merchant console. (Compulsory)
- api_key - The API Key associated with the merchant ID.
This is used to authorise and identify the caller of the request. (Compulsory) - card_number - The credit card number, will be validated by this API (Compulsory)
- card_expiry - The credit card expiry, must be in the format MMYY (Compulsory)
- name_on_card - The name on the credit card (Compulsory)
- card_security_code - The cards security code: CVV, CVV2 or CVC2 (Compulsory)
- customer_email - Customer email to store (Optional)
- customer_mobile - Customer mobile to store (Optional)
Example Request
https://api.cybercompay.com/createToken.php?api_key=ida8463534kawhdi347d39h078dt3383&merchant_id=123E59334B8338&card_number=1234123412341234&card_expiry=1215&name_on_card=Bob_Geoffrey&card_security_code=1234
Responses
If the API call was successful, it will return the following data in JSON format.
For information on the API response format and possible response codes, please see API Response Format
{"response_code":200,"message":"OK","data":{"card_token":"195ABAD331880E"}}
API response data fields:
- card_token - A unique token associated with the supplied card details
Test Code
<?php /** * Function used to make POST requests to the server using SSL. * * @param type $url The API URL that we want to send the request to. * @param type $data POST data that will be sent to the server. * @return false Returns the HTML response as a String. If an error has occured null will be returned. */ function post_to_url($url, $data) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $html = curl_exec($ch); if (curl_errno($ch) !== 0) { curl_close($ch); return false; } curl_close($ch); return $html; } //The POST data that will be sent to the server. $postData = array( 'api_key' => 'ida8463534kawhdi347d39h078dt3383', 'merchant_id' => '123E59334B8338', 'card_number ' => '1234123412341234', 'card_expiry ' => '1215', 'name_on_card' => 'Bob Geoffrey', 'card_security_code ' => '1234' ); //Make the request to the server $result = post_to_url("https://merchant.cybercompay.com/examples/createToken.php", $postData); //If we have encountered an error display something back to the customer. if ($result === false) { echo 'We have encountered an error!'; exit; } //Print the results. print_r(json_decode($result));