简体   繁体   中英

Paypal: going Live from sandbox

I have been brainstorming for a while now on this and finally i decided to put a question here.

I am using PayPal-PHP-SDK (restAPI) for processing payments. And i cannot make it go to the live endpoint ( api.paypal.com ) and always goes to sandbox ( api.sandbox.paypal.com )

Progress : Using the sandbox credentials ( clientId and clientSecret ) in 'bootstarp.php' and 'mode' set to 'sandbox' in 'sdk_config.ini' i have successfully completed multiple sandbox transactions and completed all other parts of the project. Now the only part is making it live, which is in fact turning out to be the Achilles heel of the project.

What i have tried : I have replaced the sandbox credentials with the live ones from the client. Which he got from https://developer.paypal.com/webapps/developer/applications/myapps then under the app clicking 'show' Live Credentials . I also changed the mode to live in 'sdk_config.ini'. But still it takes me to the sandbox endpoint.

EDIT : while creating the api context in bootstarp.php there is a mode i have also set that to live, code below.

$apiContext->setConfig(
    array(
        'mode' => 'live',
        'http.ConnectionTimeOut' => 30,
        'log.LogEnabled' => true,
        'log.FileName' => '../PayPal.log',
        'log.LogLevel' => 'FINE',
        'validation.level' => 'log'
    )
);

Can anyone suggest me what i am missing here as i get no error to debug and look further. For any help or advice, thanks in advance.

Have you changed the mode in bootstrap.php? It seems you can use either the configuration in bootstrap.php or in the sdk_config.ini file but not both. Make sure mode is set to live in the bootstrap.php file if you have the sdk_config.ini path commented out as below (from the bootstrap.php file)

// Register the sdk_config.ini file in current directory
// as the configuration source.
/*
if(!defined("PP_CONFIG_PATH")) {
    define("PP_CONFIG_PATH", __DIR__);
}
*/

This is probably more appropriate as a comment on Mike Miller's solution but I don't have enough rep, sorry.

I moved from the Paypal API sandbox to live literally five minutes ago, using your question and Mike's answer for information on how to do so.

The only things I changed were the values of clientId and clientSecret in bootstrap.php, and the mode (from 'sandbox' to 'live'), just like you set out in the question. I didn't edit the 'sdk_config.ini' file at all, and the path is commented out anyway, as per Mike's answer.

I note you're referring to the 'bootstrap.php' file as 'bootstarp.php' - this doesn't have anything to do with it, does it?

I had the same problem that I couldn't fix.

I'm not proud of my solution because it's not elegant at all, but it worked to start selling.

I modified the file PayPalConstants.php (located in ...\\PayPal-PHP-SDK\\paypal\\rest-api-sdk-php\\lib\\PayPal\\Core\\PayPalConstants.php )

I just changed sandbox routes for live routes:

const REST_SANDBOX_ENDPOINT = "https://api.paypal.com/";

const OPENID_REDIRECT_SANDBOX_URL = "https://www.paypal.com/webapps/auth/protocol/openidconnect";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM