我正在使用Smart Debit Payment Gateway从网站付款... 我在通过CURL提交时遇到错误,
Couldn't init Money from [nil, 8000]
你能否告诉我为什么我遇到这个问题,所有凭证都很好..
I.N:我在我的本地xampp服务器上测试了这个,而不是在线测试帐户,也不是真实帐户。
我使用的代码是:
<?php
$request_host = 'https://secure.ddprocessing.co.uk';
$request_path = '/api/ddi/variable/create';
$user = "myusername";
$password = "mypassword";
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_POST => true,
CURLOPT_USERPWD => $user . ":" . $password,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_HTTPHEADER => array("Accept: application/XML"),
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'], // Let SmartDebit see ho we are
);
$session = curl_init($request_host . $request_path);
curl_setopt_array( $session, $options );
// tell cURL to accept an SSL certificate if presented
if(ereg("^(https)", $request_host)) {
curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
}
// The request parameters
$pslid = 'pslidcode';
$payer_ref = 'XYZ-12345';
$first_name = 'John';
$last_name = 'Smith';
$address_1 = "123 Fake St";
$town = "London";
$postcode = "07666";
$country = "United State";
$account_name = "John Smith";
$sort_code = "40-12-23";
$account_number = "12345678";
$regular_amount = 1000;
$frequency_type = "M";
// urlencode and concatenate the POST arguments
$postargs = 'variable_ddi[service_user][pslid]=' . $pslid;
$postargs .= '&variable_ddi[payer_reference]=' . urlencode($payer_ref);
$postargs .= '&variable_ddi[first_name]=' . urlencode($first_name);
$postargs .= '&variable_ddi[last_name]=' . urlencode($last_name);
$postargs .= '&variable_ddi[address_1]=' . urlencode($address_1);
$postargs .= '&variable_ddi[town]=' . urlencode($town);
$postargs .= '&variable_ddi[postcode]=' . urlencode($postcode);
$postargs .= '&variable_ddi[country]=' . urlencode($country);
$postargs .= '&variable_ddi[account_name]=' . urlencode($account_name);
$postargs .= '&variable_ddi[sort_code]=' . urlencode($sort_code);
$postargs .= '&variable_ddi[account_number]=' . urlencode($account_number);
$postargs .= '&variable_ddi[regular_amount]=' . urlencode($regular_amount);
$postargs .= '&variable_ddi[frequency_type]=' . urlencode($frequency_type);
// Tell curl that this is the body of the POST
$smrtoutput = curl_setopt($session, CURLOPT_POSTFIELDS, $postargs);
// $output contains the output string
$output = curl_exec($session);
print_r($output);die;
$header = curl_getinfo($session);
// close curl resource to free up system resources
curl_close($session);
if(curl_errno($session)) {
echo 'Curl error: ' . curl_error($session);
}
else {
switch ($header["http_code"]) {
case 200:
echo "Variable DDI created";
break;
default:
echo "HTTP Error: " . $header["http_code"];
}
}
?>