Hello I've been trying to integrate paypal with the shopping cart for my site using Omnipay paypal with Laravel 4. I've mainly used THIS tutorial so far.
I'm still in the initial stages but I've hit a snag. When I try to checkout I get an error that says "The amount parameter is required".
I am a bit of a noob so I might be doing something stupid but if I hardcode in the amount (ie: 'price' => 25.00, )then it works as it should. The decription and currency are also both being pulled from the database and sent to the paypal page fine. The questions I've found on here don't seem to have people pulling data dynamically to their controller so maybe I'm doing something wrong?
Here's the relevant part of my controller:
<?php
use Omnipay\Omnipay;
class PaymentController extends Controller {
public function postPayment() {
$params = array(
'cancelUrl' => 'http://localhost/cancel_order',
'returnUrl' => 'http://localhost/payment_success',
'name' => Input::get('name'),
'description' => Input::get('description'),
'price' => Input::get('price'),
'currency' => Input::get('currency') );
Session::put('params', $params);
Session::save();
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('my username');
$gateway->setPassword('my pass');
$gateway->setSignature('my signature');
$gateway->setTestMode(true);
$response = $gateway->purchase($params)->send();
Here's my cart checkout button:
{{ Form::open([ 'url' => 'pay_via_paypal', 'method' => 'post' ]) }}
{{Form::hidden('product',Product::find($productID)->name)}}
{{Form::hidden('description',Product::find($productID)->description)}}
{{Form::hidden('amount',Product::find($productID)->price)}}
{{Form::hidden('currency',Product::find($productID)->currency)}}
{{Form::submit('CHECKOUT')}}
{{Form::close()}}
The form might look a bit confusing but the values are all showing up fine on the form before I submit.
Thanks for any help.