生产站点弹出沙盒.paypal付款窗口,而不只是paypal.com付款窗口。

huangapple go评论98阅读模式
英文:

Production site is popping up sandbox.paypal payment window instead of just paypal.com payment window

问题

我在网站上使用了PayPal的“智能按钮”付款网关。在本地测试的沙盒版本似乎运行得很正常,但一旦推送到生产环境,付款弹出窗口仍然显示sandbox.paypal.com等内容。

我确保我的生产环境中的.env文件具有以下设置:

  1. APP_ENV = production
  2. PAYPAL_MODE = live

(以及显然所有沙盒和生产的秘密和客户端ID。我是否漏掉了此处所需的任何ID?)

我的config文件夹中有一个paypal.php文件(我在使用Laravel):

  1. /**
  2. * PayPal Setting & API Credentials
  3. */
  4. if (env('APP_ENV') == 'local' || env('APP_ENV') == 'staging') {
  5. return array(
  6. 'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID'),
  7. 'secret' => env('PAYPAL_SANDBOX_SECRET'),
  8. 'settings' => array(
  9. 'mode' => env('PAYPAL_MODE', 'sandbox'),
  10. 'http.ConnectionTimeOut' => 3000,
  11. 'log.LogEnabled' => true,
  12. 'log.FileName' => storage_path() . '/logs/paypal.log',
  13. 'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
  14. ),
  15. );
  16. }
  17. if (env('APP_ENV') == 'production') {
  18. return array(
  19. 'client_id' => env('PAYPAL_PROD_CLIENT_ID'),
  20. 'secret' => env('PAYPAL_PROD_SECRET'),
  21. 'settings' => array(
  22. //payment mode, 'sandbox' or 'live'
  23. 'mode' => env('PAYPAL_MODE', 'live'),
  24. 'http.ConnectionTimeOut' => 3000,
  25. 'log.LogEnabled' => true,
  26. 'log.FileName' => storage_path() . '/logs/paypal.log',
  27. 'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
  28. ),
  29. );
  30. }

然后在处理付款的控制器中,我添加了以下构造函数。我认为这可能是我做错事情的地方,因为我不确定我是否漏掉了什么:

  1. public function __construct()
  2. {
  3. /** PayPal API上下文 **/
  4. $paypal_conf = \Config::get('paypal');
  5. $this->_api_context = new ApiContext(new OAuthTokenCredential(
  6. $paypal_conf['client_id'],
  7. $paypal_conf['secret'])
  8. );
  9. $this->_api_context->setConfig($paypal_conf['settings']);
  10. }

我不确定这个问题还可能在哪里引起,但如果您有任何想法,请告诉我,我可以添加代码!我正在使用Laravel和Vue.js堆栈。

有人有任何想法吗?

英文:

I have a paypal "smart button" payment gateway on a site. The sandbox version on local testing seemed to be working perfectly fine, but once I pushed to production, the payment popup window still says sandbox.paypal.com/etc

I've made sure that my .env file on prod has the following settings:

  1. APP_ENV = production
  2. and
  3. PAYPAL_MODE = live

(as well as obviously all the sandbox and prod secrets and client IDs. am I missing any ids that are needed here?)

I have this paypal.php in my config folder (i'm using Laravel):

  1. <?php
  2. /**
  3. * PayPal Setting & API Credentials
  4. */
  5. if ( env('APP_ENV') == 'local' || env('APP_ENV') == 'staging') {
  6. return array(
  7. 'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID'),
  8. 'secret' => env('PAYPAL_SANDBOX_SECRET'),
  9. 'settings' => array(
  10. 'mode' => env('PAYPAL_MODE', 'sandbox'),
  11. 'http.ConnectionTimeOut' => 3000,
  12. 'log.LogEnabled' => true,
  13. 'log.FileName' => storage_path() . '/logs/paypal.log',
  14. 'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
  15. ),
  16. );
  17. }
  18. if ( env('APP_ENV') == 'production' ) {
  19. return array(
  20. 'client_id' => env('PAYPAL_PROD_CLIENT_ID'),
  21. 'secret' => env('PAYPAL_PROD_SECRET'),
  22. 'settings' => array(
  23. //payment mode, 'sandbox' or 'live'
  24. 'mode' => env('PAYPAL_MODE', 'live'),
  25. 'http.ConnectionTimeOut' => 3000,
  26. 'log.LogEnabled' => true,
  27. 'log.FileName' => storage_path() . '/logs/paypal.log',
  28. 'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
  29. ),
  30. );
  31. }

then in my controller that processes payments, I added this construct. I think that this might be where I'm doing something wrong because I'm not sure if I'm missing something here:

  1. public function __construct()
  2. {
  3. /** PayPal api context **/
  4. $paypal_conf = \Config::get('paypal');
  5. $this->_api_context = new ApiContext(new OAuthTokenCredential(
  6. $paypal_conf['client_id'],
  7. $paypal_conf['secret'])
  8. );
  9. $this->_api_context->setConfig($paypal_conf['settings']);
  10. }

I'm not sure where else this issue could be being caused but let me know and I can add the code! I'm using a laravel and vuejs stack

Any ideas anyone?

答案1

得分: 0

我解决了这个问题!!原来我在网站的布局中导入了该死的沙盒API的SDK,而不是正常的非沙盒SDK。

叹气。

英文:

I solved this!! It turned out that I was importing the friggin sandbox API's SDK in the layout of the site instead of the normal non-sandbox SDK

SIGH

huangapple
  • 本文由 发表于 2020年1月6日 23:17:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/59614586.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定