Quellcode durchsuchen

debug模式开启

zhangdehua vor 1 Jahr
Ursprung
Commit
504a3ad65c

+ 6 - 1
app/api/service/Payment.php

@@ -50,7 +50,12 @@ class Payment extends BaseService
         }
 
         if ($payType == OrderPayTypeEnum::PAYPAL) {
-            $conf = config('paypal');
+            $confs = config('paypal');
+            if (is_debug()){
+                $conf = $confs['sandbox'];
+            }else{
+                $conf = $confs['live'];
+            }
             $pp = new PayPal($conf);
             return $pp->unify($order['order_no'], $order['pay_price']);
         }

+ 9 - 0
app/index/controller/Captcha.php

@@ -67,6 +67,10 @@ class Captcha extends Controller
             return $this->renderError('Invalid email address.');
         }
 
+        if (is_debug()) {
+            return $this->renderSuccess('Sent Successful!Please check your new mails.');
+        }
+
         $smtp = new UMailer(config('smtp.host'), config('smtp.port'), true,
             config('smtp.username'), config('smtp.password'));
         $smtp->debug = true;                     //是否显示发送的调试信息
@@ -89,6 +93,11 @@ class Captcha extends Controller
     {
         $code = $this->request->param('smsCode');
         $mobile = $this->request->param('mobile');
+
+        if (is_debug()) {
+            return $this->renderSuccess('Sent Successful!Please check your new mails.');
+        }
+
         $mailCaptcha = new MailCaptcha();
         $flag = $mailCaptcha->checkCaptcha($code, $mobile);
 

+ 6 - 1
app/index/controller/Checkout.php

@@ -218,7 +218,12 @@ class Checkout extends Controller
         }
 
         $paymentId = $this->request->param('paymentId');
-        $conf = config('paypal');
+        $confs = config('paypal');
+        if (is_debug()){
+            $conf = $confs['sandbox'];
+        }else{
+            $conf = $confs['live'];
+        }
         $pp = new PayPal($conf);
         $flag = $pp->executePayment($paymentId);
         if ($flag) {

+ 2 - 0
app/index/controller/Index.php

@@ -191,6 +191,8 @@ class Index extends Controller
 
     public function goldTest($name)
     {
+        $conf = config('paypal');
+        dd($conf['sandbox'],$conf['live']);
         dd('this is '.$name);
         $service = new OrderGetYundanService();
         $r = $service->orderCreateYundans($this->storeId);

+ 6 - 1
app/index/model/Order.php

@@ -154,7 +154,12 @@ class Order extends OrderModel
             'secret' => 'EDqRQhgLNHCb5bxld98T8-JJJZKvMIeqxudO7lMwDFOxBfy138PjM5A21FnDNyb3q4yYUh8r7Qr2BnVi',      // ClientSecret
             'web_hook_id' => '3NP026061E6858914',
         ];*/
-        $conf = config('paypal');
+        $confs = config('paypal');
+        if (is_debug()){
+            $conf = $confs['sandbox'];
+        }else{
+            $conf = $confs['live'];
+        }
         $pp = new PayPal($conf);
 
         return $pp->unify($order['order_no'], $order['pay_price']);

+ 6 - 1
app/index/service/Payment.php

@@ -53,7 +53,12 @@ class Payment extends BaseService
         }
         //paypal支付
         if ($payType == OrderPayTypeEnum::PAYPAL) {
-            $conf = config('paypal');
+            $confs = config('paypal');
+            if (is_debug()){
+                $conf = $confs['sandbox'];
+            }else{
+                $conf = $confs['live'];
+            }
             $pp = new PayPal($conf);
             return $pp->unify($order['order_no'], $order['pay_price']);
         }

+ 20 - 10
config/paypal.php

@@ -1,18 +1,28 @@
 <?php
-return [
+/*return [
     'mode' => 'live',//live,sandbox
     'web_hook_id' => '',
     'client_id' => 'AR8_6ebyyP4MbYKgiayiWNdo84GO9XwlOe9eaMtBBjKGX-lwLxPEr82Gzy1hBgM1jMNL6IkQ6mG9QUMe',
     'secret' => 'EOks43U2U8EN8TRqzo4OWQ4LoMOawO3UVQ6UDLzwsPu9dI17CEc0E4YRBiWB1HS6pjXmb4z9cerdIglE',
     'return_url' => '/index/checkout/payPayExecutePay/orderNo/%s/token/%s',//'https://lar.lmm.gold/api/index/index',//vp.com/index.php/api/checkout/payPayExecutePay/orderNo/9999
     'cancel_url' => '/index/index/index.html',//'https://lar.lmm.gold/store/index.html',
-];
+];*/
 
-/*return [
-    'mode' => 'sandbox',//live,sandbox
-    'web_hook_id' => '3NP026061E6858914',
-    'client_id' => 'AS0FH780ZGtSAdpT1NTjwkFzryCPf69rZb_FR9Rt_rZdasB80cmjqTQ6CQELWiFVh_MU9e31CSnyz7Ai',
-    'secret' => 'EDqRQhgLNHCb5bxld98T8-JJJZKvMIeqxudO7lMwDFOxBfy138PjM5A21FnDNyb3q4yYUh8r7Qr2BnVi',
-    'return_url' => '/index/checkout/payPayExecutePay/orderNo/%s/token/%s',//'https://lar.lmm.gold/api/index/index',//vp.com/index.php/api/checkout/payPayExecutePay/orderNo/9999
-    'cancel_url' => '/index/index/index.html',//'https://lar.lmm.gold/store/index.html',
-];*/
+return [
+    'sandbox' => [
+        'mode' => 'sandbox',//live,sandbox
+        'web_hook_id' => '3NP026061E6858914',
+        'client_id' => 'AS0FH780ZGtSAdpT1NTjwkFzryCPf69rZb_FR9Rt_rZdasB80cmjqTQ6CQELWiFVh_MU9e31CSnyz7Ai',
+        'secret' => 'EDqRQhgLNHCb5bxld98T8-JJJZKvMIeqxudO7lMwDFOxBfy138PjM5A21FnDNyb3q4yYUh8r7Qr2BnVi',
+        'return_url' => '/index/checkout/payPayExecutePay/orderNo/%s/token/%s',//'https://lar.lmm.gold/api/index/index',//vp.com/index.php/api/checkout/payPayExecutePay/orderNo/9999
+        'cancel_url' => '/index/index/index.html',//'https://lar.lmm.gold/store/index.html',
+    ],
+    'live' => [
+        'mode' => 'live',//live,sandbox
+        'web_hook_id' => '',
+        'client_id' => 'AR8_6ebyyP4MbYKgiayiWNdo84GO9XwlOe9eaMtBBjKGX-lwLxPEr82Gzy1hBgM1jMNL6IkQ6mG9QUMe',
+        'secret' => 'EOks43U2U8EN8TRqzo4OWQ4LoMOawO3UVQ6UDLzwsPu9dI17CEc0E4YRBiWB1HS6pjXmb4z9cerdIglE',
+        'return_url' => '/index/checkout/payPayExecutePay/orderNo/%s/token/%s',//'https://lar.lmm.gold/api/index/index',//vp.com/index.php/api/checkout/payPayExecutePay/orderNo/9999
+        'cancel_url' => '/index/index/index.html',//'https://lar.lmm.gold/store/index.html',    ]
+    ]
+];