由于 Sagepay API 只是通过一堆 curl 请求访问,因此您可以只使用 Zends Client 和 Request 对象。例如 :
定义您要发布的数据 -
// Set the post data
$data = array(
'VPSProtocol' => '',
'TxType' => '',
'Vendor' => '',
'VendorTxCode' => '',
'Amount' => '',
'Currency' => '',
'Description' => '',
'CardHolder' => '',
'CardNumber' => '',
'StartDate' => '',
'ExpiryDate' => '',
'IssueNumber' => '',
'CV2' => '',
'CardType' => '',
'AuthCode' => '',
'BillingSurname' => '',
'BillingFirstNames' => '',
'BillingAddress1' => '',
'BillingAddress2' => '',
'BillingCity' => '',
'BillingPostCode' => '',
'BillingCountry' => '',
'BillingPhone' => '',
'DeliverySurname' => '',
'DeliveryFirstNames'=> '',
'DeliveryAddress1' => '',
'DeliveryAddress2' => '',
'DeliveryCity' => '',
'DeliveryPostCode' => '',
'DeliveryCountry' => '',
'DeliveryPhone' => '',
'CustomerEmail' => '',
'NotificationUrl' => ''
)
然后创建新的客户端对象并将适配器设置为“CURL” -
$client = new Client();
$client->setAdapter(new Curl());
最后创建一个新的请求对象并将客户端对象分派给请求。
$request = new Request();
$request->setUri('https://test.sagepay.com/gateway/service/vspdirect-register.vsp');
$request->setMethod(Request::METHOD_POST);
$request->setContent(http_build_query($data));
$response = $client->dispatch($request);
var_dump($response);
die;
通读这可能会有所帮助。