2017 © Pedro Peláez
 

library postfinance

Helper class to work with the PostFinance e-payment system

image

offline/postfinance

Helper class to work with the PostFinance e-payment system

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PostFinance e-payment helper class

This class helps to implement basic e-commerce features from PostFinance Switzerland. The implementation follows the official documentation., (*1)

Install it

composer require 'offline/postfinance'

Use it

See index.php for an example., (*2)

Define your parameters as an array. Get your SHA-IN signature at hand. Initialize a class instance and pass your parameter array to setParamList., (*3)

$shaInSignature = 'Configuration -> Technical information -> Data and origni verification -> SHA-IN pass phrase';
$params = [
    'PSPID'        => 'your-postfinance-username',
    'ORDERID'      => '1234',
    'AMOUNT'       => '200' * 100,
    'CURRENCY'     => 'CHF',
    'LANGUAGE'     => 'de_CH',
];

$postfinance = new Offline\PaymentGateways\PostFinance($shaInSignature);
$postfinance->setParamList($params);

In your view file call getFormFields wherever you want to output the hidden input fields., (*4)

<form action="https://e-payment.postfinance.ch/ncol/test/orderstandard.asp" method="post">

    <?= $postfinance->getFormFields(); ?>

    <input type="submit" value="Submit Example">
</form>

Using different algorithms

To use SHA256 or SHA512 algorithms, simply pass the php MHASH constant as second parameter:, (*5)

$postfinance256 = new Offline\PaymentGateways\PostFinance($shaInSignature, 'sha256');
$postfinance512 = new Offline\PaymentGateways\PostFinance($shaInSignature, 'sha512');

Validating SHA-OUT signatures

Make sure you have the option I would like to receive transaction feedback parameters on the redirection URLs. under Transaktion feedback enabled., (*6)

$shaOutSignature = 'Configuration -> Transaction feedback -> SHA-OUT pass phrase';
$shaSign = isset($_GET['SHASIGN']) ? $_GET['SHASIGN'] : '';

$postfinance = new PostFinance($shaOutSignature);
$postfinance->setParamList($_GET);

$isValid = $postfinance->getDigest() === $shaSign;

var_dump($isValid);

The Versions

29/05 2017

dev-master

9999999-dev

Helper class to work with the PostFinance e-payment system

  Sources   Download

MIT

by Tobias Kündig

29/05 2017

v1.0.1

1.0.1.0

Helper class to work with the PostFinance e-payment system

  Sources   Download

MIT

by Tobias Kündig

29/05 2017

dev-zihmm-mhash-replacement

dev-zihmm-mhash-replacement

Helper class to work with the PostFinance e-payment system

  Sources   Download

MIT

by Tobias Kündig

06/08 2015

1.0.0

1.0.0.0

Helper class to work with the PostFinance e-payment system

  Sources   Download

MIT

by Tobias Kündig