Skip to content

Commit a965db0

Browse files
committed
Set back unneeded elements
1 parent 99ffdc7 commit a965db0

30 files changed

Lines changed: 4503 additions & 66 deletions

README.markdown renamed to README.md

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
# Ogone PHP library #
1+
# PostFinance PHP library #
22

3-
This library allows you to easily implement an [Ogone](http://ogone.com) integration into your project.
4-
It provides the necessary components to complete a correct payment flow with the [Ogone](http://ogone.com) platform.
5-
6-
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/marlon-be/marlon-ogone/badges/quality-score.png?s=ceabe3e767cad807b589fc63169e6a330d20f9fa)](https://scrutinizer-ci.com/g/marlon-be/marlon-ogone/)
7-
[![Build Status](https://travis-ci.org/marlon-be/marlon-ogone.png)](https://travis-ci.org/marlon-be/marlon-ogone)
3+
This library allows you to easily implement an [PostFinance](https://www.postfinance.ch/) integration into your project.
4+
It provides the necessary components to complete a correct payment flow with the [PostFinance](https://www.postfinance.ch/) platform.
85

96
Requirements:
107

118
- PHP 5.3
12-
- network connection between your webserver and the Ogone platform
9+
- network connection between your webserver and the PostFinance platform
1310

1411
As always, this is work in progress. Please feel free to fork this project and let them pull requests coming!
1512

16-
## Overview ##
13+
Installation:
14+
-------------
15+
The library is [PSR-0 compliant](http://www.php-fig.org/psr/psr-0/fr/)
16+
and the simplest way to install it is via composer
1717

18-
The library complies to the [PSR-0 standard](http://groups.google.com/group/php-standards/web/psr-0-final-proposal),
19-
so it can be autoloaded using PSR-0 classloaders like the one in Symfony2. See autoload.php for an example.
18+
composer require wysow/postfinance
19+
20+
## Overview ##
2021

21-
- Create an EcommercePaymentRequest or CreateAliasRequest, containing all the info needed by Ogone.
22+
- Create an EcommercePaymentRequest or CreateAliasRequest, containing all the info needed by PostFinance.
2223
- Generate a form
23-
- Submit it to Ogone (client side)
24-
- Receive a PaymentResponse back from Ogone (as a HTTP Request)
24+
- Submit it to PostFinance (client side)
25+
- Receive a PaymentResponse back from PostFinance (as a HTTP Request)
2526

2627
Both EcommercePaymentRequest, CreateAliasRequest and PaymentResponse are authenticated by comparing the SHA sign, which is a hash of the parameters and a secret passphrase. You can create the hash using a ShaComposer.
2728

2829
# SHA Composers #
2930

30-
Ogone provides 2 methods to generate a SHA sign:
31+
PostFinance provides 2 methods to generate a SHA sign:
3132

3233
- "Main parameters only"
3334

@@ -37,7 +38,7 @@ Ogone provides 2 methods to generate a SHA sign:
3738

3839
```php
3940
<?php
40-
use Ogone\ShaComposer\LegacyShaComposer;
41+
use PostFinance\ShaComposer\LegacyShaComposer;
4142
$shaComposer = new LegacyShaComposer($passphrase);
4243
```
4344

@@ -49,7 +50,7 @@ Ogone provides 2 methods to generate a SHA sign:
4950

5051
```php
5152
<?php
52-
use Ogone\ShaComposer\AllParametersShaComposer;
53+
use PostFinance\ShaComposer\AllParametersShaComposer;
5354
$shaComposer = new AllParametersShaComposer($passphrase);
5455
```
5556

@@ -59,19 +60,19 @@ This library currently supports both the legacy method "Main parameters only" an
5960

6061
```php
6162
<?php
62-
use Ogone\Passphrase;
63-
use Ogone\Ecommerce\EcommercePaymentRequest;
64-
use Ogone\ShaComposer\AllParametersShaComposer;
65-
use Ogone\FormGenerator;
63+
use PostFinance\Passphrase;
64+
use PostFinance\Ecommerce\EcommercePaymentRequest;
65+
use PostFinance\ShaComposer\AllParametersShaComposer;
66+
use PostFinance\FormGenerator;
6667

6768
$passphrase = new Passphrase('my-sha-in-passphrase-defined-in-ogone-interface');
6869
$shaComposer = new AllParametersShaComposer($passphrase);
6970
$shaComposer->addParameterFilter(new ShaInParameterFilter); //optional
7071

7172
$ecommercePaymentRequest = new EcommercePaymentRequest($shaComposer);
7273

73-
// Optionally set Ogone uri, defaults to TEST account
74-
//$ecommercePaymentRequest->setOgoneUri(EcommercePaymentRequest::PRODUCTION);
74+
// Optionally set PostFinance uri, defaults to TEST account
75+
//$ecommercePaymentRequest->setPostFinanceUri(EcommercePaymentRequest::PRODUCTION);
7576

7677
// Set various params:
7778
$ecommercePaymentRequest->setOrderid('123456');
@@ -91,33 +92,33 @@ This library currently supports both the legacy method "Main parameters only" an
9192
```php
9293
<?php
9394

94-
use Ogone\Passphrase;
95-
use Ogone\DirectLink\CreateAliasRequest;
96-
use Ogone\ShaComposer\AllParametersShaComposer;
97-
use Ogone\DirectLink\Alias;
95+
use PostFinance\Passphrase;
96+
use PostFinance\DirectLink\CreateAliasRequest;
97+
use PostFinance\ShaComposer\AllParametersShaComposer;
98+
use PostFinance\DirectLink\Alias;
9899

99100
$passphrase = new Passphrase('my-sha-in-passphrase-defined-in-ogone-interface');
100101
$shaComposer = new AllParametersShaComposer($passphrase);
101102
$shaComposer->addParameterFilter(new ShaInParameterFilter); //optional
102103

103104
$createAliasRequest = new CreateAliasRequest($shaComposer);
104105

105-
// Optionally set Ogone uri, defaults to TEST account
106-
// $createAliasRequest->setOgoneUri(CreateAliasRequest::PRODUCTION);
106+
// Optionally set PostFinance uri, defaults to TEST account
107+
// $createAliasRequest->setPostFinanceUri(CreateAliasRequest::PRODUCTION);
107108

108109
// set required params
109110
$createAliasRequest->setPspid('123456');
110111
$createAliasRequest->setAccepturl('http://example.com/accept');
111112
$createAliasRequest->setExceptionurl('http://example.com/exception');
112113

113-
// set optional alias, if empty, Ogone creates one
114+
// set optional alias, if empty, PostFinance creates one
114115
$alias = new Alias('customer_123');
115116
$createAliasRequest->setAlias($alias);
116117

117118
$createAliasRequest->validate();
118119

119120
// Now pass $createAliasRequest to a view to build a custom form, you have access to
120-
// $createAliasRequest->getOgoneUri(), $createAliasRequest->getParameters() and $createAliasRequest->getShaSign()
121+
// $createAliasRequest->getPostFinanceUri(), $createAliasRequest->getParameters() and $createAliasRequest->getShaSign()
121122
// Be sure to add the required fields CN (Card holder's name), CARDNO (Card/account number), ED (Expiry date (MMYY)), CVC (Card Verification Code)
122123
// and the SHASIGN
123124
```
@@ -127,10 +128,10 @@ This library currently supports both the legacy method "Main parameters only" an
127128
```php
128129
<?php
129130

130-
use Ogone\DirectLink\DirectLinkPaymentRequest;
131-
use Ogone\Passphrase;
132-
use Ogone\ShaComposer\AllParametersShaComposer;
133-
use Ogone\DirectLink\Alias;
131+
use PostFinance\DirectLink\DirectLinkPaymentRequest;
132+
use PostFinance\Passphrase;
133+
use PostFinance\ShaComposer\AllParametersShaComposer;
134+
use PostFinance\DirectLink\Alias;
134135

135136
$passphrase = new Passphrase('my-sha-in-passphrase-defined-in-ogone-interface');
136137
$shaComposer = new AllParametersShaComposer($passphrase);
@@ -148,8 +149,8 @@ This library currently supports both the legacy method "Main parameters only" an
148149
$directLinkRequest->setCurrency('EUR');
149150
$directLinkRequest->validate();
150151

151-
// now create a url to be posted to Ogone
152-
// you have access to $directLinkRequest->toArray(), $directLinkRequest->getOgoneUri() and directLinkRequest->getShaSign()
152+
// now create a url to be posted to PostFinance
153+
// you have access to $directLinkRequest->toArray(), $directLinkRequest->getPostFinanceUri() and directLinkRequest->getShaSign()
153154
```
154155

155156

@@ -158,8 +159,8 @@ This library currently supports both the legacy method "Main parameters only" an
158159
```php
159160
<?php
160161

161-
use Ogone\Ecommerce\EcommercePaymentResponse;
162-
use Ogone\ShaComposer\AllParametersShaComposer;
162+
use PostFinance\Ecommerce\EcommercePaymentResponse;
163+
use PostFinance\ShaComposer\AllParametersShaComposer;
163164

164165
// ...
165166

@@ -182,8 +183,8 @@ This library currently supports both the legacy method "Main parameters only" an
182183
```php
183184
<?php
184185

185-
use Ogone\DirectLink\CreateAliasResponse;
186-
use Ogone\ShaComposer\AllParametersShaComposer;
186+
use PostFinance\DirectLink\CreateAliasResponse;
187+
use PostFinance\ShaComposer\AllParametersShaComposer;
187188

188189
// ...
189190

@@ -209,7 +210,7 @@ As the DirectLink payment gets an instant feedback from the server (and no async
209210
```php
210211
<?php
211212

212-
use Ogone\DirectLink\DirectLinkPaymentResponse;
213+
use PostFinance\DirectLink\DirectLinkPaymentResponse;
213214

214215
$directLinkResponse = new DirectLinkPaymentResponse('ogone-direct-link-result-as-xml');
215216

@@ -224,5 +225,5 @@ As the DirectLink payment gets an instant feedback from the server (and no async
224225

225226
# Parameter filters #
226227
ParameterFilters are used to filter the provided parameters (no shit Sherlock).
227-
Both ShaIn- and ShaOutParameterFilters are provided and are based on the parameter lists defined in the Ogone documentation.
228+
Both ShaIn- and ShaOutParameterFilters are provided and are based on the parameter lists defined in the PostFinance documentation.
228229
Parameter filtering is optional, but we recommend using them to enforce expected parameters.

autoload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
* This file is part of the Marlon Ogone package.
4+
* This file is part of the Marlon PostFinance package.
55
*
66
* (c) Marlon BVBA <info@marlon.be>
77
*
@@ -14,6 +14,6 @@
1414

1515
$loader = new UniversalClassLoader;
1616
$loader->registerNamespaces(array(
17-
'Ogone' => __DIR__ . '/lib/'
17+
'PostFinance' => __DIR__ . '/lib/'
1818
));
1919
$loader->register();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/*
3+
* This file is part of the Wysow PostFinance package.
4+
*
5+
* (c) Gaultier Boniface <gboniface@wysow.fr>
6+
* (c) Marlon BVBA <info@marlon.be>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PostFinance\DirectLink;
13+
14+
use InvalidArgumentException;
15+
16+
class Alias {
17+
18+
/** @var string */
19+
private $alias;
20+
21+
public function __construct($alias)
22+
{
23+
if(empty($alias)) {
24+
throw new InvalidArgumentException("Alias cannot be empty");
25+
}
26+
27+
if(strlen($alias) > 50) {
28+
throw new InvalidArgumentException("Alias is too long");
29+
}
30+
31+
if(preg_match('/[^a-zA-Z0-9_-]/', $alias)) {
32+
throw new InvalidArgumentException("Alias cannot contain special characters");
33+
}
34+
35+
$this->alias = $alias;
36+
}
37+
38+
public function __toString()
39+
{
40+
return (string) $this->alias;
41+
}
42+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/*
3+
* This file is part of the Wysow PostFinance package.
4+
*
5+
* (c) Gaultier Boniface <gboniface@wysow.fr>
6+
* (c) Marlon BVBA <info@marlon.be>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PostFinance\DirectLink;
13+
14+
use PostFinance\AbstractRequest;
15+
use PostFinance\ShaComposer\ShaComposer;
16+
17+
class CreateAliasRequest extends AbstractRequest {
18+
19+
const TEST = "https://secure.PostFinance.com/ncol/test/alias_gateway_utf8.asp";
20+
const PRODUCTION = "https://secure.PostFinance.com/ncol/prod/alias_gateway_utf8.asp";
21+
22+
public function __construct(ShaComposer $shaComposer)
23+
{
24+
$this->shaComposer = $shaComposer;
25+
$this->PostFinanceUri = self::TEST;
26+
}
27+
28+
public function getRequiredFields()
29+
{
30+
return array(
31+
'pspid', 'accepturl', 'exceptionurl'
32+
);
33+
}
34+
35+
public function getValidPostFinanceUris()
36+
{
37+
return array(self::TEST, self::PRODUCTION);
38+
}
39+
40+
public function setAlias(Alias $alias)
41+
{
42+
$this->parameters['alias'] = (string) $alias;
43+
}
44+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/*
3+
* This file is part of the Wysow PostFinance package.
4+
*
5+
* (c) Gaultier Boniface <gboniface@wysow.fr>
6+
* (c) Marlon BVBA <info@marlon.be>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PostFinance\DirectLink;
13+
14+
use PostFinance\AbstractResponse;
15+
use PostFinance\ShaComposer\ShaComposer;
16+
17+
class CreateAliasResponse extends AbstractResponse {
18+
19+
const STATUS_OK = 0;
20+
const STATUS_NOK = 1;
21+
const STATUS_UPDATED = 2;
22+
23+
/**
24+
* Checks if the response is valid
25+
* @return bool
26+
*/
27+
public function isValid(ShaComposer $shaComposer)
28+
{
29+
return $shaComposer->compose($this->parameters) == $this->shaSign;
30+
}
31+
32+
public function isSuccessful()
33+
{
34+
return in_array($this->getParam('STATUS'), array(self::STATUS_OK, self::STATUS_UPDATED));
35+
}
36+
37+
public function getAlias()
38+
{
39+
return new Alias($this->parameters['ALIAS']);
40+
}
41+
}

0 commit comments

Comments
 (0)