如何在php中向sellix发送POST请求

时间:2020-10-27 20:14:48

标签: php api web

我正在尝试使用Sellix.io API在PHP中创建付款,在本地将所有代码正常工作,直到将代码上传到网络主机为止,

{"status":400,"data":null,"message":null,"log":null,"error":"Transaction flagged as potential fraud (xxxxxxxxxxx).","env":"production"}

它说我的请求被标记为潜在欺诈。询问时,我被告知“从服务器发送的付款请求可能被标记为没有用户代理或该设备的指纹的VPN或RDP”

如何与适当的用户代理发送请求?或指纹? 这是我一直在使用的代码:

<?php
    $mail = $_GET["mail"];
    $url = "https://dev.sellix.io/v1/payments";

    $data = json_encode(array(
        "title" => "MyProduct",
        "product_id" => "xxxxxxxxxxx",
        "gateway" => "PAYPAL",
        "value" => 20,
        "currency" => "EUR",
        "quantity" => 1,
        "email" => $mail,
        "white_label" => false,
        "return_url" => "https://dev.sellix.io/v1/return" //not sure what this is supposed to do...
    ));

    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
       // "Content-type: application/x-www-form-urlencoded\r\n" .
        'Authorization: Bearer ' . 'xxxxxxxxxxxxxxxx(API KEY)xxxxxxxxxxxxxxxx'
    ));
    echo $response = curl_exec($curl);
    curl_close($curl);
    $finalUrl = strval(json_decode($response)->data->url);
    header("Location: $finalUrl"); //redirects the current page to the payment page.
?>

1 个答案:

答案 0 :(得分:1)

这是基于缺乏与您在their help pageAPI documentation上的问题有关的信息的猜测。我已按调试顺序列出了一些提示:

1:发送用户代理标头

尝试添加客户端的用户代理标头。这将在$_SERVER['HTTP_USER_AGENT']

中可用

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "User-agent: ".$_SERVER['HTTP_USER_AGENT']."\r\n" .
        'Authorization: Bearer ' . 'xxxxxxxxxxxxxxxx(API KEY)xxxxxxxxxxxxxxxx'
    ));`

注意:如果您要进行一些自定义Ajax,则可能无法获取标头。您还可以提供静态值,但从本质上避免欺诈是您的最大利益。

2:添加指纹头/ cookie

(显然)指纹正在发送信息以标识浏览器。根据{{​​3}},它可以存储在名为__Secure-Fgp的cookie中,您必须将其添加到请求中。

this OWASP article通过某种方式展示了一种计算指纹打印客户端的方法。

免责声明:我自己还没有尝试过。如果有适合的标题,我会向他们查询。

3:使用其他产品进行调试

根据他们的帮助页面,您可以在"max_risk_level"通话中将POST /products设置为 100 ,以关闭其欺诈引擎请勿执行此操作生产中防止欺诈机制也可以防止您被骗。但这可以帮助您找出问题所在并获得概念证明并投入运行。