如何在Laravel 8中的单个控制器中使用多个支付网关功能?

发布于 2025-01-22 18:35:14 字数 882 浏览 1 评论 0原文

我在项目中使用贝宝,剃须刀薪水,条纹付款网关。当选择用户之一付款网关时,它将重定向到分配的控制器功能,将其重定向到其特定的控制器。我想在单个控制器中编写所有用于支付网关的功能,以切断客户的重定向。

当用户选择付款网关并将其重定向的表单提交到下面的控制器函数时

 if ($payment_mode->payment_gateway_name == "Paypal") {
                return redirect()->route('paywithpaypal', $planId);
            } else if ($payment_mode->payment_gateway_name == "Razorpay") {
                return redirect()->route('paywithrazorpay', $planId);
            } else if ($payment_mode->payment_gateway_name == "Stripe") {
                return redirect()->route('paywithstripe', $planId);
            } else if ($payment_mode->payment_gateway_name == "Bank Transfer") {
    }

,并且在该控制器中定义了所有功能。

I am using PayPal, Razor pay, Stripe payment gateways in my project. When select user one of them payment gateway it redirects to assigned controller function from there it redirects its particular controller. I want to write all the functions for payment gateways in single controller to cut off redirections for customer.

enter image description here

when user select payment gateway and submit the form it redirects to mentioned below controller function

 if ($payment_mode->payment_gateway_name == "Paypal") {
                return redirect()->route('paywithpaypal', $planId);
            } else if ($payment_mode->payment_gateway_name == "Razorpay") {
                return redirect()->route('paywithrazorpay', $planId);
            } else if ($payment_mode->payment_gateway_name == "Stripe") {
                return redirect()->route('paywithstripe', $planId);
            } else if ($payment_mode->payment_gateway_name == "Bank Transfer") {
    }

and in that controller all functions is defined.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红墙和绿瓦 2025-01-29 18:35:14

创建类如下所示:

  1. paymayController
  2. Sepleter类实现RazorPayservice,条纹服务,BankTransFerservice APIS
  3. 出厂方法,以创建RazorPayservice的类对象,条纹服务,BankTransFerservice,BankTransFerService,基于请求参数

paymenters Paymenters Paymenter paymenter paymenter paymenter paymenter paymenter paymenter paymenter pays painte offict参数

Create Classes as below:

  1. PaymentController
  2. Seperate classes implementing RazorpayService, StripeService, BankTransferService apis
  3. Factory Method to create class object of RazorpayService, StripeService, BankTransferService based on request parameters

PaymentController uses factory method to create object of appropriate service and calls appropriate method on this object using input parameters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文