我正在运行SOAP调用来进行付款处理。
结果不是json,当我尝试json解码时,错误是:json_decode()期望参数1是字符串,给定对象。
require_once './vendor/autoload.php';
use MaxMind\MinFraud;
//for live server use 'www' for test server use 'sandbox'
$wsdl='https://www.usaepay.com/soap/gate--------/usaepay.wsdl';
// instantiate SoapClient object as $client
$client = new SoapClient($wsdl);
$sourcekey = '[ cut ]';
$pin = '1234';
// generate random seed value
$seed=time() . rand();
// make hash value using sha1 function
$clear= $sourcekey . $seed . $pin;
$hash=sha1($clear);
// assembly ueSecurityToken as an array
$token=array(
'SourceKey'=>$sourcekey,
'PinHash'=>array(
'Type'=>'sha1',
'Seed'=>$seed,
'HashValue'=>$hash
),
'ClientIP'=>$_SERVER['REMOTE_ADDR'],
);
在它上面的配置,处理在下面完成,然后最后的呼叫在那里。
如何访问$ res中的数据?
try {
$res=$client->runTransaction($token, $Request);
print_r($res);
}
catch (SoapFault $e){
echo $client->__getLastRequest();
echo $client->__getLastResponse();
$location = "https://".$_SERVER[HTTP_HOST]."/order-decline.php";
//header("Location: $location");
die("runTransaction failed :" .$e->getMessage());
}
这是print_r($ res)的结果:
stdClass Object
(
[AcsUrl] =>
[AuthAmount] => 7.21
[AuthCode] => 229646
[AvsResult] => Address: Match & 5 Digit Zip: Match
[AvsResultCode] => Y
[BatchNum] => 3
[BatchRefNum] => 46276145
[CardCodeResult] => Match
[CardCodeResultCode] => M
[CardLevelResult] => Unknown Code
[CardLevelResultCode] =>
[ConversionRate] => 0
[ConvertedAmount] => 0
[ConvertedAmountCurrency] => 840
[CustNum] => 0
[Error] => Approved
[ErrorCode] => 0
[isDuplicate] =>
[Payload] =>
[RefNum] => 1573277303
[Result] => Approved
[ResultCode] => A
[Status] => Pending
[StatusCode] => P
[VpasResultCode] =>
)
我的目标是获取个体变量。结果代码等。