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);
}
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);

View File

@ -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();