Nick
Nick

Reputation: 69

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

Upvotes: 1

Views: 127

Answers (1)

Nick
Nick

Reputation: 69

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.

Upvotes: 2

Related Questions