【问题标题】:How to send a POST request to sellix in php如何在php中向sellix发送POST请求
【发布时间】:2021-02-10 04:35:09
【问题描述】:

我正在尝试使用 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.
?>

【问题讨论】:

    标签: php api web


    【解决方案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

    指纹(显然)发送信息以识别浏览器。根据this OWASP article,它可以存储在一个名为__Secure-Fgp 的cookie 中,您必须将其添加到请求中。

    This SO answer 以某种方式展示了一种计算指纹客户端的方法。

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

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

    根据他们的帮助页面,您可以在POST /products 呼叫中将"max_risk_level" 设置为100,以关闭他们的欺诈引擎不要在生产中这样做 strong> 欺诈预防机制也可以防止您被骗。但它可能会帮助您找出问题所在并启动并运行概念验证。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-09
      • 2013-07-11
      • 2019-03-29
      • 1970-01-01
      • 1970-01-01
      • 2017-07-13
      • 2016-04-08
      相关资源
      最近更新 更多