|
16 | 16 | use Nails\Common\Exception\ModelException; |
17 | 17 | use Nails\Factory; |
18 | 18 | use Nails\Invoice\Constants; |
19 | | -use Nails\Invoice\Exception\ChargeRequestException; |
20 | 19 | use Nails\Invoice\Exception\RequestException; |
21 | 20 | use Nails\Invoice\Exception\ScaRequestException; |
| 21 | +use Throwable; |
22 | 22 |
|
23 | 23 | /** |
24 | 24 | * Class ScaRequest |
@@ -52,11 +52,28 @@ public function execute(): ScaResponse |
52 | 52 | ); |
53 | 53 |
|
54 | 54 | } else { |
55 | | - $oScaResponse = $this->oDriver->sca( |
56 | | - $oScaResponse, |
57 | | - $this->oPayment->sca_data, |
58 | | - $oChargeRequest::compileScaUrl($this->oPayment, $this->oPayment->sca_data) |
59 | | - ); |
| 55 | + try { |
| 56 | + $oScaResponse = $this->oDriver->sca( |
| 57 | + $oScaResponse, |
| 58 | + $this->oPayment->sca_data, |
| 59 | + $oChargeRequest::compileScaUrl($this->oPayment, $this->oPayment->sca_data) |
| 60 | + ); |
| 61 | + } catch (Throwable $e) { |
| 62 | + /** |
| 63 | + * Something unexpected happened within the driver, we do not want this error reaching |
| 64 | + * the user. Ensure that we gracefully handle the exception so the user sees something |
| 65 | + * which isn't a 500. Log the real exception for debugging purposes. |
| 66 | + */ |
| 67 | + $oScaResponse->setStatusFailed( |
| 68 | + $oScaResponse->getErrorMessage(), |
| 69 | + $oScaResponse->getErrorCode(), |
| 70 | + 'Failed to authorise the payment.' |
| 71 | + ); |
| 72 | + $this->setPaymentFailed( |
| 73 | + $oScaResponse->getErrorMessage(), |
| 74 | + $oScaResponse->getErrorCode() |
| 75 | + ); |
| 76 | + } |
60 | 77 | } |
61 | 78 |
|
62 | 79 | $oScaResponse->lock(); |
|
0 commit comments