Working on payment flows

This commit is contained in:
David Bomba 2024-09-05 13:57:03 +10:00
parent c74fac68f4
commit 076f168707
2 changed files with 30 additions and 20 deletions

View File

@ -86,6 +86,9 @@ class InvoiceController extends Controller
return render('invoices.show-fullscreen', $data); 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 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); // return $this->render('invoices.show_smooth', $data);

View File

@ -12,15 +12,17 @@
namespace App\PaymentDrivers\Stripe; 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\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog; 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 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 class Alipay implements LivewireMethodInterface
{ {
@ -34,8 +36,9 @@ class Alipay implements LivewireMethodInterface
public function paymentView(array $data) public function paymentView(array $data)
{ {
$data = $this->paymentData($data); $data = $this->paymentData($data);
return render('gateways.stripe.alipay.pay', $data); return render('gateways.stripe.alipay.pay', $data);
} }
@ -64,8 +67,6 @@ class Alipay implements LivewireMethodInterface
$this->stripe->stripe_connect_auth $this->stripe->stripe_connect_auth
); );
nlog($pi);
if (in_array($pi->status, ['succeeded', 'pending'])) { if (in_array($pi->status, ['succeeded', 'pending'])) {
return $this->processSuccesfulRedirect($pi); return $this->processSuccesfulRedirect($pi);
} }
@ -143,18 +144,24 @@ class Alipay implements LivewireMethodInterface
*/ */
public function paymentData(array $data): array public function paymentData(array $data): array
{ {
$intent = \Stripe\PaymentIntent::create([ try {
'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), $intent = \Stripe\PaymentIntent::create([
'currency' => $this->stripe->client->currency()->code, 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
'payment_method_types' => ['alipay'], 'currency' => $this->stripe->client->currency()->code,
'customer' => $this->stripe->findOrCreateCustomer(), 'payment_method_types' => ['alipay'],
'description' => $this->stripe->getDescription(false), 'customer' => $this->stripe->findOrCreateCustomer(),
'metadata' => [ 'description' => $this->stripe->getDescription(false),
'payment_hash' => $this->stripe->payment_hash->hash, 'metadata' => [
'gateway_type_id' => GatewayType::ALIPAY, 'payment_hash' => $this->stripe->payment_hash->hash,
], 'gateway_type_id' => GatewayType::ALIPAY,
], $this->stripe->stripe_connect_auth); ],
], $this->stripe->stripe_connect_auth);
}
catch(\Throwable $e){
throw new PaymentFailed($e->getMessage(), $e->getCode());
}
$data['gateway'] = $this->stripe; $data['gateway'] = $this->stripe;
$data['return_url'] = $this->buildReturnUrl(); $data['return_url'] = $this->buildReturnUrl();