dongtangxi1584 2018-12-03 05:14
浏览 140
已采纳

在Magento 2.2.3中构建自定义支付网关

Bank just gave me 2 links

first for token validation like.

sandbox url: somethingurl.

then I have to pass

{
    "userName":"test",
    "password":"123456Aa"
} 

in json format

after that I have to find bank generated token from this post reguest.

which I've already done.

and then I've to send magento 2 order data (grand total) with some other credentials to a bank secure url:

somethingurl.com/createorder

json format is like this

{

"merchantId": "11122333",

"amount": "100",

"currency": "050",

"description": "This is test",

"approveUrl": "http://localhost/TheBankPHP_1.0.1/approve.php",

"cancelUrl": "http://localhost/TheBankPHP_1.0.1/cencel.php",

"declineUrl": "http://localhost/TheBankPHP_1.0.1/decline.php",

"userName": "test",

"passWord": "123456Aa",

"secureToken": "bd6e290e-ca3d-4a4b-b7c1-defe9ff6f7af"

}

Now, my question is how can I do this when user click place order button. and store that in my admin panel that order is placed with that bank order payment.

Is it possible to use cash on delivery method just set a link.

I've implemented a php page but how I integrate this with a module I've no idea. Can you please help me @Damian Culotta ?

here is my php file given below.

<?php
    $url = "https://sandbox.thebank.com:443/transaction/token";
    $data = json_encode(array("userName" => "test","password" => "123456Aa"));
    $ch = curl_init( $url );
    # Setup request to send json via POST.

    curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
    # Return response instead of printing.
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    # Send request.
    $result = curl_exec($ch);
    curl_close($ch);
    # Print response.
    echo "<pre>$result</pre>";

    $mydata = json_decode($result, true);

    $sectkn = $mydata["transactionId"];

    echo $sectkn;


    $turl = "https://sandbox.thebank.com:443/transaction/createorder";
    $data = json_encode(array(
    "merchantId" => "11122333",
    "amount" => "100",
    "currency" => "050",
    "description" => "This is test",
    "approveUrl" => "http://localhost/theBankPHP_1.0.1/approve.php",
    "cancelUrl" => "http://localhost/theBankPHP_1.0.1/cencel.php",
    "declineUrl" => "http://localhost/theBankPHP_1.0.1/decline.php",
    "userName" => "test",
    "passWord" => "123456Aa",
    "secureToken" => $sectkn,
    ));
    $ch = curl_init( $turl );
    # Setup request to send json via POST.

    curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
    # Return response instead of printing.
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    # Send request.
    $tresult = curl_exec($ch);
    curl_close($ch);
    # Print response.
    echo "<pre>$tresult</pre>";



$mydatat = json_decode($tresult, true);

$linkdata = $mydatat["items"];

$myurldata = $linkdata["url"];
$myorder = $linkdata["orderId"];
$mysession = $linkdata["sessionId"];


$redirect_url = $myurldata. "?ORDERID=". $myorder. "&SESSIONID=". $mysession;
header("Location: .$redirect_url");

//echo $redirect_url;

?>

N.B. for security purpose: I've changed the bank url. please help me

  • 写回答

1条回答 默认 最新

  • dongluan5740 2018-12-03 08:23
    关注

    You need to create custom module to create your custom payment gateway.

    I have create one for my need. You can get idea base on it.

    PayEase Payment Gateway For Magento 2

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)
  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)