Cyber​​Source安全接受与php

时间:2018-03-06 10:18:01

标签: php payment-gateway cybersource

我尝试使用 REST API 在php中集成 Cyber​​ Source 支付网关。我在github

中找到了以下参考链接

经过必要的更改后,我终于可以登录(验证)到Cyber​​源,但是我得到了以下错误。 (我可以查看Cyber​​ Source的日志)

req_reference_number:474 =>错误101 - 请求参数无效或缺失

signed: true

Array
(
    [auth_trans_ref_no] => 474
    [decision] => ERROR
    [message] => Request parameters are invalid or missing
    [reason_code] => 101
    [req_access_key] => 5e00e27842d73381b0**************
    [req_amount] => 569
    [req_bill_to_address_city] => Mountain View
    [req_bill_to_address_country] => US
    [req_bill_to_address_line1] => 1 My Apartment
    [req_bill_to_address_line2] => 2 nd street
    [req_bill_to_address_postal_code] => 94043
    [req_bill_to_address_state] => CA
    [req_bill_to_email] => someemail@somedomain.com
    [req_bill_to_forename] => Elavarasan
    [req_bill_to_phone] => 6508764564
    [req_bill_to_surname] => Natarajan
    [req_currency] => USD
    [req_customer_ip_address] => 127.0.0.1
    [req_device_fingerprint_id] => v1rh0p44gpnhag1a7mfp9tst25
    [req_item_0_code] => KFLTFDIV
    [req_item_0_name] => KFLTFDIV
    [req_item_0_quantity] => 1
    [req_item_0_sku] => sku001
    [req_item_0_unit_price] => 20.00
    [req_item_1_code] => KFLTFD70
    [req_item_1_name] => KFLTFD70
    [req_item_1_quantity] => 1
    [req_item_1_sku] => sku002
    [req_item_1_unit_price] => 10.00
    [req_line_item_count] => 2
    [req_locale] => en-us
    [req_merchant_defined_data1] => MDD1
    [req_merchant_defined_data2] => MDD2
    [req_merchant_defined_data3] => MDD3
    [req_merchant_defined_data4] => MDD4
    [req_merchant_descriptor] => Krungsri
    [req_override_custom_cancel_page] => http://localhost/cyphp/sa-wm/response.php
    [req_override_custom_receipt_page] => http://localhost/cyphp/sa-wm/response.php
    [req_profile_id] => *******************************
    [req_reference_number] => 474
    [req_transaction_type] => sale
    [req_transaction_uuid] => 5aa6329409169
    [required_fields] => payment_method
    [signature] => IJ0iEsOJLZe2W4dNrogdzp8op8Evon2wU1KvA3W6SzM=
    [signed_date_time] => 2018-03-12T07:57:00Z
    [signed_field_names] => decision,req_access_key,req_profile_id,req_transaction_uuid,req_transaction_type,req_reference_number,req_amount,req_currency,req_line_item_count,req_locale,req_override_custom_receipt_page,req_override_custom_cancel_page,auth_trans_ref_no,req_item_0_code,req_item_0_name,req_item_0_quantity,req_item_0_sku,req_item_0_unit_price,req_item_1_code,req_item_1_name,req_item_1_quantity,req_item_1_sku,req_item_1_unit_price,req_bill_to_forename,req_bill_to_surname,req_bill_to_email,req_bill_to_phone,req_bill_to_address_line1,req_bill_to_address_line2,req_bill_to_address_city,req_bill_to_address_state,req_bill_to_address_country,req_bill_to_address_postal_code,req_customer_ip_address,req_device_fingerprint_id,req_merchant_defined_data1,req_merchant_defined_data2,req_merchant_defined_data3,req_merchant_defined_data4,req_merchant_descriptor,required_fields,reason_code,message,signed_field_names,signed_date_time
    [utf8] => ✓
)

如果我重命名或删除任何参数,则身份验证失败。所以我希望,我传递了一些错误的价值。但我无法找出哪一个......

我试图改变几乎所有传递的字段值,但每次都会出现相同的错误

错误101 - 请求参数无效或缺失

enter image description here

2 个答案:

答案 0 :(得分:1)

我也只做了SOAP,但是在查看了其余的v1示例后,看起来传递了api密钥和密钥以在Apiclient中创建paytoken。授权付款应该是这样的(在你安装sdk之后):

<?php
use \CyberSource\Authorizations as Authorizations;
use \CyberSource\Configuration as Configuration;

class CyberSource {

      private $config;

      function __construct($apiKey, $secretKey) {
         // pass apikey and secretkey to configuration 
         $this->config = new Configuration($apiKey, $secretKey);
      }

      private function runAuth($this->config) {
          $api = new Authorizations($this->config);
          $jsonPayload = // ur json request payload

          try{
            // pass the request json payload object 
            $response = $api->createAuthorization($jsonPayload);
          } catch (\E $e) {
             //throw error here
          }
      }

}

如果您必须使用v2,那么您需要阅读此pdf,您需要添加一些内容以进行帐户身份验证。

答案 1 :(得分:0)

最后我从Cyber​​ Source找到了示例代码(php),我们只需根据凭据进行配置。这是link

Source Code

您必须在security.php文件

中定义密钥
define ('SECRET_KEY', '7f15d699ff14461b9a84*****');

和,  access_key文件中的profile_idsigneddatafields.php

<input type="hidden" name="access_key" value="5e00e27842d73******">
<input type="hidden" name="profile_id" value="43C533AC-****-****-****-*********">

那就是它。