You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can **[spread the word!](http://twitter.com/share?text=I%20am%20using%20this%20cool%20PHP%20package&url=https://github.com%2FLaragear%2FReCaptcha&hashtags=PHP,Laravel,Transbank,WebPay)**
36
+
Your support allows me to keep this package free, up-to-date, and maintainable. Alternatively, you can **[spread the word!](http://twitter.com/share?text=I%20am%20using%20this%20cool%20PHP%20package&url=https://github.com%2FLaragear%2FReCaptcha&hashtags=PHP,Laravel,Transbank,WebPay)**
37
37
38
38
## Requisites
39
39
40
-
* Laravel 11, or later
40
+
* PHP 8.3 or later
41
+
* Laravel 12 or later
41
42
42
43
# Installation
43
44
@@ -231,7 +232,7 @@ You will be able to hear all transactions started and completed. This package se
231
232
232
233
## Livewire Component
233
234
234
-
This packages includes the [`Laragear/Transbank/Livewire/CheckoutWebpay`](src/Livewire/CheckoutWebpay.php) Liveware trait that automatically handles receiving a Webpay Transaction from Transbank [thanks to lifecycle hooks](https://livewire.laravel.com/docs/4.x/lifecycle-hooks#using-hooks-inside-a-trait).
235
+
This packages includes the [`Laragear/Transbank/Livewire/InteractsWithWebpay`](src/Livewire/InteractsWithWebpay.php) Liveware trait that automatically handles receiving a Webpay Transaction from Transbank [thanks to lifecycle hooks](https://livewire.laravel.com/docs/4.x/lifecycle-hooks#using-hooks-inside-a-trait).
235
236
236
237
The only requirement is to implement the `handleSuccessfulTransaction()` method, which receives the successful transaction. For example, you may use this to mark a hypothetical "Cart" model as paid.
237
238
@@ -262,7 +263,7 @@ class Payment extends Component
262
263
263
264
Apart from the `$isSuccessful` property to check the transaction success, this trait also offers other methods you can override for your convenience:
264
265
265
-
-`handleWebpayException()`: Receives any exception thrown by Webpay (like connection errors).
266
+
-`handleWebpayException()`: Controls exceptions thrown by Webpay (like connection errors).
266
267
-`afterTransactionReceived()`: Handles the freshly retrieved transaction.
267
268
-`handleTransactionStatus()`: Handles how the transaction should be considered successful or failed.
268
269
-`handleFailedTransaction()`: Handles the Transaction when it has failed.
@@ -271,6 +272,28 @@ Apart from the `$isSuccessful` property to check the transaction success, this t
271
272
272
273
You can use these methods to show different messages to the user. For example, you can use `handleNonWebpayResponse()` to redirect the user back to the cart checkout route, or `handleFailedTransaction()` to store the failure for analytics.
273
274
275
+
The `handleWebpayException()` receives any exception, like connection errors or form aborts, and lets you handle it as you wish. For example, you may suppress the exception and render your component as not-successful. Otherwise, any Exception returned will be thrown as usual, so it's great to _replace_ exceptions with your own.
276
+
277
+
```php
278
+
use Laragear\Transbank\Exceptions\ClientException;
279
+
use Throwable;
280
+
281
+
public $title = '';
282
+
public $message = '';
283
+
284
+
protected function handleWebpayException(Throwable $exception)
285
+
{
286
+
if ($exception instanceof ClientException) {
287
+
$this->isSuccessful = false;
288
+
} else {
289
+
report($exception);
290
+
291
+
$this->title = 'Transbank is unresponsive';
292
+
$this->message = 'We will look into it as soon as possible.';
293
+
}
294
+
}
295
+
```
296
+
274
297
The `afterTransactionReceived()` method is great to override when you require to do logic _after_ the transaction has been received, but _before_ any other logic. For example, to retrieve a Checkout process.
275
298
276
299
```php
@@ -322,7 +345,8 @@ You should use this [adding custom actions](https://filamentphp.com/docs/5.x/res
322
345
```php
323
346
use App\Models\Checkout;
324
347
use Filament\Schemas\Schema;
325
-
use Illuminate\Support\Number;use Laragear\Transbank\Filament\WebpayAction;
348
+
use Illuminate\Support\Number;
349
+
use Laragear\Transbank\Filament\WebpayAction;
326
350
327
351
public ?Checkout $checkout = null;
328
352
@@ -358,7 +382,7 @@ All exceptions implement `TransbankException`, so you can easily catch and check
358
382
359
383
There are 4 types of exceptions:
360
384
361
-
*`ClientException`: Any error byproduct of bad transactions, misconfiguration, aborts, abandonment, timeout or invalid values.
385
+
*`ClientException`: Any error byproduct of bad transactions, misconfiguration, aborts, abandonment, timeout, or invalid values.
362
386
*`ServerException`: Any internal Transbank servers errors.
363
387
*`NetworkException`: Any communication error from Transbank Server, like network timeouts or wrong endpoints.
364
388
*`UnknownException`: Any other error.
@@ -454,12 +478,12 @@ return [
454
478
455
479
Disabled by default, you can further protect your endpoints using the [`transbank.protect` middleware](#middleware-endpoint-protection). Once enabled, it will save the token of every transaction created by 5 minutes, and once Transbank returns the user with the token, abort the request if it was not generated or was expired.
456
480
457
-
This also handles which cache store to use, and which prefix to use when storing the tokens into the cache.
481
+
This also handles which cache store to use and which prefix to use when storing the tokens into the cache.
458
482
459
483
# Licence
460
484
461
-
This specific package version is licensed under the terms of the [MIT License](LICENSE.md), at time of publishing.
485
+
This specific package version is licensed under the terms of the [MIT License](LICENSE.md), at the time of publishing.
`Redcompra`, `Webpay`, `Oneclick`, `Onepay`, `Patpass` and `Transbank` are trademarks of [Transbank S.A.](https://www.transbank.cl/). This package and its author are not associated with Transbank S.A.
0 commit comments