0

我正在尝试使用REST API将Cyber​​ Source Payment gateway 集成到 php 中。我在github中找到了以下参考链接

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

req_reference_number: 474 => ERROR 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] => ✓
)

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

我试图更改我传递的几乎每个字段值,但每次都得到相同的错误

ERROR 101 - 请求参数无效或丢失

在此处输入图像描述

4

2 回答 2

2

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

源代码

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

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

并且, access_keyprofile_id文件signeddatafields.php

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

就是这样。

于 2018-03-12T11:32:17.667 回答
1

我也只做了 SOAP,但是在查看了他们的 rest v1 示例之后,似乎传递了 api 密钥和密钥以在 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,您需要在标题中添加一些内容以进行帐户身份验证。

于 2018-03-07T20:37:13.173 回答