我在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添加到我的应用中,这现在令人头疼。 请大家帮我。
答案 0 :(得分:0)
“身份验证失败”错误表示您的商人ID和交易密钥不正确。
假设您的商人ID是正确的,那么您的transaction_key不是正确的格式。您可以转到https://ebctest.cybersource.com的业务中心,然后转到SOAP Toolkit API的“帐户管理”->“交易安全性密钥”->“安全性密钥”来获取transaction_key。在此处生成密钥。
答案 1 :(得分:0)
我发现我指向的网址无效或某些东西,但我通过将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"
这可以解决出现的错误中所有的错误。