1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Stripe: Payments with tokens & error handling

This commit is contained in:
Benjamin Beganović 2020-11-01 16:52:37 +01:00
parent 7d50430a9e
commit 99c30846ad
2 changed files with 20 additions and 8 deletions

View File

@ -13,6 +13,7 @@
namespace App\PaymentDrivers\Stripe;
use App\Events\Payment\PaymentWasCreated;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Jobs\Util\SystemLogger;
@ -159,14 +160,27 @@ class CreditCard
{
PaymentFailureMailer::dispatch($this->stripe->client, $server_response->cancellation_reason, $this->stripe->client->company, $server_response->amount);
PaymentFailureMailer::dispatch(
$this->stripe->client,
$server_response,
$this->stripe->client->company,
$server_response->amount
);
$message = [
'server_response' => $server_response,
'data' => [],
'data' => $this->stripe->payment_hash->data,
];
SystemLogger::dispatch($message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->stripe->client);
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_STRIPE,
$this->stripe->client
);
throw new \Exception('Failed to process the payment.', 1);
throw new PaymentFailed('Failed to process the payment.', 500);
}
private function storePaymentMethod(\Stripe\PaymentMethod $method, $payment_method_id, $customer)

View File

@ -2,8 +2,8 @@
@section('gateway_head')
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
<meta name="stripe-token" content="{{ $token->token }}">
<meta name="stripe-secret" content="{{ $intent->client_secret }}">
<meta name="stripe-token" content="{{ optional($token)->token }}">
<meta name="only-authorization" content="">
@endsection
@ -12,7 +12,7 @@
@csrf
<input type="hidden" name="gateway_response">
<input type="hidden" name="store_card">
<input type="hidden" name="payment_hash" value="{{$payment_hash}}">
<input type="hidden" name="payment_hash" value="{{ $payment_hash }}">
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
@ -26,9 +26,7 @@
@include('portal.ninja2020.gateways.includes.payment_details')
@if((int)$total['amount_with_fee'] == 0)
@include('portal.ninja2020.gateways.stripe.includes.pay_with_credit')
@elseif($token)
@if($token)
@include('portal.ninja2020.gateways.stripe.includes.pay_with_token')
@include('portal.ninja2020.gateways.includes.pay_now', ['id' => 'pay-now-with-token'])
@else