Requesting the configuration of the Store extension.
support, ws.webtv, api, store, config, get
GET vars specific to this request:
Var | Value | Description |
go | store | The API section |
do | get_config | The API action |
Resulting Request URL:
The resulting request URL would be similar to this (don't forget to append the required info: key, timestamp, salt and signature):
https://....../api.php?go=store&do=get_config&{required information}
None. No POST vars are required for this request.
If the request was successful, you'll receive a response containing:
• data: An array with the config data.
The name of the data indexes are pretty self-explanatory but it is worth detailing the following:
- currency_symbol_position: (int) The position for the currency symbol, in the amounts. Possible values: 0 (prefix - Ex. €10), 1 (suffix - Ex. 10€).
- min_purchase_amount: (decimal) The minimum required purchase amount (it is not possible to place an order whose total amount due is lower than this value).
Example:
{ "data": { "currency_code": "EUR", "currency_id": "5", "currency_symbol": "\u20ac", "currency_symbol_position": "1", "min_purchase_amount": "4.00", "payment_methods": [{ "id": "1", "name": "BANK", "settings": { "bank_name": "", "bank_address": "", "bank_account": "", "bank_iban": "", "bank_swift": "", "bank_message": "" }, "enable_rp": "0" }, { "id": "3", "name": "EXTERNAL_GATEWAY", "settings": { "external_gateway_url": "http:\/\/www.mywebtvdomain.com\/external_payment_processor.php", "external_gateway_key": "XASW89GGH34RTZDF" }, "enable_rp": "1" }, { "id": "2", "name": "PAYPAL", "settings": { "pp_client_id": "", "pp_secret": "", "pp_username": "info_api1.mywebtvdomain.com", "pp_password": "R302XBAQDAYFJ8HP", "pp_signature": "XnS5s1Kso7MWUdW2ErQKJJJ4qi4-8F-OrbybrDfT0oJ3IGAklzfkhUy.", "pp_sandbox": "0" }, "enable_rp": "1" }], "support_email": "admin@mywebtvdomain.com" } }
If the request failed (for example, if no signature was provided in the request), you'll receive a response like the following:
{ "error" : "REQUEST_ERROR", "error_long" : "Missing signature" }
Possible Error Messages
Check the general errors.
Preparing GET and POST data.
// The GET vars $GET_VARS = array( "go" => "store", "do" => "get_config" ); // The POST vars $POST_VARS = array();
Generating the salt, timestamp, signature and sending the request
*** The following code block is common to all signed requests ***
// Collect the API Base URL and Credential info $API_URL = "https://www.mywebtvdomain.tv/api.php"; $API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee"; $API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // keep this safe!!! // Generating salt and timestamp $salt = md5(mt_rand()); $timestamp = time(); $signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // Generating the validation signature // - Default method: using base64_encode(hash_hmac(...)) $signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // comment this line if using the next method // - Simplified method - available since v60: using md5(). // This method requires the variable $API_SIGNATURE_GENERATION_MODE = 1; in the config/Config.inc.php file. // $signature = md5($salt."-".$timestamp."-".$API_SHARED_SECRET); // you must "uncomment" this line when using the simplified method // Append the timestamp, salt, key and signature to the GET vars $GET_VARS["timestamp"] = $timestamp; // UTC timestamp $GET_VARS["salt"] = $salt; $GET_VARS["key"] = $API_KEY_ID ; // The API Key ID: This is public and is used by the API to identify the application; $GET_VARS["signature"] = $signature; // Create the request URL. Please note that if you do not use PHP buit in function // to create the HTTP query then don't forget to URL encode the values $REQUEST_URL = $API_URL."?".http_build_query($GET_VARS); // The previous will build an URL like .../api.php?go=api_subject&do=api_action&etc... // Create a new cURL resource and set the appropriate options $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $REQUEST_URL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_VARS); // If your PHP host does not have a valid SSL certificate, you will need to turn off SSL // Certificate Verification. This is dangerous (!), and should only be done temporarily // until a valid certificate has been installed curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate. // Sending the request to the API $response = curl_exec($ch); // Processing the response if (!$response) { echo 'API call failed'; } else { print_r(json_decode($response,true)); }