Need help with the Zend form on the Paypal website


I created a Zend form (the user can specify the payment details and amount of money they wanted to deposit into my back end system) when they submitted the details it go through to the validation function to ensure all the data is validated. But after validation I wanted to submit the necessary payment data to paypal IPN website and forward the user to paypal website as well (so they can enter their paypal email and password for transaction).

But I have no clue how can I achieve this? Do I need to create a new Zend Form object and post the data to paypal website or there is a easy way to submit the data to paypal and forward the user to the paypal website? If possible can u show me how I can code this?

Thanks so much in advance.

Assuming you use Express Checkout, the easiest way to do this is to simply redirect user to another page saying "redirecting to paypal..." after your validation.

At that page you'll have a hidden form (you can construct it with Zend_Form or manuallly, it does not really matter), you can then add some javascript to submit that form and also leave "submit" button visible so that user could click it if tired waiting until javascript does it for him.

Or this can simply be a "thank you" page, e.g.:

Thank you for your order! Your order number is 27335

[Click here] to complete the payment.

After they payment is done, paypal will return to your IPN URL which you specified. You can then check it like this:

$paypal_url = '';
$client = new Zend_Http_Client($paypal_url);
$client->setParameterPost(array('cmd' => '_notify-validate')+$_POST);
$response = $client->request();

if ($response->getBody() !== 'VERIFIED') {
    //Not verified

This peace of code simply ensures that what you got from IPN really comes from paypal. After that, you will also need to check the params it has passed to you in $_POST (like order number, amount, currency etc). You will also need item_number to "link" it with the order# you should have added before redirecting to PayPal.

You can also check other ways doing checkout, which PayPal suggests here

Alternatively, you can also try PayPal NVP solution.