API Access Information
You can get HUAWEIPIN API access information from your store panel. Parameters:
Parameter Name |
Description |
merchant_apikey |
Your API Key |
merchant_secretkey |
Your Secret Key |
merchant_oid |
Your Unique Order Number |
amount |
PIN amount to be converted to cash |
client_username |
Client Usrr Name Or User Account Number |
client_ip |
Client IP Address |
Successful API response
200 SUCCESS
{
"isSuccess": true,
"code": 200,
"errorMeesage": "Pin created successfully.",
"pin": "9999888877776666"
}
Error Codes
Response Codes & Descriptions
Code |
Description |
302 |
merchant_apikey cannot be empty |
303 |
merchant_secretkey cannot be empty |
304 |
amount Must be at least 5. |
305 |
merchant_oid Order Number cannot be empty |
306 |
Your API information is incorrect |
307 |
Store balance is not sufficient for this transaction. |
308 |
merchant_oid This order number has been used before. Use a unique number. |
Parametreler
Request data must be JSON
type
POST/
Parameters
Name |
Type |
Required |
Description |
merchant_apikey |
string |
Yes |
Store Api-Key (Will be obtained from the store panel) |
merchant_secretkey |
String |
Yes |
Store Secret-Key (Will be obtained from the store panel) |
merchant_oid |
Unique order number |
amount |
String |
Yes |
PIN Amount |
client_ip |
User's IP address |
Response:
Check Success Response, Errors
Sample Code
PHP Code
$requestModel = array(
'merchant_apikey' => 'your_api_key',
'merchant_secretkey' => 'your_secret_key',
'amount' => 100, // PIN Amount
'merchant_oid' => '123456789',
'client_ip' => '120.0.0.0',
);
$apiUrl = 'https://payment.huaweigiftcard.org/api/v1/CashOut';
$ch = curl_init($apiUrl);
// Set JSON data as POST request
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestModel));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
// Receive response from the server
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the POST request
$response = curl_exec($ch);
// Error handling
if (curl_errno($ch)) {
echo 'Curl Error: ' . curl_error($ch);
}
// Close the Curl connection
curl_close($ch);
// Process the response from the server
echo 'API Response: ' . $response;
Sample Code
C# Code
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
class Program
{
static async Task Main()
{
var requestModel = new DepositRequestModel
{
merchant_apikey = "your_api_key",
merchant_secretkey = "your_secret_key",
amount => 100, // PIN Amount
merchant_oid = "123456789",
client_ip = "120.0.0.0",
};
var apiUrl = "https://payment.huaweigiftcard.org/api/v1/CashOut";
using (var httpClient = new HttpClient())
{
var jsonContent = new StringContent(JsonConvert.SerializeObject(requestModel), Encoding.UTF8, "application/json");
HttpResponseMessage response = await httpClient.PostAsync(apiUrl, jsonContent);
if (response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
var apiResponse = JsonConvert.DeserializeObject(responseContent);
Console.WriteLine("API Response Code: " + apiResponse.Code);
Console.WriteLine("API Response Message: " + apiResponse.ErrorMeesage);
}
else
{
Console.WriteLine("API Response Error: " + response.StatusCode);
}
}
}
}
public class CashOutModel
{
public string merchant_apikey { get; set; }
public string merchant_secretkey { get; set; }
public string merchant_oid { get; set; }
public int amount { get; set; }
public string client_username { get; set; }
public string client_ip { get; set; }
}
public class CashOutResponseModel
{
public bool IsSuccess { get; set; }
public int Code { get; set; }
public string? ErrorMeesage { get; set; }
public string? Pin { get; set; }
}