I'm trying to integrate Paypal as the payment gateway in my Laravel 5.8
website. In order to do so I'm using the Laravel-Omnipay package which offers Omnipay
integration into Laravel.
As for my Paypal
business account, I've set up my credentials. Using the paypal sandbox with the following code works:
Route::get('paypal', function() {
$gateway = Omnipay::create('PayPal_Rest');
$gateway->initialize(array(
'clientId' => 'MySandboxClientId',
'secret' => 'MySandboxSecret',
'testMode' => true,
));
$card = new CreditCard(array(
'firstName' => 'first name',
'lastName' => 'last name',
'number' => '5498876202508868',
'cvv' => '123',
'expiryMonth' => '09',
'expiryYear' => '2024',
'billingAddress1' => '1 Scrubby Creek Road',
'billingCountry' => 'AU',
'billingCity' => 'Scrubby Creek',
'billingPostcode' => '4999',
'billingState' => 'QLD',
));
try {
$transaction = $gateway->purchase(array(
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'card' => $card,
));
$response = $transaction->send();
$data = $response->getData();
dd($data);
echo "Gateway purchase response data == " . print_r($data, true) . "\n";
if ($response->isSuccessful()) {
echo "Purchase transaction was successful!\n";
}
} catch (\Exception $e) {
echo "Exception caught while attempting authorize.\n";
echo "Exception type == " . get_class($e) . "\n";
echo "Message == " . $e->getMessage() . "\n";
}
});
However, when I try to pass to a live payment using my own credit card. I can an Unauthorized payment.
error. The code I'm using is the same as above, I'm just replacing the clientId and secret with my live sandbox credentials.
How can I make a live call to the REST Api. I need to make a $1 transaction so I can test whether the card is valid or not.