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 |
pin |
PIN number to be converted to cash |
amount |
PIN amount to be converted to cash |
Successful API response
200 SUCCESS
{
"isSuccess": true,
"code": 200,
"errorMeesage": "The pin was successfully broken."
}
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 |
PIN Number cannot be empty |
306 |
merchant_oid is unique and cannot be left blank. |
307 |
client_username cannot be empty. |
308 |
Pin not found or amount not correct. |
309 |
Your API information is incorrect. |
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) |
amount |
String |
Yes |
PIN Amount |
pin |
String |
Yes |
PIN Number. |
merchant_oid |
String |
Yes |
Unique order number |
client_username |
String |
Yes |
Username or Number on your system. |
client_ip |
String |
Yes |
User's IP address on your system. |
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
'pin' => '9999888877776666', // PIN Number
);
$apiUrl = 'https://payment.huaweigiftcard.org/api/v1/CashIn';
$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
pin = "9999888877776666", // PIN Number
};
var apiUrl = "https://payment.huaweigiftcard.org/api/v1/CashIn";
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 CashInModel
{
public string merchant_apikey { get; set; }
public string merchant_secretkey { get; set; }
public string pin { get; set; }
public int amount { get; set; }
}
public class CashInResponseModel
{
public bool IsSuccess { get; set; }
public int Code { get; set; }
public string? ErrorMeesage { get; set; }
}
Parametreler
Request data must be JSON
type
Callback parameters will be sent to the CallBackUrl address specified in your Store panel by the HUAWEIPIN system. The system will retry the callback process every 10 minutes until it receives a "Successful" response. To facilitate the integration process, you can track API transactions from the Merchant Panel > API > Transactions page.
POST/
Parameters
Name |
Type |
Required |
Description |
merchant_oid |
string |
Yes |
Order Number. |
merchant_callback_privatekey |
string |
Yes |
Store CallBack-Key (Will be obtained from the store panel). |
status |
String |
Yes |
Transaction state. |
amount |
Intager |
Yes |
Order Amount. |
hash |
String |
Yes |
hash = SHA256(merchant_oid + amount + merchant_callback_privatekey) |
Response:
Check Success Response, Errors
Sample Code
PHP Code
echo "OK";
Sample Code
C# Code
Return Ok("Write your message.");