Welcome to our support center
Updating credit card Information
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.
- API Overview
- API Key and Merchant ID
- Subscription & Contract APIs
The fetchUpdateCardUrl API is used to return the url of a page that a user can use to update their credit card details. The API authenticates with merchant_id and API key, and loads the subscribers data based off a contract_id that must be passed in.
When a user subscribes, a subscription is created and assigned a contract_id. This ID is the reference that is used throughout the CyberCom Pay system. Card data and subscriber details relate back to the contract_id.
The API takes the following parameters as either GET or 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)
- contract_id - The contract ID of the user's subscription (Compulsory)
Example fetchUpdateCardUrl API call:
If the API call was successful, it will return the following data in JSON format.
Calling the address in the 'url' parameter will load a form for the subscriber to update their card with. This page is authenticated with the'identifier_id' parameter in the url.
Please note that there is a one-to-one relationship between a subscription and a registered credit card. The credit card being updated will only affect the subscription that was loaded by the contract_id originally passed into the fetchUpdateCardUrl API call. Other active subscriptions using the same card will not be updated.The update card page
The page used to update credit cards (https://subscription.cybercompay.com/update-card.php) will return errors if it loads incorrectly.
The following errors can be returned:
- Error: Empty identifier_id - The identifier_id passed into the page is missing.
- Error: Contract is not active - The subscription contract belonging to a subscriber has been made inactive, or is suspended
- Error: Can not find contract- The system can not find the associated contract.
This is a system error, and shouldn't occur under normal situations.
- Error: No identifier data - The identifier data is empty.
If this error occurs, call the fetchUpdateCardUrl API again to create another identifier_id.
API response example:
Below is an example code that will work against a test section of the server. Although this is intended to simulate server behaviour, characteristics and responses are not always the same.
Please note that no transactions will be sent online and the server will not store any information from these requests. For more information on this, please see Testing Without An Account
<?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', 'contract_id' => 'B249FD2EA2F18' ); //Make the request to the server $result = post_to_url("https://merchant.cybercompay.com/examples/fetchUpdateCardUrl.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));