简体   繁体   中英

Paypal PHP SDK going from sandbox to live

Hey guys I followed this tutorial

http://www.sanwebe.com/2014/09/paypal-rest-api-payment-system

I have the paypal sandbox mode working perfect. It's time to launch the site & I want to switch it to live. I've been messing with it for hours and cannot figure out how to direct this to the live mode.

Any help at all will be greatly appreciated.

If you are using PayPal-PHP-SDK,

Step 1: You need to set the mode to live to point the SDK to live endpoints. To do that, there are multiple ways:

  • sdk_config.ini
    • you need to set this there
    • 在此输入图像描述
  • dynamically using ApiContext
    • you could do that by setting it similar to this
    • 在此输入图像描述

Step 2: , Please update the clientId and secret for Live environment, as they are different based on sandbox or live. Visit PayPal Developer and check on live select box as shown below:

在此输入图像描述

These two steps should get you going with the live API endpoint.

Can't comment to H Patel, but there's another sdk_config.ini file in the PayPal PHP SDK files which includes an endpoint and mode.

I've noticed I had to change the service.EndPoint in this other config file to https://api.paypal.com , change the mode in both config files to live , set the log.LogLevel to INFO , AND dynamically set the mode to live in my PHP script. I ALSO changed the acct1.ClientId and acct1.ClientSecret in both of these config ini files and it seems like maybe I've got it working now.

So it's not a matter of choosing how you want to do it, you have to do all of it and then some beyond what PayPal tells you to do.

You can set manualy to go live without creating config.ini file

Just set in the value you want

\PayPal\Core\PayPalConfigManager::getInstance()->addConfigs(['mode' => 'live' /*or "sandbox" */]) ;

then set your live Credential id/secret with the live information

$credential = new \PayPal\Auth\OAuthTokenCredential($paypal_id, $paypal_secret);

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