Как пройти аутентификацию с помощью API-интерфейса мыла Cybersource в Stack Overflow

У меня есть следующий код на моем 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

Решение

Ошибка «аутентификация не удалась» говорит о том, что ваш merchant_id иaction_key неверны.

Предполагая, что ваш merchant_id указан правильно, ваш ключ транзакции — неверный формат. Вы можете получить ключ транзакции, перейдя в бизнес-центр по адресу https://ebctest.cybersource.com затем перейдите в Управление учетными записями-> Ключи безопасности транзакций -> Ключи безопасности для API SOAP Toolkit. Сгенерируйте ключ там.

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"

Это позаботилось обо всем, что было не так с ошибкой, которая появлялась.

0