Submit form via cURL and redirect browser to PayPal Submit form via cURL and redirect browser to PayPal curl curl

Submit form via cURL and redirect browser to PayPal


WARNING: this answer has a security deficit. Passing sensitive data (such as item and price) through the client allows the client to modify the transaction. ie. change the item, or change the price. See the PayPal documentation on how to implement IPN.

You should redirect the user with the php header function and send the vars as GET not POST.

// Process PayPal paymentif ($method == 'PayPal') {    // Prepare GET data    $query = array();    $query['notify_url'] = 'http://jackeyes.com/ipn';    $query['cmd'] = '_cart';    $query['upload'] = '1';    $query['business'] = 'social@jackeyes.com';    $query['address_override'] = '1';    $query['first_name'] = $first_name;    $query['last_name'] = $last_name;    $query['email'] = $email;    $query['address1'] = $ship_to_address;    $query['city'] = $ship_to_city;    $query['state'] = $ship_to_state;    $query['zip'] = $ship_to_zip;    $query['item_name_'.$i] = $item['description'];    $query['quantity_'.$i] = $item['quantity'];    $query['amount_'.$i] = $item['info']['price'];    // Prepare query string    $query_string = http_build_query($query);    header('Location: https://www.paypal.com/cgi-bin/webscr?' . $query_string);}


Rather than trying to post all the data to PayPal and back, you should keep the data on your server and send only an identifying token. Any data you send to PayPal (via the user's browser) can be intercepted and modified. This is a serious security hazard.

If you send only the token there is no opportunity for tampering.

Read the PayPal spec, it has guidelines on how to implement these things.

You must use IPN or some similar post processing because PayPal is the only one who knows whether a payment was actually made. Do not trust any data you get from the user.


doing curl it will make end to end calls in backend side , it will not reflect on frontend behavior .

you have to make a form with hidden field and javascript to auto submit the form once page loaded .