简体   繁体   中英

Pay 3rd Party With PayPal API

I'm developing an application which pays out payments to a 3rd party. The source code for what I'm using is found here:

http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreateThirdPartyPayment.html

I've added the following as well for my ClientID and Client Secret:

$apiContext = new \PayPal\Rest\ApiContext(
    new \PayPal\Auth\OAuthTokenCredential(
        'xxxxxxxxxxxxxxxxxxxxxxxxx',     // ClientID
        'xxxxxxxxxxxxxxxxxxxxxxxxx'      // ClientSecret
    )
);

When using my sandbox credentials, the code succeeds as it should. When swapping to the live credentials, however, I get an invalid client, authentication failed error. I've ensure the live ClientID and Client Secret are exactly what I have on my developer portal.

I've been looking all over the developer portal looking for a possible setting I'm missing, or something not configured correctly but have come to a loss. Any advice?

Update: I also don't see any issues/errors on the developer portal when logged into developer.paypal.com

Update 2: I found this just now:

public function setConfig(array $config)
{
   PayPalConfigManager::getInstance()->addConfigs($config);
}

Do I need to set the config by $apiContext->setConfig('LIVE') (or something to this effect?)

With the assistance from @JashParakh I was able to solve the issue. I added the following:

$config['mode'] = 'Live';
$apiContext->setConfig($config);

The payment went through in live and is should have.

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