<?php
class Api
{
//Nomor merchant
private $mch_id = 10085;
//APIKEY merchant
private $mch_key = 'slrkogmvo13hb92d8i5111bxm8q8euc7';
//Membuat tanda tangan (sign)
private function sign($data, $Md5key)
{
ksort($data);
$md5str = "";
foreach ($data as $key => $val) {
if (!empty($val)) {
$md5str = $md5str . $key . "=" . $val . "&";
}
}
return strtoupper(md5($md5str . "key=" . $Md5key));
}
//Request CURL
protected function curl($url, $data = [], $method = 'POST')
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
if (1 == strpos("$" . $url, "https://")) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($curl);
if (curl_errno($curl)) {
return 'ERROR_200' . curl_error($curl);
}
curl_close($curl);
return $res;
}
//Request pay-out
public function df()
{
$param = [
"memberId" => $this->mch_id,
"type" => 'bankcard',
"orderId" => 'E20210905123123123',
"dstCode" => 'BCA',
"amount" => 50000,
"account" => '0123456789',
"name" => 'TONGTIAN HOT',
"phone" => '85193017660',
"email" => 'gotocode@gmail.com',
"address" => 'gotocode@gmail.com',
"notifyUrl" => 'http://www.yourdomain.com/demo/notifyurl.php'
];
$param["sign"] = $this->sign($param, $this->mch_key);
return $this->curl('http://pay.huolilian.com/Payment_Dfpay_add', $param);
}
}
//Instansiasi request
$api = new Api();
$res = $api->df();
echo print_r($res);