0

我的 index.php 上有以下代码

<?php
// This sample demonstrates how to run a sale request, which combines an
// authorization with a capture in one request.

// Using Composer-generated autoload file.
require __DIR__ . '/vendor/autoload.php';
// Or, uncomment the line below if you're not using Composer autoloader.
//require_once(__DIR__ . '/lib/CybsSoapClient.php');


// Before using this example, you can use your own reference code for the transaction.
$referenceCode = 'holla';

$client = new CybsSoapClient();
$request = $client->createRequest($referenceCode);

// Build a sale request (combining an auth and capture). In this example only
// the amount is provided for the purchase total.
$ccAuthService = new stdClass();
$ccAuthService->run = 'true';
$request->ccAuthService = $ccAuthService;

$ccCaptureService = new stdClass();
$ccCaptureService->run = 'true';
$request->ccCaptureService = $ccCaptureService;

$billTo = new stdClass();
$billTo->firstName = 'John';
$billTo->lastName = 'Doe';
$billTo->street1 = '1295 Charleston Road';
$billTo->city = 'Mountain View';
$billTo->state = 'CA';
$billTo->postalCode = '94043';
$billTo->country = 'US';
$billTo->email = 'null@cybersource.com';
$billTo->ipAddress = '10.7.111.111';
$request->billTo = $billTo;

$card = new stdClass();
$card->accountNumber = '4111111111111111';
$card->expirationMonth = '12';
$card->expirationYear = '2020';
$request->card = $card;

$purchaseTotals = new stdClass();
$purchaseTotals->currency = 'USD';
$purchaseTotals->grandTotalAmount = '90.01';
$request->purchaseTotals = $purchaseTotals;

$reply = $client->runTransaction($request);

// This section will show all the reply fields.
print("\nRESPONSE: " . print_r($reply, true));

cybs.ini 就像

merchant_id = "firefy"
transaction_key = "5430494897960177107046"

; Modify the URL to point to either a live or test WSDL file with the desired API version.
wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.109.wsdl"

当我在本地机器上运行代码时,我收到以下错误消息。

Fatal error: Uncaught SoapFault exception: [wsse:FailedCheck] Security Data : UsernameToken authentication failed. in C:\xampp\htdocs\cybersourceTest\index.php:50 Stack trace: #0 C:\xampp\htdocs\cybersourceTest\index.php(50): SoapClient->__call('runTransaction', Array) #1 {main} thrown in C:\xampp\htdocs\cybersourceTest\index.php on line 50

我怎么知道导致上述错误的原因以及如何解决上述错误。我正在尝试将支付 api 添加到我的应用程序中,这现在让人头疼。如果有人可以,请大家帮帮我。

4

2 回答 2

0

错误“身份验证失败”表示您的商家 ID 和交易密钥不正确。

假设您的 Mercer_id 正确,您的 transaction_key 格式不正确。您可以通过访问https://ebctest.cybersource.com的业务中心获取 transaction_key,然后转到 Account Management-> Transaction Security Keys -> Security Keys for the SOAP Toolkit API。在那里生成一个密钥。

于 2018-11-24T23:33:34.977 回答
0

我发现我指向的 url 无效或其他东西,但我通过将 wsdl 的端点从

wsdl="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.109.wsdl"

wsdl="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.151.wsdl"

这解决了所有与弹出错误有关的问题。

于 2018-11-26T09:14:21.863 回答