For simple PayPal integration we just have to send the user to the PayPal site with the required information to process the order. Here is the code to use that it in a simple manner.
First of all you have to create a form and pass the value into the form accordingly.
You can use the below code:
$paypal_url = ‘https://www.sandbox.paypal.com/cgi-bin/webscr’; //Test PayPal API URL
$paypal_id = ‘[email protected]’; //Business Email ?>
Here is the form:
<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”business” value=”<?php echo $paypal_id; ?>”>
<input placeholder=”ProductName” type=”text” name=”item_name” value=”Memorex 256MB Memory Stick”><br>
<input placeholder=”ProductId” type=”text” name=”item_number” value=”MEM32507725″><br>
<input placeholder=”Amount” type=”text” name=”amount” value=”3″><br>
<input type=”hidden” name=”tax” value=”1″>
<input placeholder=”Quantity” type=”text” name=”quantity” value=”1″><br>
<input type=”hidden” name=”no_note” value=”1″>
<input type=”hidden” name=”currency_code” value=”USD”><input type=”hidden” name=”cancel_return” value=”http://localhost/report/paypal/cancel.php”>
<input type=”hidden” name=”return” value=”http://localhost/report/paypal/sucess.php”><!– Enable override of buyers’s address stored with PayPal . –>
<input type=”hidden” name=”address_override” value=”1″>
<!– Set variables that override the address stored with PayPal. –>
<input placeholder=”FirstName” type=”text” name=”first_name” value=”John”><br>
<input placeholder=”LastName” type=”text” name=”last_name” value=”Doe”><br>
<input placeholder=”Address” type=”text” name=”address1″ value=”345 Lark Ave”><br>
<input placeholder=”City” type=”text” name=”city” value=”San Jose”><br>
<input placeholder=”State” type=”text” name=”state” value=”CA”><br>
<input placeholder=”Zip” type=”text” name=”zip” value=”95121″><br>
<select name=”country”>
<option value=””>Select Country</option><option value=”AL”>ALBANIA</option> <option value=”DZ”>ALGERIA </option><option value=”ZM”>ZAMBIA</option></select><br>
<input type=”image” name=”submit” border=”0″ src=”https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif” alt=”PayPal – The safer, easier way to pay online”>
</form>
Leave a comment