2017 © Pedro Peláez
 

library saferpay

Saferpay payment service library

image

payment/saferpay

Saferpay payment service library

  • Friday, April 20, 2018
  • by dominikzogg
  • Repository
  • 7 Watchers
  • 18 Stars
  • 16,563 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 16 Forks
  • 1 Open issues
  • 25 Versions
  • 1 % Grown

The README.md

Saferpay API, an unofficial implementation

Build Status Total Downloads Latest Stable Version, (*1)

installation

with buzz

```{.json} "payment/saferpay": "~3.0" "payment/httpclient-buzz": "~1.2", (*2)


##### with guzzle ```{.json} "payment/saferpay": "~3.0" "payment/httpclient-guzzle": "~1.1"

a simple implementation

uses default (with buzz client)

```{.php} use Payment\HttpClient\BuzzClient; use Payment\Saferpay\Data\PayInitParameter;, (*3)


##### creating a saferpay instance ```{.php} use Payment\Saferpay\Saferpay; $saferpay = new Saferpay;
set httpclient (with buzz)

```{.php} $saferpay->setHttpClient(new BuzzClient());, (*4)


##### implementation ```{.php} $amount = 1200; $currency = 'CHF'; if (getParam('status') == 'success') { $payConfirmParameter = $saferpay->verifyPayConfirm(getParam('DATA'), getParam('SIGNATURE')); if ($payConfirmParameter->get('AMOUNT') == $amount && $payConfirmParameter->get('CURRENCY') == $currency) { $saferpay->payCompleteV2($payConfirmParameter, 'Settlement'); echo 'payment success!'; } else { $saferpay->payCompleteV2($payConfirmParameter, 'Cancel'); echo 'payment failed!'; } } else { $payInitParameter = new PayInitParameter(); $payInitParameter->setAccountid(PayInitParameter::SAFERPAYTESTACCOUNT_ACCOUNTID); $payInitParameter->setAmount($amount); $payInitParameter->setCurrency($currency); $payInitParameter->setDescription(sprintf('Ordernumber: %s', '000001')); $payInitParameter->setSuccesslink(requestUrl() . '?status=success'); $payInitParameter->setFaillink(requestUrl() . '?status=fail'); $payInitParameter->setBacklink(requestUrl() . '?status=back'); $payInitParameter->setDelivery('no'); // hide address form header('Location: ' . $saferpay->createPayInit($payInitParameter) , 302); }

a billpay implemention (works only with providerset, use it standalone)

uses billpay (with buzz client)

```{.php} use Payment\HttpClient\BuzzClient; use Payment\Saferpay\Data\PayInitParameter; use Payment\Saferpay\Data\PayConfirmParameter; use Payment\Saferpay\Data\PayCompleteParameter; use Payment\Saferpay\Data\PayCompleteResponse; use Payment\Saferpay\Data\Billpay\BillpayPayInitParameter; use Payment\Saferpay\Data\Billpay\BillpayPayConfirmParameter; use Payment\Saferpay\Data\Billpay\BillpayPayCompleteParameter; use Payment\Saferpay\Data\Billpay\BillpayPayCompleteResponse; use Payment\Saferpay\Data\Collection\Collection;, (*5)


##### creating a saferpay instance ```{.php} $saferpay = new Saferpay;
set httpclient (with buzz)

```{.php} $saferpay->setHttpClient(new BuzzClient());, (*6)


##### implementation ```{.php} $amount = 1200; $currency = 'CHF'; if (getParam('status') == 'success') { $payConfirmParameter = new PayConfirmParameter; $billpayPayConfirmParameter = new BillpayPayConfirmParameter; $payConfirmParameterCollection = new Collection($payConfirmParameter->getRequestUrl()); $payConfirmParameterCollection->addCollectionItem($payConfirmParameter); $payConfirmParameterCollection->addCollectionItem($billpayPayConfirmParameter); $payConfirmParameterCollection = $this->getSaferpay()->verifyPayConfirm( getParam('DATA'), getParam('SIGNATURE'), $objPayConfirmParameterCollection ); $payCompleteParameter = new PayCompleteParameter; $billpayPayCompleteParameter = new BillpayPayCompleteParameter; $payCompleteParameterCollection = new Collection($payCompleteParameter->getRequestUrl()); $payCompleteParameterCollection->addCollectionItem($payCompleteParameter); $payCompleteParameterCollection->addCollectionItem($billpayPayCompleteParameter); $payCompleteResponse = new PayCompleteResponse; $billpayPayCompleteResponse = new BillpayPayCompleteResponse; $payCompleteResponseCollection = new Collection($payCompleteResponse->getRequestUrl()); $payCompleteResponseCollection->addCollectionItem($payCompleteResponse); $payCompleteResponseCollection->addCollectionItem($billpayPayCompleteResponse); if ($payConfirmParameterCollection->get('AMOUNT') == $amount && $payConfirmParameterCollection->get('CURRENCY') == $currency) { $this->getSaferpay()->payCompleteV2( $payConfirmParameterCollection, 'Settlement', PayInitParameter::SAFERPAYTESTACCOUNT_SPPASSWORD, $payCompleteParameterCollection, $payCompleteResponseCollection ); echo 'payment success!'; } else { $this->getSaferpay()->payCompleteV2( $payConfirmParameterCollection, 'Cancel', PayInitParameter::SAFERPAYTESTACCOUNT_SPPASSWORD, $payCompleteParameterCollection, $payCompleteResponseCollection ); echo 'payment failed!'; } } else { $payInitParameter = new PayInitParameter(); $payInitParameter->setAccountid(PayInitParameter::SAFERPAYTESTACCOUNT_ACCOUNTID); $payInitParameter->setAmount($amount); $payInitParameter->setCurrency($currency); $payInitParameter->setDescription(sprintf('Ordernumber: %s', '000001')); $payInitParameter->setSuccesslink(requestUrl() . '?status=success'); $payInitParameter->setFaillink(requestUrl() . '?status=fail'); $payInitParameter->setBacklink(requestUrl() . '?status=back'); $payInitParameter->setProviderset(array(BillpayPayInitParameter::PROVIDERSET_BILLPAY_INVOICE)); $billpayPayInitParameter = new BillpayPayInitParameter(); $billpayPayInitParameter->setLegalform(BillpayPayInitParameter::LEGALFORM_MISC); $billpayPayInitParameter->setDeliveryGender(BillpayPayInitParameter::GENDER_COMPANY); $billpayPayInitParameter->setDeliveryFirstname('John'); $billpayPayInitParameter->setDeliveryLastname('Doe'); $billpayPayInitParameter->setDeliveryStreet('Samplestreet 0'); $billpayPayInitParameter->setDeliveryZip('00000'); $billpayPayInitParameter->setDeliveryCity('Samplecity'); $billpayPayInitParameter->setDeliveryCountry('US'); $billpayPayInitParameter->setDeliveryPhone('+10000000000'); $payInitParameterCollection = new Collection($payInitParameter->getRequestUrl()); $payInitParameterCollection->addCollectionItem($payInitParameter); $payInitParameterCollection->addCollectionItem($billpayPayInitParameter); header('Location: ' . $saferpay->createPayInit($payInitParameterCollection) , 302); }
we define some helpers (plain php)

```{.php} function requestUrl() { $protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))); return $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; }, (*7)

function getParam($key, $default = null) { return array_key_exists($key, $_REQUEST) ? $_REQUEST[$key] : $default; } ```, (*8)

The Versions

20/04 2018

dev-master

9999999-dev

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

29/09 2016

3.1.1

3.1.1.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

18/11 2015

3.1.0

3.1.0.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

03/07 2014

2.0.x-dev

2.0.9999999.9999999-dev

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

03/07 2014

2.2.4

2.2.4.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

03/07 2014

3.0.2

3.0.2.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

27/05 2014

2.2.3

2.2.3.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

27/05 2014

3.0.1

3.0.1.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

01/02 2014

3.0.0

3.0.0.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

01/11 2013

2.2.2

2.2.2.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

01/11 2013

2.2.1

2.2.1.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

01/09 2013

2.2.0

2.2.0.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

28/06 2013

2.1.2

2.1.2.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

27/06 2013

2.1.1

2.1.1.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

27/06 2013

2.1.0

2.1.0.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

24/06 2013

2.0.5

2.0.5.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

24/06 2013

2.0.4

2.0.4.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

21/06 2013

2.0.3

2.0.3.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

21/06 2013

2.0.2

2.0.2.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

21/06 2013

2.0.1

2.0.1.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

17/06 2013

2.0.0

2.0.0.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

payment e-commerce saferpay

07/05 2013

dev-old

dev-old

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

by Dominik Zogg

payment e-commerce saferpay

07/05 2013

1.0.2

1.0.2.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

by Dominik Zogg

payment e-commerce saferpay

06/05 2013

1.0.1

1.0.1.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

by Dominik Zogg

payment e-commerce saferpay

25/02 2013

1.0.0

1.0.0.0

Saferpay payment service library

  Sources   Download

MIT

The Requires

 

by Dominik Zogg

payment e-commerce saferpay