2017 © Pedro Peláez
 

library sagepay

Sagepay Direct V3 Wrapper

image

dwmsw/sagepay

Sagepay Direct V3 Wrapper

  • Saturday, March 10, 2018
  • by darylldoyle
  • Repository
  • 4 Watchers
  • 3 Stars
  • 1,962 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 16 Versions
  • 7 % Grown

The README.md

dwmsw/sagepay

Build Status Code Climate Test Coverage, (*1)

Description

dwmsw/sagepay is a library for interacting with the Sagepay Direct v3.00 protocol, (*2)

It aims to make interacting with Sagepay as easy as possible and is available as a composer package on packagist, (*3)

This wrapper doesn't include any database implementations, it is purely here to make interacting with the Sagepay API easier and to add a level of validation. All methods that send the data to Sagepay will return the response to you in an associative array, with nothing added or removed., (*4)

It has been built this way as to not restrict developers to certain database implementations or structures. We prefer for you to be able to use the data however you like., (*5)

Installation

Installing via composer is the best way. Run the following from the CLI, (*6)

composer require dwmsw/sagepay, (*7)

What is implemented?

  • Payments (with or without tokens)
  • Deferred Payments w/ release
  • Discounts
  • Refunds
  • 3D Secure

Basic Usage

Payment, (*8)

// Create instance of Direct
$sagepay = new dwmsw\sagepay\Direct();

// New Basket instance
$basket = new dwmsw\sagepay\Basket();
// Add an item to the basket
$basket->addItem(new dwmsw\sagepay\Item('Test Item', 30.00, 6, 1));
// Add another item to the basket
$basket->addItem(new dwmsw\sagepay\Item('Test Item Two', 30.00, 6, 2));
// Add a discount
$basket->addDiscount(new dwmsw\sagepay\Discount(50.00, 'This is a discount'));

// Set the Basket
$sagepay->setBasket($basket);

// Set up the config
$sagepay->setConnectionMode(CONNECTION MODE TEST/LIVE);
$sagepay->setVendorName(YOUR VENDOR NAME);
$sagepay->setCurrency('GBP');
$sagepay->setApplyAvsCv2(1);
$sagepay->setApply3dSecure(0);
$sagepay->setGiftAid(0);

$vendorTxCode = md5(rand(1, 1000));

// TX Specific bits
$sagepay->setVendorTxCode($vendorTxCode);
$sagepay->setDescription('Test Payment');
$sagepay->setCustomerEmail('daryll@digitalwebmedia.co.uk');

// Set up addresses
$BillingAddress = new dwmsw\sagepay\Address();
$BillingAddress->setName('Daryll', 'Doyle');
$BillingAddress->setPhone('46554789658');
$BillingAddress->setAddress('88', 'Test Address', 'Town', 'GB', '412');

// Set Addresses into the class
$sagepay->setBillingAddress($BillingAddress);
// Delivery Address can be a different instance of address if needed
$sagepay->setDeliveryAddress($BillingAddress);

// New card instance
$card = new dwmsw\sagepay\Card();
// Card details 
$card->setCardHolder('Mr D Doyle');
$card->setCardType('VISA');
$card->setCardNumber('4929000000006');
$card->setStartDate(false);
$card->setExpiryDate('1216');
$card->setCV2('123');

$sagepay->setCard($card);

$output = $sagepay->register('PAYMENT');

// Do whatever you want with $output

To use tokens with payments, you'll initially need to pass the following in your setup:, (*9)

$sagepay->setCreateToken(1);

This will tell sagepay to return you a token when payments are successful. You can then use this token, to make further payments., (*10)

To make a payment using a token, you don't enter the card details, but instead use the following:, (*11)

// New card instance
$card = new dwmsw\sagepay\Card();
$card->setToken('TOKEN');
$card->setCV2('CV2');

$sagepay->setCard($card);

When using a token, the class automatically sets StoreToken to 1 to persist the token. Although I will probably add an option to change this at some point!, (*12)

DEFERRED, (*13)

// As above, but use the following line
$output = $sagepay->register('DEFERRED');

RELEASE, (*14)

// Create instance of Direct
$sagepay = new dwmsw\sagepay\Direct();
// Make the release
$output = $sagepay->release('VPSTxId', 'SecurityKey', 'vendorTxCode', 'TxAuthNo', 'AMOUNT TO RELEASE');

// Do whatever with $output

REFUND, (*15)

// Create instance of Direct
$sagepay = new dwmsw\sagepay\Direct();
// Make the refund
$output = $sagepay->refund('NEWvendorTxCode', 'AMOUNT TO REFUND', 'OLDVPSTxId', 'OLDvendorTxCode', 'OLDSecurityKey', 'OLDTxAuthNo', 'Refund Message');

// Do whatever with $output

3D Secure, (*16)

// Create instance of Direct
$sagepay = new dwmsw\sagepay\Direct();
$sagepay->setConnectionMode('test');

// Send the output back to Sagepay
$output = $sagepay->threeDResponse($_POST['MD'], $_POST['PaRes']);

To Do

  • Paypal Integration

Getting Involved

  • Open an issue with a feature you'd like
  • Make a PR
  • Write any tests that may be missing!

The Versions

10/03 2018

dev-master

9999999-dev https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

10/03 2018

1.9.0

1.9.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

25/08 2016

1.8.1

1.8.1.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

25/08 2016

1.8.0

1.8.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

17/09 2015

1.7.0

1.7.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

17/09 2015

1.6.1

1.6.1.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

17/09 2015

1.6.0

1.6.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

07/01 2015

1.5.1

1.5.1.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

07/01 2015

1.5.0

1.5.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

07/01 2015

1.4.0

1.4.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

04/01 2015

1.3.0

1.3.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

07/11 2014

1.2.0

1.2.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

07/11 2014

dev-3D-Secure

dev-3D-Secure https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

07/11 2014

1.1.0

1.1.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

06/11 2014

1.0.0

1.0.0.0 https://github.com/dwmsw/sagepay

Sagepay Direct V3 Wrapper

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay

05/11 2014

0.0.1

0.0.1.0 https://github.com/dwmsw/sagepay

Sagepay integration

  Sources   Download

GPLv3

The Requires

 

The Development Requires

payment pay gateway merchant purchase sagepay sage pay