代码之家  ›  专栏  ›  技术社区  ›  Elavarasan

php中CyberSource与REST Api的安全验收集成

  •  0
  • Elavarasan  · 技术社区  · 6 年前

    我正在尝试整合 网络资源 php中的支付网关使用 REST API 。我在 github

    经过必要的更改后,我终于可以登录(验证)到网络资源,但我得到以下错误。(我可以查看网络来源的日志)

    请求参考号: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 回复  |  直到 6 年前
        1
  •  2
  •   Elavarasan    6 年前

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

    Source Code

    您必须在中定义密钥 security.php 文件

    define ('SECRET_KEY', '7f15d699ff14461b9a84*****');
    

    access_key profile_id 在里面 signeddatafields.php 文件

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

    就是这样。

        2
  •  1
  •   feiiiiii    6 年前

    我也只做了SOAP,但在看了RESTV1示例之后,似乎传递了api密钥和密钥来在中创建paytoken Apiclient 。授权付款应如下所示(安装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 为了进行帐户身份验证,需要向标头中添加一些内容。