I currently have a site that is requiring Sagepay integration, previous sites have integrated sagepay successfully however none have used Zend, unfortunately there isn't that much documentation on using Zend with Sagepay, I have however found a module that may work at this link:

http://code.google.com/p/zend-service-sagepay/source/browse/trunk/library/My/Sagepay.php?r=2

What would be best practice in this instance, I am aware Sagepay offers multiple methods for handling payments although the more it is integrated with the site the better.

有帮助吗?

解决方案

Since the Sagepay API is just accessed via a bunch of curl requests you could just use Zends Client and Request objects. For example :

Define what data you would like to post -

// 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'   =>  ''
)

Then create the new client object and set the adapter to 'CURL' -

$client = new Client();
$client->setAdapter(new Curl());

And finally create a new request object and dispatch the client object to the request.

$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;

A read through this may help.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top