Welcome to our support center

Developers

Updating Contracts

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.

  • API Overview
  • API Key and Merchant ID
  • Subscription & Contract APIs

Overview

The updateTemplateContract API allows modification on contract templates without the use of the merchant console. The optional fields passed in the request should be limited to the details needing to be updated.


Parameters

The updateTemplateContract API takes the following parameters:

  • merchant_id - The merchant ID that can be found within the merchant console. (Compulsory)
  • apikey - 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 template (Compulsory)
  • ct_frequency - The JSON frequency data - See above for how to format this (Optional)
  • ct_total_amount - The recurring amount in New Zealand Dollars (Optional)
  • ct_initial_amount - The initial setup amount in New Zealand Dollars.
    This can be set to 0 if not required (Optional)
  • ct_tnc - The terms and conditions of the subscription (Optional)
  • ct_name - Subscription name (Optional)
  • ct_description - Subscription description (Optional)
  • ct_total_amount_aud - The total amount in AUD (Optional)
  • ct_total_amount_cad - The total amount in CAD (Optional)
  • ct_total_amount_cny - The total amount in CNY (Optional)
  • ct_total_amount_eur - The total amount in EUR (Optional)
  • ct_total_amount_gbp - The total amount in GBP (Optional)
  • ct_total_amount_hkd - The total amount in HKD (Optional)
  • ct_total_amount_jpy - The total amount in JPY (Optional)
  • ct_total_amount_sgd - The total amount in SGD (Optional)
  • ct_total_amount_zar - The total amount in ZAR (Optional)
  • ct_total_amount_krw - The total amount in ZAR (Optional)
  • ct_total_amount_usd - The total amount in USD (Optional)
  • ct_initial_amount_aud - The initial amount in AUD (Optional)
  • ct_initial_amount_cad - The initial amount in CAD (Optional)
  • ct_initial_amount_cny - The initial amount in CNY (Optional)
  • ct_initial_amount_eur - The initial amount in EUR (Optional)
  • ct_initial_amount_gbp - The initial amount in GBP (Optional)
  • ct_initial_amount_hkd - The initial amount in HKD (Optional)
  • ct_initial_amount_jpy - The initial amount in JPY (Optional)
  • ct_initial_amount_sgd - The initial amount in SGD (Optional)
  • ct_initial_amount_zar - The initial amount in ZAR (Optional)
  • ct_initial_amount_krw - The initial amount in KRW (Optional)
  • ct_initial_amount_usd - The initial amount in USD (Optional)
  • ct_duration - The JSON duration data. Leave empty if subscription is on-going.
    See above for how to format this (Optional)


Example Request

Example updateTemplateContract API call:

https://api.cybercompay.com/updateTemplateContract.php?apikey=ida8463534kawhdi347d39h078dt3383&merchant_id=123E59334B8338&contract_id=B249FD2EA2F18&ct_name=Magazine+Subscription&ct_total_amount=1.99

If the API call was successful, it will return a response in JSON format.


Responses

API response example:

{"response_code":200,"message":"OK","data":{"contract_id":"B249FD2EA2F18"}}


Test Code

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(
    'apikey' => 'ida8463534kawhdi347d39h078dt3383',
    'merchant_id' => '123E59334B8338',
    'contract_id' => 'B249FD2EA2F18',
    'ct_name' => 'Magazine Subscription',
    'ct_total_amount' => '1.99'
);

//Make the request to the server
$result = post_to_url("https://merchant.cybercompay.com/examples/updateTemplateContract.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));