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

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

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

问题

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

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

APP_ENV = production

和

PAYPAL_MODE = live

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

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

/**
 * PayPal Setting & API Credentials
 */

if (env('APP_ENV') == 'local' || env('APP_ENV') == 'staging') {
    return array(
        'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID'),
        'secret' => env('PAYPAL_SANDBOX_SECRET'),
        'settings' => array(
            'mode' => env('PAYPAL_MODE', 'sandbox'),
            'http.ConnectionTimeOut' => 3000,
            'log.LogEnabled' => true,
            'log.FileName' => storage_path() . '/logs/paypal.log',
            'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
        ),
    );
}

if (env('APP_ENV') == 'production') {
    return array(
        'client_id' => env('PAYPAL_PROD_CLIENT_ID'),
        'secret' => env('PAYPAL_PROD_SECRET'),
        'settings' => array(
            //payment mode, 'sandbox' or 'live'
            'mode' => env('PAYPAL_MODE', 'live'),
            'http.ConnectionTimeOut' => 3000,
            'log.LogEnabled' => true,
            'log.FileName' => storage_path() . '/logs/paypal.log',
            'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
        ),
    );
}

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

public function __construct()
{
    /** PayPal API上下文 **/
    $paypal_conf = \Config::get('paypal');
    $this->_api_context = new ApiContext(new OAuthTokenCredential(
            $paypal_conf['client_id'],
            $paypal_conf['secret'])
    );
    $this->_api_context->setConfig($paypal_conf['settings']);
}

我不确定这个问题还可能在哪里引起,但如果您有任何想法,请告诉我,我可以添加代码!我正在使用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:

APP_ENV = production

and

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):

<?php
/**
 * PayPal Setting & API Credentials
 */


if ( env('APP_ENV') == 'local' || env('APP_ENV') == 'staging') {
    return array(
        'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID'),
        'secret' => env('PAYPAL_SANDBOX_SECRET'),
        'settings' => array(
            'mode' => env('PAYPAL_MODE', 'sandbox'),
            'http.ConnectionTimeOut' => 3000,
            'log.LogEnabled' => true,
            'log.FileName' => storage_path() . '/logs/paypal.log',
            'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
        ),
    );
}

if ( env('APP_ENV') == 'production' ) {
    return array(
        'client_id' => env('PAYPAL_PROD_CLIENT_ID'),
        'secret' => env('PAYPAL_PROD_SECRET'),
        'settings' => array(
            //payment mode, 'sandbox' or 'live'
            'mode' => env('PAYPAL_MODE', 'live'),
            'http.ConnectionTimeOut' => 3000,
            'log.LogEnabled' => true,
            'log.FileName' => storage_path() . '/logs/paypal.log',
            'log.LogLevel' => env('PAYPAL_LOG_LEVEL', 'DEBUG'),
        ),
    );
}

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:

    public function __construct()
    {
        /** PayPal api context **/
        $paypal_conf = \Config::get('paypal');
        $this->_api_context = new ApiContext(new OAuthTokenCredential(
                $paypal_conf['client_id'],
                $paypal_conf['secret'])
        );
        $this->_api_context->setConfig($paypal_conf['settings']);
    }

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:

确定