@@ -59,151 +59,156 @@ class Transaction extends Model implements TransactionInterface
5959```
6060``` php
6161<?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- }
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 after verify method from payment gateway or not
111+ * This feature does not append to all payment gateways.
112+ * for example in Mellat gateway this method can assume as SETTLE method
113+ *
114+ * @return bool
115+ */
116+ public function checkForAfterVerify(): bool;
117+
118+ /**
119+ * check if transaction is ready for requesting refund method from payment gateway or not
120+ * This feature does not append to all payment gateways
121+ *
122+ * @return bool
123+ */
124+ public function checkForRefund(): 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+ * @param string $cardNumber
131+ * @param bool $save
132+ *
133+ * @return bool
134+ */
135+ public function setCardNumber(string $cardNumber, bool $save = true): bool;
136+
137+ /**
138+ * Mark transaction as a verified transaction
139+ *
140+ * @param bool $save
141+ *
142+ * @return bool
143+ */
144+ public function setVerified(bool $save = true): bool;
145+
146+ /**
147+ * Mark transaction as a after verified transaction
148+ * For example SETTLED in Mellat gateway
149+ *
150+ * @param bool $save
151+ *
152+ * @return bool
153+ */
154+ public function setAfterVerified(bool $save = true): bool;
155+
156+ /**
157+ * Mark transaction as a paid/successful transaction
158+ *
159+ * @param bool $save
160+ *
161+ * @return bool
162+ */
163+ public function setAccomplished(bool $save = true): bool;
164+
165+ /**
166+ * Mark transaction as a refunded transaction
167+ *
168+ * @param bool $save
169+ *
170+ * @return bool
171+ */
172+ public function setRefunded(bool $save = true): bool;
173+
174+ /**
175+ * Returns the payable amount af the transaction
176+ *
177+ * @return int
178+ */
179+ public function getPayableAmount(): int;
180+
181+ /**
182+ * Set callback parameters from payment gateway
183+ *
184+ * @param array $parameters
185+ * @param bool $save
186+ *
187+ * @return bool
188+ */
189+ public function setCallBackParameters(array $parameters, bool $save = true): bool;
190+
191+ /**
192+ * Set extra values of the transaction. Every key/value pair that you want to bind to the transaction
193+ *
194+ * @param string $key
195+ * @param $value
196+ * @param bool $save
197+ *
198+ * @return bool
199+ */
200+ public function setExtra(string $key, $value, bool $save = true): bool;
201+ }
200202
201203
202204```
203205
2042066 . Prepare for online payment
205207
206208``` php
209+ <?php
210+
211+ // your Laravel action
207212 public function payOnline (Request $request, Transaction $transaction)
208213 {
209214 // check if the selected payment is active or not from your gateways table
@@ -215,18 +220,10 @@ class Transaction extends Model implements TransactionInterface
215220 return view('gateway.notfound');
216221 }
217222
218- // get some additional parameters for updating transaction
219- $parameters = [
220- 'description' => $request->input('by_online_description', ''),
221- 'bank' => $request->input('by_online_gateway'),
222- ];
223-
224- // update transaction payment method
225- $transaction = $this->transactionsRepository->setTransactionPaid(
226- $transaction, TransactionPayment::ONLINE, $parameters
227- );
228-
229- // make larapay payment gateway instance
223+ /**
224+ * make larapay payment gateway instance
225+ * example: $paymentGatewayHandler = Larapay::make('saman', $transaction);
226+ **/
230227 $paymentGatewayHandler = Larapay::make($paymentGateway->slug, $transaction);
231228
232229
@@ -247,15 +244,15 @@ class Transaction extends Model implements TransactionInterface
247244 } catch (\Exception $e) {
248245 // could not generate goto gate form
249246 Log::emergency($paymentGateway->slug . ' #' . $e->getCode() . '-' . $e->getMessage());
250- Session::flash('alert-danger', trans('trans.could_not_create_goto_bank_form', ['gateway' => $paymentGateway->name ]));
247+ Session::flash('alert-danger', trans('trans.could_not_create_goto_bank_form', ['gateway' => $paymentGateway->slug ]));
251248
252249 return redirect()->back()->withInput();
253250 }
254251 if (is_null($form)) {
255252 return redirect()->back()->withInput();
256253 }
257254
258- // view goto gate view
255+ // view goto gate form/ view
259256 return view('gateway.gotogate', [
260257 'gateway' => $paymentGateway,
261258 'form' => $form,
0 commit comments