dongshendi3599 2018-11-24 11:18
浏览 109
已采纳

我如何在php上对cybersource soap toolkit api进行身份验证

I have the following code on my 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("
RESPONSE: " . print_r($reply, true));

and the cybs.ini is like

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"

when i run the code on my local machine i get the following error messaage.

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

How do i know what caused the error above and how can i solve the above error. I am trying to add payout api to my app and this is giving a headache right now. Please guys help me out if anyone can.

  • 写回答

2条回答 默认 最新

  • douyu0852 2018-11-24 23:33
    关注

    The error “authentication failed” is saying your merchant_id and transaction_key are not correct.

    Assuming that your merchant_id is correct your transaction_key is not the correct format. You can get a transaction_key by going to the business center at https://ebctest.cybersource.com then go to Account Management-> Transaction Security Keys -> Security Keys for the SOAP Toolkit API. Generate a key there.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)