aurelien75000 aurelien75000 - 1 year ago 118
PHP Question

Paypal/Laravel can't make a Live payment

I've followed this tutorial to implement payment using Paypal services on my website:

But when i want to flip from SandBox mode to Live mode (which is the real payment) all my transactions goes to the SandBox history (you can check it in your Paypal account).

Here is the code of the function "store()" that do the payment:

public function store(Request $request)

// ### CreditCard
$card = Paypalpayment::creditCard();

$fi = Paypalpayment::fundingInstrument();

$payer = Paypalpayment::payer();

//Payment Amount
$amount = Paypalpayment::amount();

$transaction = Paypalpayment::transaction();
->setDescription("Payment description")

// ### Payment
// A Payment Resource; create one using
// the above types and intent as 'sale'

$payment = Paypalpayment::payment();


try {
} catch (\PPConnectionException $ex) {
return "Exception: " . $ex->getMessage() . PHP_EOL;



Answer Source

Look what $this->_apiContext contains. There is a mode that needs to be set to live to make it work.

If not found, you can create apiContext object as shown here:

$apiContext = new \PayPal\Rest\ApiContext(
    new \PayPal\Auth\OAuthTokenCredential(
        'Live ClientId',     // ClientID
        'Live Client Secret'      // ClientSecret

    'mode' => 'live',
    'log.LogEnabled' => true,
    'log.FileName' => 'PayPal.log',
    'log.LogLevel' => 'FINE'

and use $apiContext instead when you call $payment->create();

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download