示例#1
0
 public function testBasketWithDiscounts()
 {
     $basket = new dwmsw\sagepay\Basket();
     $basket->addItem(new dwmsw\sagepay\Item('Test Item', 30.0, 6, 1));
     $basket->addDiscount(new dwmsw\sagepay\Discount(12.0, 'This is a discount'));
     $output = $basket->getItems(true);
     $expected = '<basket>
                   <item>
                     <description>Test Item</description>
                     <quantity>1</quantity>
                     <unitNetAmount>30.00</unitNetAmount>
                     <unitTaxAmount>6.00</unitTaxAmount>
                     <unitGrossAmount>36.00</unitGrossAmount>
                     <totalGrossAmount>36.00</totalGrossAmount>
                   </item>
                   <discounts>
                     <discount>
                       <fixed>12.00</fixed>
                       <description>This is a discount</description>
                     </discount>
                   </discounts>
                 </basket>';
     $this->assertXmlStringEqualsXmlString($expected, $output);
 }
示例#2
0
文件: index.php 项目: dwmsw/sagepay
<?php

include '../../vendor/autoload.php';
// New Basket instance
$basket = new dwmsw\sagepay\Basket();
// Add an item to the basket
$basket->addItem(new dwmsw\sagepay\Item('Test Item', 30.0, 6, 1));
// Add another item to the basket
$basket->addItem(new dwmsw\sagepay\Item('Test Item Two', 30.0, 6, 2));
// Create instance of Direct
$sagepay = new dwmsw\sagepay\Direct();
// Set the Basket
$sagepay->setBasket($basket);
// Set up the config
$sagepay->setVendorName('YOUR VENDOR NAME');
$sagepay->setConnectionMode('test');
$sagepay->setCurrency('GBP');
$sagepay->setApplyAvsCv2(1);
$sagepay->setApply3dSecure(1);
$sagepay->setGiftAid(0);
$vendorTxCode = md5(rand(1, 1000) . date('U'));
// TX Specific bits
$sagepay->setVendorTxCode($vendorTxCode);
$sagepay->setDescription('Test Payment');
$sagepay->setCustomerEmail('*****@*****.**');
$sagepay->setCreateToken(1);
// Set up addresses
$BillingAddress = new dwmsw\sagepay\Address();
$BillingAddress->setName('Test', 'Person');
$BillingAddress->setPhone('01589658741');
$BillingAddress->setAddress('88', 'Street 2', 'City', 'GB', '412');