Skip to content

Commit

Permalink
1.9.0
Browse files Browse the repository at this point in the history
* Common: Update to v2.1 Paymill API
* WooCommerce: Support for Subscription Product End Settings, only newly
created subscriptions will be affected. Old subscriptions need to be
terminated manually on Paymill Dashboard
* WooCommerce: Support for Subscription pause/start, thanks to
https://twitter.com/osma
* WooCommerce: Several minor bugfixes contributed by
https://twitter.com/osma
  • Loading branch information
straightvisions-matthias-bathke committed Feb 26, 2015
1 parent 4b712e4 commit 4de798f
Show file tree
Hide file tree
Showing 64 changed files with 2,433 additions and 477 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ pip-log.txt
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

Changelog
=========
1.9.0
-----
* Common: Update to v2.1 Paymill API
* WooCommerce: Support for Subscription Product End Settings, only newly created subscriptions will be affected. Old subscriptions need to be terminated manually on Paymill Dashboard
* WooCommerce: Support for Subscription pause/start, thanks to https://twitter.com/osma
* WooCommerce: Several minor bugfixes contributed by https://twitter.com/osma

1.8.3
-----
* WooCommerce: Support for javascript based Multi-Step-Checkout like in "Bazar Shop")
* WooCommerce: Subscriptions-Support added for order delivery date plugin https://wordpress.org/plugins/order-delivery-date-for-woocommerce/

1.8.2
-----
* Common: Benchmark error fixed
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ PAYMILL for WordPress
* Contributors: Matthias Reuter
* Donate link:
* Tags: paymill, creditcard, elv, payment, woocommerce, paybutton, ecommerce, debitcard, subscriptions
* Requires at least: 4.0
* Tested up to: 4.0
* Stable tag: 1.8.2
* Requires at least: 4.1
* Tested up to: 4.1.1
* Stable tag: 1.9
* License: [GPLv3 or later](http://www.gnu.org/licenses/gpl-3.0.html)

With PAYMILL you are able to provide credit card based payments for your customers.
Expand All @@ -18,11 +18,11 @@ Plugin Description

Requires:
* PHP 5.3 or higher
* WordPress 4.0.x or higher
* WordPress 4.1.x or higher
* CuRL PHP extension

Supported Shops including subscriptions support:
* WooCommerce (2.2.x) + WooCommerce Subscriptions (1.5.x)
* WooCommerce (2.3.x) + WooCommerce Subscriptions (1.5.x)
* Magic Members (1.8.x)
* Pay Button (independent, light-weight payment form)

Expand Down
15 changes: 9 additions & 6 deletions lib/api/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
php:
- "5.5"
- "5.4"
- "5.3"
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
- hhvm

script: ant test
env:
global:
secure: "StaRWxgVW55YXMetUfL91rGDHJCBC0e3Nv9qYx5jg2aa9H0BIYhJ8vYtDXbKFEeGXWRnlLdPVclzRiIMdYQTZaBrjHxWVzE9N5stIyIq/Ik5hvkRs3h78ICSsDJB7SAun+aYv4vV/2kR44B0YiOhWZehV3IhAWO1Csd4HDjiQHY="
language: php

before_install: composer self-update
install: composer install
151 changes: 96 additions & 55 deletions lib/api/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
PAYMILL-PHP
===========

[![Build Status](https://travis-ci.org/paymill/paymill-php.png)](https://travis-ci.org/paymill/paymill-php)
[![Latest Stable Version](https://poser.pugx.org/paymill/paymill/v/stable.png)](https://packagist.org/packages/paymill/paymill)
[![Total Downloads](https://poser.pugx.org/paymill/paymill/downloads.png)](https://packagist.org/packages/paymill/paymill)
[![Build Status](https://travis-ci.org/paymill/paymill-php.png)](https://travis-ci.org/paymill/paymill-php)[![Latest Stable Version](https://poser.pugx.org/paymill/paymill/v/stable.png)](https://packagist.org/packages/paymill/paymill)[![Total Downloads](https://poser.pugx.org/paymill/paymill/downloads.png)](https://packagist.org/packages/paymill/paymill)

VERSIONING
----------

This wrapper is using the api v2.1 launched in June 2014. If you wish to use the old api v2.0 please use the wrapper in branch v2: https://github.com/paymill/paymill-php/tree/v2.

How to test
-----------
There are different credit card numbers, frontend and backend error codes, which can be used for testing.
For more information, please read our testing reference.
https://www.paymill.com/en-gb/documentation-3/reference/testing/

There are different credit card numbers, frontend and backend error codes, which can be used for testing. For more information, please read our testing reference. https://www.paymill.com/en-gb/documentation-3/reference/testing/

Getting started with PAYMILL
----------------------------

If you don't already use Composer, then you probably should read the installation guide http://getcomposer.org/download/.

Please include this library via Composer in your composer.json and execute **composer update** to refresh the autoload.php.

```json
{
"require": {
"paymill/paymill": "v3.0.0"
"repositories": [
{
"type": "vcs",
"url": "https://github.com/paymill/paymill-php"
}
],
"require": {
"paymill/paymill": "dev-master"
}
}
```

Expand All @@ -33,73 +41,106 @@ Lets say you have two files, which are going to use the PAYMILL lib. First one i
To load the PAYMILL library from the file, which is located in *your project root folder*, you need to **require** PAYMILL's **autoload** script like this:

```php
require './paymill-php/autoload.php';
require './paymill-php/autoload.php';
```

To load the PAYMILL library from the file, which is located in *the app folder*, you need to **require** PAYMILL's **autoload** script like this:

```php
require '../paymill-php/autoload.php';
require '../paymill-php/autoload.php';
```

1. Instantiate the request class with the following parameters:
$apiKey: First parameter is always your private API (test) Key

```php
$request = new Paymill\Request($apiKey);
```
2. Instantiate the model class with the parameters described in the API-reference:
```php
$payment = new Paymill\Models\Request\Payment();
$payment->setToken("098f6bcd4621d373cade4e832627b4f6");
```
3. Use your desired function:

```php
$response = $request->create($payment);
$paymentId = $response->getId();
```

It recommend to wrap it into a "try/catch" to handle exceptions like this:
```php
try{
$response = $request->create($payment);
$paymentId = $response->getId();
}catch(PaymillException $e){
//Do something with the error informations below
$e->getResponseCode();
$e->getStatusCode();
$e->getErrorMessage();
}
```
1. Instantiate the request class with the following parameters: $apiKey: First parameter is always your private API (test) Key

```php
$request = new Paymill\Request($apiKey);
```

1. Instantiate the model class with the parameters described in the API-reference:

```php
$payment = new \Paymill\Models\Request\Payment();
$payment->setToken("098f6bcd4621d373cade4e832627b4f6");
```

1. Use your desired function:

```php
$response = $request->create($payment);
$paymentId = $response->getId();
```

It recommend to wrap it into a "try/catch" to handle exceptions like this:

```php
try {
$response = $request->create($payment);
$paymentId = $response->getId();
} catch(\Paymill\Services\PaymillException $e){
//Do something with the error informations below
$e->getResponseCode();
$e->getStatusCode();
$e->getErrorMessage();
}
```

Receiving Response
--------------
------------------

This section shows diffrent ways how to receive a response. The followings examples show how to get the Id for a transaction.

This section shows diffrent ways how to receive a response.
The followings examples show how to get the Id for a transaction.
1. The default response is one of the response-models.

1. The default response is one of the response-models.
```php
$response = $request->create($payment);
$response->getId();
$response = $request->create($payment);
$response->getId();
```

2. getLastResponse() returns the unconverted response from the API.
1. getLastResponse() returns the unconverted response from the API.

```php
$request->create($payment);
$response = $request->getLastResponse();
$response['body']['data']['id'];
$request->create($payment);
$response = $request->getLastResponse();
$response['body']['data']['id'];
```

3. getJSONObject returns the response as stdClass-Object.
1. getJSONObject returns the response as stdClass-Object.

```php
$request->create($payment);
$response = $request->getJSONObject();
$response->data->id;
$request->create($payment);
$response = $request->getJSONObject();
$response->data->id;
```

Using Root certificate
----------------------

If the error below occurres on your system please follow the steps below to configure curl.

```php
Paymill\Services\PaymillException: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
```

Windows / OS X / Linux

1. Download http://curl.haxx.se/ca/cacert.pem and save it on your server.
2. Open php.ini with an editor and add the line `curl.cainfo=PathToYourCACertFile`
3. Restart your Webserver

Update Root certificate on Linux(ubuntu)

1. Run `sudo update-ca-certificates`
2. Restart your Webserver

Changelog
---------

#### 3.2.1

- bugfix: [#92](https://github.com/paymill/paymill-php/pull/92) remove typecheck for http response code

Documentation
--------------
-------------

For further information, please refer to our official PHP library reference: https://www.paymill.com/en-gb/documentation-3/reference/api-reference/index.html
6 changes: 6 additions & 0 deletions lib/api/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

function autoload($className)
{
$prefix = 'Paymill\\';
$len = strlen($prefix);
if (strncmp($prefix, $className, $len) !== 0) {
return;
}

$className = ltrim($className, "\\");
$fileName = '';
$namespace = '';
Expand Down
3 changes: 3 additions & 0 deletions lib/api/composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{

"name": "paymill/paymill",
"type": "library",
"description": "Paymill PHPLib",
Expand All @@ -16,4 +17,6 @@
"Paymill": "lib/"
}
}

}

Binary file added lib/api/composer.phar
Binary file not shown.
10 changes: 6 additions & 4 deletions lib/api/lib/Paymill/API/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Curl extends CommunicationAbstract
* Extra cURL options. The array is keyed by the name of the cURL
* options.
*/
public function __construct($apiKey, $apiEndpoint = 'https://api.paymill.com/v2/', array $extracURL = array())
public function __construct($apiKey, $apiEndpoint = 'https://api.paymill.com/v2.1/', array $extracURL = array())
{
$this->_apiKey = $apiKey;
$this->_apiUrl = $apiEndpoint;
Expand All @@ -67,8 +67,7 @@ public function requestApi($action = '', $params = array(), $method = 'POST')
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_USERAGENT => 'Paymill-php/0.0.2',
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_CAINFO => realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'paymill.crt',
CURLOPT_SSL_VERIFYPEER => true
);

// Add extra options to cURL if defined.
Expand All @@ -88,7 +87,6 @@ public function requestApi($action = '', $params = array(), $method = 'POST')
if ($this->_apiKey) {
$curlOpts[CURLOPT_USERPWD] = $this->_apiKey . ':';
}

$curl = curl_init();
curl_setopt_array($curl, $curlOpts);
$responseBody = $this->_curlExec($curl);
Expand All @@ -101,6 +99,10 @@ public function requestApi($action = '', $params = array(), $method = 'POST')

if ('application/json' === $responseInfo['content_type']) {
$responseBody = json_decode($responseBody, true);
} elseif('text/csv' === $responseInfo['content_type']
&& !isset($responseBody['error'])
) {
return $responseBody;
}

return array(
Expand Down
3 changes: 3 additions & 0 deletions lib/api/lib/Paymill/Models/Request/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function setId($id)
*/
public function getFilter()
{
if (is_null($this->_filter)) {
return array();
}
return $this->_filter;
}

Expand Down
Loading

0 comments on commit 4de798f

Please sign in to comment.