Skip to content

Commit 1b049fe

Browse files
committed
added banktest info to README
1 parent 6687e41 commit 1b049fe

File tree

2 files changed

+222
-3
lines changed

2 files changed

+222
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

README.md

Lines changed: 221 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Laravel Online Payment :: LaraPay component
22

3-
Online Payment Module handler for Laravel 5+ known as LaraPay component.
3+
Online Payment Module handler for Laravel 5+ known as LaraPay component completely compatible with [banktest.ir](banktest.ir) simulator
4+
5+
## What is B‌anktest?
6+
[BankTest](banktest.ir) is a sandbox service for all Iranian online payment gateways
7+
بانک تست : شبیه ساز درگاه های پرداخت آنلاین / تست درگاه پرداخت آنلاین
8+
49

510
## Currenctly support:
611

@@ -45,37 +50,250 @@ use Tartan\Larapay\Transaction;
4550

4651
class Transaction extends Model implements TransactionInterface
4752
{
53+
// set order reference Id
4854
public function setReferenceId($referenceId, $save = true){}
4955

56+
// check if you transaction is ready for requesting payment token
5057
public function checkForRequestToken(){}
5158

59+
// check if transaction is ready for requesting verify transaction
5260
public function checkForVerify(){}
5361

62+
// check if transaction is ready for requesting inqury transaction (if supported by gateway)
5463
public function checkForInquiry(){}
5564

65+
// check if transaction is ready for requesting reverse transaction (if supported by gateway)
5666
public function checkForReverse(){}
5767

68+
// check if transaction is ready for requesting settle/... transaction (if needed by gateway)
5869
public function checkForAfterVerify(){}
5970

71+
// update transaction by paid card number (if provided by gateway)
6072
public function setCardNumber($cardNumber){}
61-
73+
74+
// mark transaction as verified
6275
public function setVerified(){}
63-
76+
77+
// mark transaction as settled/...
6478
public function setAfterVerified(){}
6579

80+
// mark transaction as completed
6681
public function setSuccessful($flag){}
6782

83+
// mark transaction as reversed
6884
public function setReversed(){}
6985

86+
// get transaction amount
7087
public function getAmount(){}
7188

89+
// set transactions's paid tme
7290
public function setPaidAt($time = 'now'){}
7391

92+
// set transaction's extra details
7493
public function setExtra($key, $value, $save = false){}
7594
}
7695
```
7796

97+
6. Prepare for online payment
98+
99+
```php
100+
public function payOnline (Request $request, Transaction $transaction)
101+
{
102+
// check if the selected payment is active or not from your gateways table
103+
$paymentGateway = Gateway::activeGate()
104+
->where('slug', $request->input('by_online_gateway'))
105+
->first();
106+
107+
if (empty($paymentGateway)) {
108+
return view('gateway.notfound');
109+
}
110+
111+
// get some additional parameters for updating transaction
112+
$parameters = [
113+
'description' => $request->input('by_online_description', ''),
114+
'bank' => $request->input('by_online_gateway'),
115+
];
116+
117+
// update transaction payment method
118+
$transaction = $this->transactionsRepository->setTransactionPaid(
119+
$transaction, TransactionPayment::ONLINE, $parameters
120+
);
121+
122+
// make larapay payment gateway instance
123+
$paymentGatewayHandler = Larapay::make($paymentGateway->slug, $transaction);
124+
125+
126+
// set payment params
127+
$paymentParams = [
128+
'order_id' => $transaction->getBankOrderId(),
129+
'redirect_url' => route('payment.callback', [
130+
'bank' => $paymentGateway->slug,
131+
'transactionId' => $transaction->guid
132+
]),
133+
'amount' => $transaction->amount,
134+
'submit_label' => trans('larapay::larapay.goto_gate')
135+
];
136+
137+
try {
138+
// get goto gate form
139+
$form = $paymentGatewayHandler->form($paymentParams);
140+
} catch (\Exception $e) {
141+
// could not generate goto gate form
142+
Log::emergency($paymentGateway->slug . ' #' . $e->getCode() . '-' . $e->getMessage());
143+
Session::flash('alert-danger', trans('t.could_not_create_goto_bank_form', ['gateway' => $paymentGateway->name]));
144+
145+
return redirect()->back()->withInput();
146+
}
147+
if (is_null($form)) {
148+
return redirect()->back()->withInput();
149+
}
150+
151+
// view goto gate view
152+
return view('gateway.gotogate', [
153+
'gateway' => $paymentGateway,
154+
'form' => $form,
155+
]);
156+
}
157+
```
158+
159+
## Component Configuration
78160

161+
```php
162+
return [
163+
164+
/*
165+
|--------------------------------------------------------------------------
166+
| Tartan e-payment component`s operation mode
167+
|--------------------------------------------------------------------------
168+
|
169+
| *** very important config ***
170+
| please do not change it if you don't know what BankTest is
171+
|
172+
| > production: component operates with real payments gateways
173+
| > development: component operates with simulated "BankTest" (banktest.ir) gateways
174+
|
175+
*/
176+
'mode' => env('LARAPAY_MODE', 'production'),
177+
178+
/*
179+
|--------------------------------------------------------------------------
180+
| ready to serve gateways
181+
|--------------------------------------------------------------------------
182+
|
183+
| specifies ready to serve gateways.
184+
| gateway characters are case sensitive and should be exactly same as their folder name.
185+
| eg, "Jahanpay" is correct not "JahanPay" or "jahanpay"
186+
| the gateways list is comma separated
187+
|
188+
*/
189+
'gateways' => env('LARAPAY_GATES', 'Mellat,Saman,Pasargad'),
190+
191+
/*
192+
|--------------------------------------------------------------------------
193+
| Mellat gateway configuration
194+
|--------------------------------------------------------------------------
195+
*/
196+
'mellat' => [
197+
'username' => env('MELLAT_USERNAME', ''),
198+
'password' => env('MELLAT_PASSWORD',''),
199+
'terminal_id' => env('MELLAT_TERMINAL_ID', ''),
200+
'callback_url' => env('MELLAT_CALLBACK_URL', '')
201+
],
202+
203+
/*
204+
|--------------------------------------------------------------------------
205+
| Parsian gateway configuration
206+
|--------------------------------------------------------------------------
207+
*/
208+
'parsian' => [
209+
'pin' => env('PARSIAN_PIN', ''),
210+
],
211+
/*
212+
|--------------------------------------------------------------------------
213+
| Pasargad gateway configuration
214+
|--------------------------------------------------------------------------
215+
*/
216+
'pasargad' => [
217+
'terminalId' => env('PASARGAD_TERMINAL_ID', ''),
218+
'merchantId' => env('PASARGAD_MERCHANT_ID', ''),
219+
'certificate_path' => storage_path(env('PASARGAD_CERT_PATH', 'payment/pasargad/certificate.xml')),
220+
'callback_url' => env('PASARGAD_CALLBACK_URL', '')
221+
],
222+
223+
/*
224+
|--------------------------------------------------------------------------
225+
| Sadad gateway configuration
226+
|--------------------------------------------------------------------------
227+
*/
228+
'sadad' => [
229+
'merchant' => env('SADAD_MERCHANT', ''),
230+
'transaction_key' => env('SADAD_TRANS_KEY', ''),
231+
'terminal_id' => env('SADAD_TERMINAL_ID', ''),
232+
'callback_url' => env('SADAD_CALLBACK_URL', ''),
233+
],
234+
235+
'saderat' => [
236+
'MID' => env('SADERAT_MID', ''),
237+
'TID' => env('SADERAT_TID', ''),
238+
'public_key_path' => storage_path(env('SADERAT_CERT_PATH', 'payment/saderat/public.key')),
239+
'private_key_path' => storage_path(env('SADERAT_CERT_PATH', 'payment/saderat/private.key')),
240+
],
241+
242+
/*
243+
|--------------------------------------------------------------------------
244+
| Saman gateway configuration
245+
|--------------------------------------------------------------------------
246+
*/
247+
'saman' => [
248+
'merchant_id' => env('SAMAN_MERCHANT_ID', ''),
249+
'merchant_pass' => env('SAMAN_MERCHANT_PASS', ''),
250+
],
251+
252+
/*
253+
|--------------------------------------------------------------------------
254+
| Zarinpal gateway configuration
255+
|--------------------------------------------------------------------------
256+
|
257+
| types: acceptable values --- zarin-gate or normal
258+
| server: acceptable values --- germany or iran or test
259+
|
260+
*/
261+
'zarinpal' => [
262+
'merchant_id' => env('ZARINPAL_MERCHANT_ID', ''),
263+
'type' => env('ZARINPAL_TYPE', 'zarin-gate'),
264+
'callback_url' => env('ZARINPAL_CALLBACK_URL', ''),
265+
'server' => env('ZARINPAL_SERVER', 'germany'),
266+
'email' => env('ZARINPAL_EMAIL', ''),
267+
'mobile' => env('ZARINPAL_MOBILE', '09xxxxxxxxx'),
268+
'description' => env('ZARINPAL_MOBILE', 'powered-by-TartanPayment'),
269+
],
270+
271+
/*
272+
|--------------------------------------------------------------------------
273+
| SoapClient Options
274+
|--------------------------------------------------------------------------
275+
|
276+
| useOptions: true/false
277+
| options: soapClient Options
278+
|
279+
*/
280+
'soap' => [
281+
'useOptions' => env('SOAP_HAS_OPTIONS', false),
282+
'options' => [
283+
'proxy_host' => env('SOAP_PROXY_HOST', ''),
284+
'proxy_port' => env('SOAP_PROXY_PORT', ''),
285+
'stream_context' => stream_context_create(
286+
[
287+
'ssl' => [
288+
'verify_peer' => false,
289+
'verify_peer_name' => false,
290+
],
291+
]
292+
),
293+
]
294+
]
295+
];
296+
```
79297

80298
## Team
81299

0 commit comments

Comments
 (0)