Skip to content

Commit 8cd44e6

Browse files
committed
get ready for PHP7.0 syntax
1 parent 3ad5127 commit 8cd44e6

20 files changed

+981
-942
lines changed

README.md

+148-42
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ Online Payment Module handler for Laravel 5+ known as LaraPay component complete
1919

2020
## Installation
2121

22+
Larapay Version 6 required PHP 7+
23+
2224
1.Installing via composer
2325

2426
```bash
25-
composer require tartan/laravel-online-payment:"^5.0"
27+
composer require tartan/laravel-online-payment:"^7.0"
2628
```
2729
2.Add this to your app service providers for laravel version < 5.4 :
2830

@@ -45,54 +47,158 @@ php artisan vendor:publish
4547
* Your Transaction/Invoice (Eloquent) model MUST implement
4648

4749
```php
50+
<?php
4851
namespace App\Model;
4952

5053
use Tartan\Larapay\Transaction\TransactionInterface;
5154

52-
class Transaction extends Model implements TransactionInterface
55+
class Transaction extends Model implements TransactionInterface
5356
{
54-
// set order reference Id
55-
public function setReferenceId($referenceId, $save = true){}
56-
57-
// check if you transaction is ready for requesting payment token
58-
public function checkForRequestToken(){}
59-
60-
// check if transaction is ready for requesting verify transaction
61-
public function checkForVerify(){}
62-
63-
// check if transaction is ready for requesting inqury transaction (if supported by gateway)
64-
public function checkForInquiry(){}
65-
66-
// check if transaction is ready for requesting reverse transaction (if supported by gateway)
67-
public function checkForReverse(){}
68-
69-
// check if transaction is ready for requesting settle/... transaction (if needed by gateway)
70-
public function checkForAfterVerify(){}
71-
72-
// update transaction by paid card number (if provided by gateway)
73-
public function setCardNumber($cardNumber){}
74-
75-
// mark transaction as verified
76-
public function setVerified(){}
77-
78-
// mark transaction as settled/...
79-
public function setAfterVerified(){}
80-
81-
// mark transaction as completed
82-
public function setSuccessful($flag){}
83-
84-
// mark transaction as reversed
85-
public function setReversed(){}
86-
87-
// get transaction amount
88-
public function getAmount(){}
57+
// ...
58+
}
59+
```
60+
```php
61+
<?php
62+
63+
namespace Tartan\Larapay\Transaction;
64+
65+
interface TransactionInterface
66+
{
67+
/**
68+
* set gateway token of transaction
69+
*
70+
* @param string $token
71+
* @param bool $save
72+
*
73+
* @return mixed
74+
*/
75+
public function setGatewayToken(string $token, bool $save = true): bool;
76+
77+
/**
78+
* set reference ID of transaction
79+
*
80+
* @param string $referenceId
81+
* @param bool $save
82+
*
83+
* @return mixed
84+
*/
85+
public function setReferenceId(string $referenceId, bool $save = true): bool;
86+
87+
/**
88+
* check if transaction is ready for requesting token from payment gateway or not
89+
*
90+
* @return boolean
91+
*/
92+
public function checkForRequestToken(): bool;
93+
94+
/**
95+
* check if transaction is ready for requesting verify method from payment gateway or not
96+
*
97+
* @return bool
98+
*/
99+
public function checkForVerify(): bool;
100+
101+
/**
102+
* check if transaction is ready for requesting inquiry method from payment gateway or not
103+
* This feature does not append to all payment gateways
104+
*
105+
* @return bool
106+
*/
107+
public function checkForInquiry(): bool;
108+
109+
/**
110+
* check if transaction is ready for requesting refund method from payment gateway or not
111+
* This feature does not append to all payment gateways
112+
*
113+
* @return bool
114+
*/
115+
public function checkForRefund(): bool;
116+
117+
/**
118+
* check if transaction is ready for requesting after verify method from payment gateway or not
119+
* This feature does not append to all payment gateways.
120+
* for example in Mellat gateway this method can assume as SETTLE method
121+
*
122+
* @return bool
123+
*/
124+
public function checkForAfterVerify(): bool;
125+
126+
/**
127+
* Set the card number (hash of card number) that used for paying the transaction
128+
* This data does not provide by all payment gateways
129+
*
130+
* @return bool
131+
*/
132+
public function setCardNumber(string $cardNumber): bool;
133+
134+
/**
135+
* Mark transaction as a verified transaction
136+
*
137+
* @return bool
138+
*/
139+
public function setVerified(): bool;
140+
141+
/**
142+
* Mark transaction as a after verified transaction
143+
* For example SETTLED in Mellat gateway
144+
*
145+
* @return bool
146+
*/
147+
public function setAfterVerified(): bool;
148+
149+
/**
150+
* Mark transaction as a paid/successful transaction
151+
*
152+
* @return bool
153+
*/
154+
public function setPaid(): bool;
155+
156+
/**
157+
* Mark transaction as a refunded transaction
158+
*
159+
* @return bool
160+
*/
161+
public function setRefunded(): bool;
162+
163+
/**
164+
* Returns the payable amount af the transaction
165+
* @return int
166+
*/
167+
public function getAmount(): int;
168+
169+
/**
170+
* Set the paid time of the transaction.
171+
* You can set this value in setPaid() method too and bypass this function
172+
*
173+
* @param string $time
174+
*
175+
* @return bool
176+
*/
177+
public function setPaidAt(string $time = 'now'): bool;
178+
179+
/**
180+
* Set extra values of the transaction. Every key/value pair that you want to bind to the transaction
181+
*
182+
* @param string $key
183+
* @param $value
184+
* @param bool $save
185+
*
186+
* @return bool
187+
*/
188+
public function setExtra(string $key, $value, bool $save = true): bool;
189+
190+
/**
191+
* Set callback parameters from payment gateway
192+
*
193+
* @param array $paramaetrs
194+
* @param bool $save
195+
*
196+
* @return bool
197+
*/
198+
public function setCallBackParameters(array $parameters, bool $save = true): bool;
199+
}
89200

90-
// set transactions's paid tme
91-
public function setPaidAt($time = 'now'){}
92201

93-
// set transaction's extra details
94-
public function setExtra($key, $value, $save = false){}
95-
}
96202
```
97203

98204
6. Prepare for online payment

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.4.0",
14+
"php": ">=7.0.0",
1515
"ext-soap" : "*",
1616
"illuminate/support": "5.x.x"
1717
},

0 commit comments

Comments
 (0)