diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 2a22627d8491..1f9555523b97 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -86,6 +86,9 @@ class InvoiceController extends Controller return render('invoices.show-fullscreen', $data); } + if(!$invoice->isPayable()) + return $this->render('invoices.show',$data); + return auth()->guard('contact')->user()->client->getSetting('payment_flow') == 'default' ? $this->render('invoices.show', $data) : $this->render('invoices.show_smooth', $data); // return $this->render('invoices.show_smooth', $data); diff --git a/app/PaymentDrivers/Stripe/Alipay.php b/app/PaymentDrivers/Stripe/Alipay.php index df03760f6efc..7ab38a7d1db4 100644 --- a/app/PaymentDrivers/Stripe/Alipay.php +++ b/app/PaymentDrivers/Stripe/Alipay.php @@ -12,15 +12,17 @@ namespace App\PaymentDrivers\Stripe; -use App\Exceptions\PaymentFailed; -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Jobs\Util\SystemLogger; -use App\Models\GatewayType; use App\Models\Payment; -use App\Models\PaymentType; use App\Models\SystemLog; -use App\PaymentDrivers\Common\LivewireMethodInterface; +use App\Models\GatewayType; +use App\Models\PaymentType; +use App\Jobs\Util\SystemLogger; +use App\Exceptions\PaymentFailed; use App\PaymentDrivers\StripePaymentDriver; +use Stripe\Exception\InvalidRequestException; +use App\PaymentDrivers\Common\LivewireMethodInterface; +use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use Throwable; class Alipay implements LivewireMethodInterface { @@ -34,8 +36,9 @@ class Alipay implements LivewireMethodInterface public function paymentView(array $data) { + $data = $this->paymentData($data); - + return render('gateways.stripe.alipay.pay', $data); } @@ -64,8 +67,6 @@ class Alipay implements LivewireMethodInterface $this->stripe->stripe_connect_auth ); - nlog($pi); - if (in_array($pi->status, ['succeeded', 'pending'])) { return $this->processSuccesfulRedirect($pi); } @@ -143,18 +144,24 @@ class Alipay implements LivewireMethodInterface */ public function paymentData(array $data): array { - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - 'currency' => $this->stripe->client->currency()->code, - 'payment_method_types' => ['alipay'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->getDescription(false), - 'metadata' => [ - 'payment_hash' => $this->stripe->payment_hash->hash, - 'gateway_type_id' => GatewayType::ALIPAY, - ], - ], $this->stripe->stripe_connect_auth); + try { + $intent = \Stripe\PaymentIntent::create([ + 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), + 'currency' => $this->stripe->client->currency()->code, + 'payment_method_types' => ['alipay'], + 'customer' => $this->stripe->findOrCreateCustomer(), + 'description' => $this->stripe->getDescription(false), + 'metadata' => [ + 'payment_hash' => $this->stripe->payment_hash->hash, + 'gateway_type_id' => GatewayType::ALIPAY, + ], + ], $this->stripe->stripe_connect_auth); + } + catch(\Throwable $e){ + throw new PaymentFailed($e->getMessage(), $e->getCode()); + + } $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl();