如何实施instamojo支付网关集成,无法重定向支付网关页面...
public function gatway() {
$this->load->helper('url');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key:161ad93497e1af7efa6088621c75161f",
"X-Auth-Token:b87b7fe1bc1fa56ad7bbcd1025f9f6aa"));
$payload = Array(
'purpose' => 'FIFA 16',
'amount' => '2500',
'phone' => '9999999999',
'buyer_name' => 'John Doe',
'redirect_url' => '',
'send_email' => true,
'webhook' => '',
'send_sms' => true,
'email' => 'foo@example.com',
'allow_repeated_payments' => false,
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, TRUE);
//echo $data;
//var_dump($data);
redirect($site, 'refresh');
答案 0 :(得分:0)
当您在curl中使用htpps
时,您必须附加带有curl请求的ssl证书或将CURLOPT_SSL_VERIFYPEER
设置为false
public function gatway() {
$this->load->helper('url');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //<---- add this line or attach ssl certi
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key:161ad93497e1af7efa6088621c75161f",
"X-Auth-Token:b87b7fe1bc1fa56ad7bbcd1025f9f6aa"));
$payload = Array(
'purpose' => 'FIFA 16',
'amount' => '2500',
'phone' => '9999999999',
'buyer_name' => 'John Doe',
'redirect_url' => '',
'send_email' => true,
'webhook' => '',
'send_sms' => true,
'email' => 'foo@example.com',
'allow_repeated_payments' => false,
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, TRUE);
if(isset($data['success']) && $data['success'] === true)
{
$site = $data['payment_request']['longurl'];
redirect($site, 'refresh');
}