PluginProbe
imoje / 4.2.0
imoje v4.2.0
4.16.1 4.16.0 trunk 3.1.1 3.2.0 3.2.1 3.2.3 3.2.4 3.2.6 3.2.7 3.2.8 3.3.0 3.3.1 3.3.2 3.3.3 4.0.0 4.1.0 4.1.1 4.10.1 4.11.0 4.12.0 4.14.0 4.15.0 4.15.1 4.15.2 All 39 releases
imoje / includes / libs / payment-core / README.md

README.md in imoje 4.2.0, at includes/libs/payment-core/README.md

117 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # Payment Core Library
2
3 It is a simple PHP library that allow implement payment gateway methods out of the box.
4
5 ## Requirements
6 * [](http://php.net/PHP](http://php.net/](http://php.net/) needs to be a minimum version of 5.4.0
7 * [](http://php.net/manual/en/book.curl.phpcURL](http://php.net/manual/en/book.curl.php](http://php.net/manual/en/book.curl.php) needs to be enabled
8
9 ### Installation
10 1. `git clone`
11 2. `composer install`
12
13 ## How to use:
14 Library provides few already created methods like generate form order or just generate form fields.
15
16 If you want to generate full form:
17 1. First you need to initialize Payment instance and provide environment, service key and service id. The last parameter `language` is optional, if if won't be provided the default value will be used (which is 'en')
18 2. Then simply run `$payment->buildOrderForm($orderData)` to build full form or `$payment->buildFormFields($orderData)` to build form fields.
19
20 ## Examples:
21
22 ##### Build full form:
23
24 Order data must have fields:
25 `amount, currency, orderId, customerFirstName, customerLastName`
26
27 Optional data:
28 `customerEmail, urlSuccess, urlFailure, urlReturn, urlNotification, cartData, version`
29
30 Example `$orderData`:
31
32 ```php
33 $orderData = [
34 'amount' => (int) (1.33 * 100), //INT, price should be multipled by 100 so for example 1.33 will be 133
35 'currency' => 'PLN', // see suported currences in 'Supported variables' sectiom
36 'orderId' => '123456790',
37 'customerFirstName' => 'John',
38 'customerLastName' => 'Doe',
39 'customerEmail' => '[email protected]',
40 'urlSuccess' => 'https://example.com/success.php',
41 'urlFailure' => 'https://example.com/failure.php',
42 'urlReturn' => 'https://example.com/return.php',
43 ];
44 ```
45
46 ```php
47 use Imoje\Payment\Paywall;
48
49 public function yourFunction()
50 {
51 // ...
52
53 $payment = new Paywall(\Imoje\Payment\Util::ENVIRONMENT_PRODUCTION, 'b1c8bd6c7411455aab3295c48fcf26a7', 'e692d208484b4d5887755362d0587a00', 'pl');
54
55 $form = $payment->buildOrderForm($orderData); // You can also pass second parameter `language` to generate form that will redirect to this language
56 }
57 ```
58
59 The `$form` must contain $orderData and additional keys (signature must have which one hash method was use (for example sha256)), like:
60
61 `serviceId, merchantId, signature`
62
63 ```php
64 <input type="hidden" value="133" name="serviceId">
65 <input type="hidden" value="133" name="merchantId">
66 <input type="hidden" value="133" name="amount">
67 <input type="hidden" value="PLN" name="currency">
68 <input type="hidden" value="123456790" name="orderId">
69 <input type="hidden" value="John" name="customerFirstName">
70 <input type="hidden" value="Doe" name="customerLastName">
71 <input type="hidden" value="[email protected]" name="customerEmail">
72 <input type="hidden" value="https://example.com/success.php" name="urlSuccess">
73 <input type="hidden" value="https://example.com/failure.php" name="urlFailure">
74 <input type="hidden" value="https://example.com/return.php" name="urlReturn">
75 <input type="hidden" value="7c46b5c9836520a9a0552d31136a705d3f7a7ea3db13de87f41fb3ee31f6dbff;sha256" name="signature">
76 ```
77
78 and then you can wrap it to your own `form` HTML tag
79
80 ```php
81 <form method="POST" action="http://example.com/pl/payment">
82 <input type="hidden" value="133" name="serviceId">
83 <input type="hidden" value="133" name="merchantId">
84 <input type="hidden" value="133" name="amount">
85 <input type="hidden" value="PLN" name="currency">
86 <input type="hidden" value="123456790" name="orderId">
87 <input type="hidden" value="John" name="customerFirstName">
88 <input type="hidden" value="Doe" name="customerLastName">
89 <input type="hidden" value="[email protected]" name="customerEmail">
90 <input type="hidden" value="https://example.com/success.php" name="urlSuccess">
91 <input type="hidden" value="https://example.com/failure.php" name="urlFailure">
92 <input type="hidden" value="https://example.com/return.php" name="urlReturn">
93 <input type="hidden" value="7c46b5c9836520a9a0552d31136a705d3f7a7ea3db13de87f41fb3ee31f6dbff;sha256" name="signature">
94
95 <input class="button" type="submit" value="Continue" id="submit-payment-form">
96 </form>
97 ```
98
99 ## Additional features:
100 Library provides few additional methods that you can use.
101
102 First you need to add `use Imoje\Payment\Util;` then you can:
103
104 * `Util::getSupportedCurrencies()` - it will return an array with available currencies.
105 * `Util::getSupportedLanguages()` - it will return an array with available languages.
106 * `Util::canUseForCurrency($currencyCode)` - `$currencyCode` should be in format ISO4217. The method will return bool.
107
108 ## Supported variables:
109
110 The supported currencies are:
111 `PLN`
112
113 The supported languages are:
114 `Polish, English`
115
116 The format you should use for it is ISO 639-1 (Alpha-2 code)
117