{"id":148,"date":"2014-12-03T05:00:57","date_gmt":"2014-12-03T05:00:57","guid":{"rendered":"https:\/\/www.kolkataonweb.com\/code-bank\/?p=148"},"modified":"2014-11-25T19:02:08","modified_gmt":"2014-11-25T19:02:08","slug":"paypal-form-submit-through-php","status":"publish","type":"post","link":"https:\/\/www.kolkataonweb.com\/code-bank\/php\/paypal-form-submit-through-php\/","title":{"rendered":"PayPal form submit through PHP"},"content":{"rendered":"<p>PayPal Payments Standard is a quick and easy way to integrate Paypal with any website. Normally the method uses a form to send the various details of the transaction to Paypal server.<\/p>\n<p>The below code can simulate the form submission through PHP. With this no form is required. The details of transaction pulled from DB, calculations (if any) done through PHP code and the user can be redirected to Paypal for making the payment.  <\/p>\n<pre class='wp-code-highlight prettyprint'> \r\n$paypal_url = 'https:\/\/www.paypal.com\/cgi-bin\/webscr';\r\n$paypal_id = 'XXXXXXXXXX'; \/\/ Paypal Merchant Id\r\n$cancel_url = \"http:\/\/www.domain.com\/cancel-return.php\";\r\n$return_url = \"http:\/\/www.domain.com\/success-return.php\"; \r\n$inv = \"INV\/BVRM\/\".rand(1111,9999);\r\n        \r\n\/\/ Prepare GET data\r\n$query = array();\r\n$query['notify_url'] = \"http:\/\/www.domain.com\/ipn.php\";\r\n$query['cmd'] = '_xclick';\r\n$query['business'] = $paypal_id;\r\n\/\/$query['address_override'] = '1';\r\n$query['first_name'] = \"John Doe\";\r\n$query['country'] = \"IN\";\r\n$query['email'] = $_SESSION['email'];\r\n$query['amount'] = $product_details['price'];\r\n$query['item_name'] = $product_details['name'];\r\n$query['currency_code'] = \"INR\";\r\n\r\n$query['custom'] = $_SESSION['user_id'] . \",\" . $package_price . \",\" . $package_validity . \",\" . $package_name;\r\n\r\n$query['return'] = $return_url;\r\n$query['cancel_return'] = $cancel_url;\r\n$query['rm'] = \"2\";\r\n$query['invoice'] = $inv;\r\n    \r\n\/\/ Prepare query string\r\n$query_string = http_build_query($query);\r\n\r\nheader('location: ' . $paypal_url. \"?\". $query_string);\r\ndie();\r\n<\/pre>\n<p>The array keys are the names of the various fields of the form that is used normally in PayPal Payments Standard method. A detail of all available parameters\/fields can be found <a href=\"https:\/\/developer.paypal.com\/docs\/classic\/paypal-payments-standard\/integration-guide\/Appx_websitestandard_htmlvariables\/http:\/\/\" title=\"HTML Variables for PayPal Payments Standard\" target=\"_blank\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PayPal Payments Standard is a quick and easy way to integrate Paypal with any website. Normally the method uses a form to send the various details of the transaction to Paypal server. The below code can simulate the form submission through PHP. With this no form is required. The details of transaction pulled from DB,&hellip; <a class=\"more-link\" href=\"https:\/\/www.kolkataonweb.com\/code-bank\/php\/paypal-form-submit-through-php\/\">Continue reading <span class=\"screen-reader-text\">PayPal form submit through PHP<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-php","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":4,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/148\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}