Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Beanstream支付网关集成需要脚本_Php_Payment Gateway_Beanstream - Fatal编程技术网

Php Beanstream支付网关集成需要脚本

Php Beanstream支付网关集成需要脚本,php,payment-gateway,beanstream,Php,Payment Gateway,Beanstream,我需要在php代码中实现BeanStream支付网关。我是支付网关实现方面的新手。有人能帮我做演示项目或脚本吗?事先谢谢。我知道这是一个老问题,但由于我刚刚在代码中实现了Beanstream支付网关,我想我还是会回答以下问题: 一旦您拥有Beanstream的帐户,您将能够访问他们的API手册,其中提供了有关所有请求和响应字段的良好文档。您可以使用PHP中的curl库轻松地连接到Beanstream API。下面是一个基于文档执行简单付款的示例方法($global_ccauth只是一个ORM对象

我需要在php代码中实现BeanStream支付网关。我是支付网关实现方面的新手。有人能帮我做演示项目或脚本吗?事先谢谢。

我知道这是一个老问题,但由于我刚刚在代码中实现了Beanstream支付网关,我想我还是会回答以下问题:

一旦您拥有Beanstream的帐户,您将能够访问他们的API手册,其中提供了有关所有请求和响应字段的良好文档。您可以使用PHP中的curl库轻松地连接到Beanstream API。下面是一个基于文档执行简单付款的示例方法($global_ccauth只是一个ORM对象,它包含我的请求信息,我每次都将这些信息存储在数据库中,包括来自Beanstream的响应字符串,但请注意,在将其保存到数据库之前,您可能希望在ORM模型中混淆信用卡号,就像我所做的那样):


我还实现了他们的定期付款,用于自动处理每月付款,它似乎运行良好。您只需根据他们的API文档调整发送的参数。

PHP付款似乎就是您要查找的内容。

您能详细说明一下吗?您搜索过一些吗?您尝试过什么吗?我的网站该网站正在使用具有信用卡功能的购物车。客户端提供了Beanstream merchat帐户API密钥、API密码和签名。我已搜索了集成脚本。但我找不到。有人可以帮助编写脚本吗?
public static function do_payment($global_ccauth, $submitted_card_number) {
    $payment_result = array(
        'status' => FALSE,
        'response' => array(),
    );

    // attempt to process the payment using CURL and a POST request to the Beanstream server as per Beanstream's example
    $request = curl_init();

    // Get curl to POST
    curl_setopt($request, CURLOPT_POST, 1);
    curl_setopt($request, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // return the results instead of echoing them
    curl_setopt($request, CURLOPT_URL, BEANSTREAM_URL);

    // These are the transaction parameters that we will POST
    $auth_parameters = "requestType=BACKEND";
    $auth_parameters .= "&merchant_id=" . BEANSTREAM_MERCHANT;
    $auth_parameters .= "&username=" . BEANSTREAM_API_USER;
    $auth_parameters .= "&password=" . BEANSTREAM_API_PASS;
    $auth_parameters .= "&trnCardOwner=" . $global_ccauth->trnCardOwner;
    $auth_parameters .= "&trnCardNumber=". $submitted_card_number;
    $auth_parameters .= "&trnExpMonth=" . $global_ccauth->trnExpMonth;
    $auth_parameters .= "&trnExpYear=" . $global_ccauth->trnExpYear;
    //$auth_parameters .= "&trnCardCvd=";
    $auth_parameters .= "&trnOrderNumber=" . $global_ccauth->trnOrderNumber ;
    $auth_parameters .= "&trnAmount=" . $global_ccauth->trnAmount;
    $auth_parameters .= "&ordName=" . $global_ccauth->ordName;
    $auth_parameters .= "&ordEmailAddress=" . $global_ccauth->ordEmailAddress;
    $auth_parameters .= "&ordPhoneNumber=" . $global_ccauth->ordPhoneNumber;
    $auth_parameters .= "&ordAddress1=" . $global_ccauth->ordAddress1;
    $auth_parameters .= "&ordAddress2=" . $global_ccauth->ordAddress2;
    $auth_parameters .= "&ordCity=" . $global_ccauth->ordCity;
    $auth_parameters .= "&ordProvince=" . $global_ccauth->ordProvince;
    $auth_parameters .= "&ordPostalCode=" . $global_ccauth->ordPostalCode;
    $auth_parameters .= "&ordCountry=" . $global_ccauth->ordCountry;

    curl_setopt($request, CURLOPT_POSTFIELDS, $auth_parameters);

    // Now POST the transaction. $txResult will contain Beanstream's response
    $auth_result = curl_exec($request);
    curl_close($request);

    if ($auth_result !== FALSE) {
        // save the raw results
        $global_ccauth->response = $auth_result;
        $global_ccauth->save();

        // parse the results
        parse_str($auth_result, $parsed_result);
        $payment_result['response'] = $parsed_result;
        if ( ! empty($parsed_result['trnApproved']) && $parsed_result['trnApproved'] == 1) {
            // the request was approved
            $payment_result['status'] = TRUE;
        } else {
            // the request was not approved
            // do something smart
        }
    } else {
        // curl POST request failed
        // do something smart
    }

    return $payment_result;
}