https://www.gccmerchant.com/api
Authentication is done using an API key and a secret. To generate this pair, go to the API page
Say the client wants to make a request to
POST https://www.gccmerchant.com/api/
With a payload of
{
"request": "/order/new",
"nonce": "1234",
"option1": ...
}
The nonce provided must be strictly increasing.
To authenticate a request, use the following:
payload = parameters-dictionary -> JSON encode -> base64
signature = HMAC-SHA384(payload, api-secret) as hexadecimal
send (api-key, payload, signature)
These are encoded as HTTP headers named:
X-GCC-APIKEY
X-GCC-PAYLOAD
X-GCC-SIGNATURE
Requests parameters for POST requests (authenticated) (presented below in the "Request" sections) are part of the PAYLOAD, not GET parameters.
Requests parameters for GET requests (non-authenticated) are GET parameters, appended to the call URL like this:
/call/?parameter=value
POST /create_invoice
Key | Type | Description |
---|---|---|
price_currency | [float] | what client can use to pay this invoice, for now it will be GCC overtime |
base_price | [string] | amount to pay |
base_price_currency | [string] | What kind of currency in EUR/USD/GCC/BTC Customer shop using for this request |
callback_url | [url] | where to send ping-back about invoice status changing |
redirect_url | [url] | where to redirect shop client |
order_id | [int] | where to redirect shop client |
refund_address | [string] | An address to return funds to the customer in the event of cancellation/refunding it |
item_description | [string] | Optional description of item |
Key | Type | Description |
---|---|---|
id | [string] | A unique id for the invoice |
status | [string] | The status (state) of the invoice |
payment_address | [string] | The address to pay the invoice in GCC |
price | [string] | A price to pay, calculated in GCC |
crypto_balance_due | [string] | This is equal to price, unless the invoice was underpaid and a balance remains |
price_currency | [string] | The currency the invoice is to be paid. (mostly it is GCC) |
base_price | [string] | The value of good or shop being purchased. |
base_price_currency | [string] | The value of good or shop being purchased (EUR/USD/GCC/BTC) |
service_fee_rate | [string] | Per transaction service fee. 0.01 = 1% |
spot_rate | [string] | exchange rate based on GCC Merchant Price ie. 25.00 GCC/USD |
inverse_spot_rate | [string] | exchange rate based on GCC Merchant Price ie. 0.002 USD/GCC |
crypto_url | [string] | Wallet friendly url - this can be used to generate payable QR Code. |
gateway_url | [string] | URL to this invoice on the hosted gateway. Redirect shop client here, or use an iframe |
redirect_url | [string] | Valid url where the customer will be sent after a payment through the hosted gateway |
order_id | [string] | Identifier for tracking the order from customer shop system |
item_description | [string] | Optional description of item |
refund_address | [string] | An address to return funds to the customer in the event of |
callback_url | [string] | Valid url where the webhook notifications will be sent after a payment through the hosted gateway |
merchant_id | [string] | Unique identifier for the issuing customer shop |
POST /check_invoice
Key | Type | Description |
---|---|---|
invoice_id | [string] | Invoice id is the unique number of get from create invoice method response |
Key | Type | Description |
---|---|---|
id | [string] | A unique id for the invoice |
status | [string] | The status (state) of the invoice |
payment_address | [string] | The address to pay the invoice in GCC |
price | [string] | A price to pay, calculated in GCC |
crypto_balance_due | [string] | This is equal to price, unless the invoice was underpaid and a balance remains |
price_currency | [string] | The currency the invoice is to be paid. (mostly it is GCC) |
base_price | [string] | The value of good or shop being purchased. |
base_price_currency | [string] | The value of good or shop being purchased (EUR/USD/GCC/BTC) |
service_fee_rate | [string] | Per transaction service fee. 0.01 = 1% |
spot_rate | [string] | exchange rate based on GCC Merchant Price ie. 25.00 GCC/USD |
inverse_spot_rate | [string] | exchange rate based on GCC Merchant Price ie. 0.002 USD/GCC |
crypto_url | [string] | Wallet friendly url - this can be used to generate payable QR Code. |
gateway_url | [string] | URL to this invoice on the hosted gateway. Redirect shop client here, or use an iframe |
redirect_url | [string] | Valid url where the customer will be sent after a payment through the hosted gateway |
order_id | [string] | Identifier for tracking the order from customer shop system |
item_description | [string] | Optional description of item |
refund_address | [string] | An address to return funds to the customer in the event of |
callback_url | [string] | Valid url where the webhook notifications will be sent after a payment through the hosted gateway |
merchant_id | [string] | Unique identifier for the issuing customer shop |
POST /create_wallet
Key | Type | Description |
---|---|---|
callback | [string] | (optional)Callback url for get the notification |
Key | Type | Description |
---|---|---|
result | [string] | "success" or "error" |
address | [string] | The deposit address (or error message if result = "error") |
POST /send
Key | Type | Description |
---|---|---|
address | [string] | Withdraw address |
amount | [float] | amount you need to send to withdraw address |
Key | Type | Description |
---|---|---|
result | [string] | "success" or "error" |
tx_hash | [string] | Transaction id of the particular transaction |
POST /balance
POST /list_wallet
Key | Type | Description |
---|---|---|
address | [string] | Wallet address |
POST /list
<? $key = "yB8FTD7Lhj3DFG8AuayTiHcj87UTUWEsxN7qqfcIzgleWtOqEm"; $secret = "jX4wgcEb6y7K1Fx96YojGXz2cvv0Wang7rNoErzK0Hu1n2bt0A"; // generate a nonce to avoid problems with 32bits systems $mt = explode(' ', microtime()); $req['request'] = "/create_wallet"; $req['nonce'] = $mt[1].substr($mt[0], 2, 6); // generate the POST data string $post_data = base64_encode(json_encode($req)); $sign = hash_hmac('sha384', $post_data, $secret); // generate the extra headers $headers = array( 'X-GCC-APIKEY: '.$key, 'X-GCC-PAYLOAD: '.$post_data, 'X-GCC-SIGNATURE: '.$sign, ); // curl handle (initialize if required) static $ch = null; if (is_null($ch)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Bter PHP bot; '.php_uname('a').'; PHP/'.phpversion().')' ); } curl_setopt($ch, CURLOPT_URL, "https://www.gccmerchant.com/api/create_wallet"); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $res = curl_exec($ch); if ($res === false) throw new Exception('Curl error: '.curl_error($ch)); echo json_decode($res); ?>