简体   繁体   English

Payfort 中的支付集成

[英]Payment integration in Payfort

I'm working on Payfort API integration, and facing a problem with integrating using PHP.我正在研究 Payfort API 集成,并面临使用 PHP 集成的问题。 The link which I have followed mistake is in merchant reference.我遵循错误的链接在商家参考中。 Where to get this reference?从哪里得到这个参考?

<?php
$merchant_reference = 'TEST81003';
$redirectUrl = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';
$return_url = 'https://love.ae/admin/public/login';

$requestParams = array(
'command' => 'PURCHASE',
'access_code' => 'bSCrsxniHsJqWtQ9ki15',
'merchant_identifier' => 'xPzUtIjC',
'merchant_reference' => 'TEST81003',
'amount' => 1050*100,
'currency' => 'AED',
'language' => 'en',
'customer_email' => 'alraqbani@gmail.com',
'token_name' => 'ali',
'return_url' => 'https://love.ae/admin/public/login',
'card_security_code' => '123',
);

// calculating signature
$shaString = '';
ksort($requestParams);
$SHARequestPhrase   = '$2y$10$IGSCjOlk9';
$SHAResponsePhrase   = '$2y$10$Ll6DBCeeH';
$SHAType       = 'sha256';
foreach ($requestParams as $k => $v) {
$shaString .= "$k=$v";
}

if (1 == 1)
$shaString = $SHARequestPhrase . $shaString . $SHARequestPhrase;
else
$shaString = $SHAResponsePhrase . $shaString . $SHAResponsePhrase;

$signature = hash($SHAType, $shaString);

$requestParams['signature'] = hash($SHAType, $shaString);

// calling payfort api using curl
//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
$useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;charset=UTF-8',
//'Accept: application/json, application/*+json',
//'Connection:keep-alive'
));
curl_setopt($ch, CURLOPT_URL, $redirectUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); // The number of seconds to wait while trying to connect
//curl_setopt($ch, CURLOPT_TIMEOUT, Yii::app()->params['apiCallTimeout']); // timeout in seconds
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestParams));

$response = curl_exec($ch);
print_r($response);

curl_close($ch);

return $response;
?>

{"amount":"105000","response_code":"00044","signature":"e85cd4511c0b21649871c3b857d8782a1f4c326325cb04891720a2bb1bae400c","merchant_identifier":"xPzUtIjC","access_code":"bSCrsxniHsJqWtQ9ki15","language":"en","command":"PURCHASE","response_message":"Token name does not exist","merchant_reference":"TEST81003","customer_email":"alraqbani@gmail.com","currency":"AED","status":"00"}

   <?php
   $merchant_reference = 'TEST81003';
   $redirectUrl = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';
   $return_url = 'https://love.ae/admin/public/login';

   $requestParams = array(
   'command' => 'PURCHASE',
   'access_code' => 'bSCrsxniHsJqWtQ9ki15',
   'merchant_identifier' => 'xPzUtIjC',
   'merchant_reference' => 'TEST81003',
   'amount' => 1050*100,
   'currency' => 'AED',
   'language' => 'en',
   'customer_email' => 'alraqbani@gmail.com',
   'token_name' => 'ali',
   'return_url' => 'https://love.ae/admin/public/login',
    'card_security_code' => '123',
   );

// calculating signature
    $shaString = '';
    ksort($requestParams);
    $SHARequestPhrase   = '$2y$10$IGSCjOlk9';
    $SHAResponsePhrase   = '$2y$10$Ll6DBCeeH';
    $SHAType       = 'sha256';
    foreach ($requestParams as $k => $v) {
    $shaString .= "$k=$v";
    }

    if (1 == 1)
    $shaString = $SHARequestPhrase . $shaString . $SHARequestPhrase;
    else
    $shaString = $SHAResponsePhrase . $shaString . $SHAResponsePhrase;

    $signature = hash($SHAType, $shaString);

    $requestParams['signature'] = hash($SHAType, $shaString);

    // calling payfort api using curl
    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    $useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 
    Firefox/20.0";
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json;charset=UTF-8',
     //'Accept: application/json, application/*+json',
     //'Connection:keep-alive'
     ));
    curl_setopt($ch, CURLOPT_URL, $redirectUrl);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); // The number of seconds to 
    wait while trying to connect
    //curl_setopt($ch, CURLOPT_TIMEOUT, Yii::app()->params['apiCallTimeout']); 
    // timeout in seconds
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestParams));

    $response = curl_exec($ch);
    print_r($response);

    curl_close($ch);

    return $response;
    ?>

merchant_reference is a unique order number for each payment request. Merchant_reference 是每个付款请求的唯一订单号。 It could be Primary key of the table or can be generated uniquely.它可以是表的主键,也可以是唯一生成的。 eg例如

$merchant_reference = '5000-'.time(); $merchant_reference = '5000-'.time();

merchant_reference Alphanumeric Max: 40 Merchant_reference 字母数字最大:40

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM