PluginProbe
PayPlug for WooCommerce (Official) / 1.2.10
PayPlug for WooCommerce (Official) v1.2.10
3.1.0 3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 All 102 releases
payplug / vendor / payplug / payplug-php / README.rst

README.rst in PayPlug for WooCommerce (Official) 1.2.10, at vendor/payplug/payplug-php/README.rst

132 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 PHP library for the PayPlug API
2 ===============================
3
4 .. image:: https://travis-ci.org/payplug/payplug-php.svg?branch=master
5 :target: https://travis-ci.org/payplug/payplug-php
6 :alt: CI Status
7
8 .. image:: https://img.shields.io/packagist/v/payplug/payplug-php.svg
9 :target: https://packagist.org/packages/payplug/payplug-php
10 :alt: Packagist
11
12 This is the documentation of PayPlug's PHP library. It is designed to
13 help developers to use PayPlug as payment solution in a simple, yet robust way.
14
15 You can create a PayPlug account at https://www.payplug.com/.
16
17 Prerequisites
18 -------------
19
20 PayPlug's library relies on **cURL** to perform HTTP requests and requires **OpenSSL (1.0.1 or newer)** to secure transactions. You also need **PHP 5.3** or newer for the PayPlug PHP V2.
21
22 For version **PHP 5.2** or older you must refer to PayPlug PHP V1.
23
24 Documentation
25 -------------
26 Please see https://docs.payplug.com/api for latest documentation.
27
28 Installation
29 ------------
30 **Option 1 - Strongly preferred)** via composer:
31
32 - Get composer from `composer website`_.
33 - Make sure you have initialized your *composer.json*.
34 - Run *composer require payplug/payplug-php* from your project directory.
35
36 .. _composer website: https://getcomposer.org/download/
37
38 **Option 2)** clone the repository :
39 ::
40
41 git clone https://github.com/payplug/payplug-php.git
42
43 **Option 3)** download as a tarball :
44
45 - Download the most recent tarball from the `download page V2`_ (V2 for **PHP 5.3** or newer)
46 - Download the most recent tarball from the `download page V1`_ (V1 for **PHP 5.2** or older)
47 - Unpack the tarball
48 - Put the files somewhere in your project
49
50 .. _download page V1: https://github.com/payplug/payplug-php/releases/tag/V1.1.2
51 .. _download page V2: https://github.com/payplug/payplug-php/releases
52
53 __ https://bitbucket.org/payplug/payplug_php/downloads#tag-downloads
54
55 To get started, add the following to your PHP script (if you are not running a framework):
56
57 .. sourcecode :: php
58
59 <?php
60 require_once("PATH_TO_PAYPLUG/payplug_php/lib/init.php");
61
62 Usage
63 -----
64
65 Here's how simple it is to create a payment request:
66
67 .. sourcecode :: php
68
69 <?php
70 require_once("PATH_TO_PAYPLUG/payplug_php/lib/init.php"); // If not using a framework
71
72 // Loads your account's parameters that you've previously downloaded and saved
73 Payplug\Payplug::init(array(
74 'secretKey' => 'sk_live_YOUR_PRIVATE_KEY',
75 'apiVersion' => 'THE_API_VERSION_YOU_WANT',
76 ));
77
78 // Create a payment request of €9.99. The payment confirmation (IPN) will be sent to "'https://example.net/notifications?id='.$customer_id".
79 // note that all amounts must be expressed in centimes as positive whole numbers (€9.99 = 999 centimes).
80 // Metadata allow you to include additional information when processing payments or refunds.
81 $customer_id = '42710';
82
83 $payment = Payplug\Payment::create(array(
84 'amount' => 999,
85 'currency' => 'EUR',
86 'billing' => array(
87 'title' => 'mr',
88 'first_name' => 'John',
89 'last_name' => 'Watson',
90 'email' => '[email protected]',
91 'address1' => '221B Baker Street',
92 'postcode' => 'NW16XE',
93 'city' => 'London',
94 'country' => 'GB',
95 'language' => 'en'
96 ),
97 'shipping' => array(
98 'title' => 'mr',
99 'first_name' => 'John',
100 'last_name' => 'Watson',
101 'email' => '[email protected]',
102 'address1' => '221B Baker Street',
103 'postcode' => 'NW16XE',
104 'city' => 'London',
105 'country' => 'GB',
106 'language' => 'en',
107 'delivery_type' => 'BILLING'
108 ),
109 'hosted_payment' => array(
110 'return_url' => 'https://example.net/return?id='.$customer_id,
111 'cancel_url' => 'https://example.net/cancel?id='.$customer_id
112 ),
113 'notification_url' => 'https://example.net/notifications?id='.$customer_id,
114 'metadata' => array(
115 'customer_id' => $customer_id
116 )
117 ));
118 ?>
119
120 // You will be able to find how the payment object is built in the documentation.
121 // For instance, if you want to get an URL to the payment page, you get do:
122 $paymentUrl = $payment->hosted_payment->payment_url;
123
124 // Then, you can redirect the user to the payment page
125 header("Location: $paymentUrl");
126
127 Go further:
128 -----------
129 Tests:
130 ++++++
131 See tests/README.rst.
132