Skip to content

Commit

Permalink
Merge pull request #13 from juriansluiman/feature/refactoring
Browse files Browse the repository at this point in the history
Feature/refactoring
  • Loading branch information
Jurian Sluiman committed Aug 11, 2013
2 parents 6aa6693 + df06042 commit 0995088
Show file tree
Hide file tree
Showing 28 changed files with 3,583 additions and 474 deletions.
14 changes: 0 additions & 14 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,11 @@

class Module implements
Feature\AutoloaderProviderInterface,
Feature\ServiceProviderInterface,
Feature\ConfigProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
Expand All @@ -66,14 +62,4 @@ public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

/**
* Go to the service configuration
*
* @return array
*/
public function getServiceConfig()
{
return include __DIR__ . '/config/services.config.php';
}
}
179 changes: 178 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,181 @@
SlmIdealPayment
===============
[![Build Status](https://travis-ci.org/juriansluiman/SlmIdealPayment.png)](https://travis-ci.org/juriansluiman/SlmIdealPayment)
[![Latest Stable Version](https://poser.pugx.org/slm/ideal-payment/v/stable.png)](https://packagist.org/packages/slm/ideal-payment)

This module is a Zend Framework 2 module to provide iDEAL payments (a Dutch payment system).
Created by Jurian Sluiman

Introduction
---
SlmIdealPayment is a Zend Framework 2 module to provide payments via the iDEAL
system. iDEAL is a payment service for the Dutch market and allows integration
of payments for almost all Dutch banks.

The module provides integration for the so-called iDEAL professional / iDEAL
advanced method. Integration via iDEAL basic / iDEAL lite is not included.

> **Standalone usage:**
> This module is developed for Zend Framework 2, but can be used without the
> framework in your own application. There is no need to understand Zend
> Framework 2 to use this module.
### Supported acquirers

SlmIdealPayment works with the following banks (or acquirers in iDEAL terms):

1. Rabobank
2. ING Bank
3. ABN Amro

Installation
---
The module can be loaded via composer. Require `slm/ideal-payment` in your
composer.json file. If you do not have a composer.json file in the root of your
project, copy the contents below and put that into a file called composer.json
and save it in the root of your project:

```
{
"require": {
"slm/ideal-payment": "@dev"
}
}
```

Then execute the following commands in a CLI:

```
curl -s http://getcomposer.org/installer | php
php composer.phar install
```

Now you should have a vendor directory, including a slm/ideal-payment. In your
bootstrap code, make sure you include the vendor/autoload.php file to properly
load the SlmIdealPayment module.

Configuration
---
The file `slmidealpayment.local.php.dist` eases the iDEAL configuration. Copy
the file from `vendor/slm/ideal-payment/config/slmidealpayment.local.php.dist`
to your autoload folder and remove the `.dist` extension.

Open the file and update the values to your needs. If you do not have a SSL
certificate, you can use a self-signed certificate and upload that one to the
iDEAL dashboard of your acquirer. Generate a key with 2048 bits encryption with
the following command:

```
openssl genrsa –aes128 –out priv.pem –passout pass:[privateKeyPass] 2048
```

Then create a certificate valid for 5 years:

```
openssl req –x509 –sha256 –new –key priv.pem –passin pass:[privateKeyPass]
-days 1825 –out cert.cer
```

Then use the `priv.pem` and `cert.cer` files for the iDEAL signatures.

Usage
---
SlmIdealPayments will setup the client with the correct properties. Use the
following names to request an instance from the service manager:

1. Rabobank: `SlmIdealPayment\Client\Standard\Rabobank`
2. ING Bank: `SlmIdealPayment\Client\Standard\Ing`
3. ABN Amro: `SlmIdealPayment\Client\Standard\AbnAmro`

### Directory request
Then use the client to perform the request. A directory request gives a list of
supported issuers. The result is a `SlmIdealPayment\Response\DirectoryResponse`:

```php
$client = $sl->get('SlmIdealPayment\Client\Standard\Rabobank');

$request = new DirectoryRequest;
$response = $client->send($request);

foreach ($response->getContries() as $country) {
echo sprintf("Country: %s\n", $country->getName());

foreach ($country->getIssuers() as $issuer) {
echo sprintf("%s: %s\n", $issuer->getId(), $issuer->getName());
}
}
```

### Transaction request
A transaction request needs a Transaction object. The result is a
`SlmIdealPayment\Response\TransactionResponse` object:

```php
use SlmIdealPayment\Model;

$client = $sl->get('SlmIdealPayment\Client\Standard\Rabobank');

// Set up the issuer
$issuer = new Model\Issuer;
$issuer->setId($issuerId); // set selected issuer here

// Set up the transaction
$transaction = new Model\Transaction;
$transaction->setPurchaseId($purchaseId);
$transaction->setAmount($amount);
$transaction->setDescription($description);
$transaction->setEntranceCode($ec);

$request = new TransactionRequest;
$request->setIssuer($issuer);
$request->setTransaction($transaction);

$response = $client->send($request);

echo $response->getTransaction()->getTransactionId();

// Then perform redirect:
// Redirect to $response->getAuthenticationUrl();
```

### Status request
A status request also needs a transaction object, but then for its transaction
id. The result is a `SlmIdealPayment\Response\StatusRequest`:

```php
use SlmIdealPayment\Model;

$client = $sl->get('SlmIdealPayment\Client\Standard\Rabobank');

$transaction = new Model\Transaction;
$transaction->setTransactionId($transactionId);

$request = new StatusRequest;
$request->setTransaction($transaction);

$response = $client->send($request);

echo $response->getTransaction()->getStatus();
```

Using SlmIdealPayment outside ZF2
===
You can use the client without Zend Framework 2. Only the HTTP client is used
inside the client and it's a small dependency you can load in any project you
have. However, you need to configure all variables yourself.

```php
use SlmIdealPayment\Client\StandardClient;

$client = new StandardClient;
$client->setRequestUrl('https://ideal.rabobank.nl/ideal/iDEALv3');
$client->setMerchantId('00X0XXXXX');
$client->setSubId('0');

$client->setPublicCertificate('data/ssl/rabobank.cer');
$client->setPrivateCertificate('data/ssl/cert.cer');

$client->setKeyFile('data/ssl/priv.pem');
$client->setKeyPassword('h4x0r');
```

Now `$client` is configured, use above methods to perform the various requests.
25 changes: 0 additions & 25 deletions autoload_classmap.php

This file was deleted.

12 changes: 0 additions & 12 deletions autoload_function.php

This file was deleted.

2 changes: 0 additions & 2 deletions autoload_register.php

This file was deleted.

26 changes: 19 additions & 7 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@
* @link http://juriansluiman.nl
*/

use Zend\Http\Client as HttpClient;

return array(
'ideal' => array(
'slm_ideal_payment' => array(
'production' => true,
'merchant_id' => '',
'sub_id' => '',
'certificate' => '',
'key_file' => '',
'key_password' => '',

'enable_validation' => true,
'validation_scheme' => __DIR__ . '/../data/AcceptantAcquirer.xsd',

'ssl_options' => array(
'sslcapath' => '/etc/ssl/certs',
),
Expand All @@ -62,10 +64,20 @@
'live' => 'https://ideal.secure-ing.com/ideal/iDeal',
'certificate' => __DIR__ . '/../data/ing.cer',
),
'rabo' => array(
'test' => 'https://idealtest.rabobank.nl/ideal/iDeal',
'live' => 'https://ideal.rabobank.nl/ideal/iDeal',
'certificate' => __DIR__ . '/../data/rabo.cer',
'rabobank' => array(
'test' => 'https://idealtest.rabobank.nl/ideal/iDEALv3',
'live' => 'https://ideal.rabobank.nl/ideal/iDEALv3',
'certificate' => __DIR__ . '/../data/rabo_ideal_v3.cer',
),
),

'service_manager' => array(
'factories' => array(
'SlmIdealPayment\Client\StandardClient' => 'SlmIdealPayment\Service\StandardClientFactory',

'SlmIdealPayment\Client\Standard\Rabobank' => 'SlmIdealPayment\Service\StandardClientFactory',
'SlmIdealPayment\Client\Standard\Ing' => 'SlmIdealPayment\Service\StandardClientFactory',
'SlmIdealPayment\Client\Standard\AbnAmro' => 'SlmIdealPayment\Service\StandardClientFactory',
),
),
);
Loading

0 comments on commit 0995088

Please sign in to comment.