Paypal Website Payment Standards in Visualforce

Sometimes we need to implement a functionality where we have to accept credit card payment but we just want to have a quick and simple process. Paypal website payment standards is the choice. What we need for this
1.) Business Account
2.) Force.com site where we can host this visualforce page
3.) Code to Accept IPNBelow is the code which will display a Buy Now button on visualforce page and you can change the amount based on your calculations
<form action=”https://www.sandbox.paypal.com/cgi-bin/webscr” method=”post”>
<input type=”hidden” name=”cmd” value=”_xclick”/>
<input type=”hidden” name=”business” value=”YOUR BUSINESS EMAIL HERE”/>
<input type=”hidden” name=”item_name” value=”ITEM NAME”/>
<input type=”hidden” name=”item_number” value=”ITEM NO”/>
<input type=”hidden” name=”amount” value=”1″/>
<input type=”hidden” name=”notify_url” value=”IPN URL”/>
<input type=”hidden” name=”custom” value=”YOU CAN PASS A CUSTOM VARIABLE HERE WHICH WILL BE PASSED TO IPN”/>
<input type=”hidden” name=”return” value=”URL WHERE USER WILL BE REDIRECTED AFTER PAYMENT”/>
<input type=”hidden” name=”cancel_return” value=”URL WHERE USER WILL BE REDIRECTED AFTER CLICKING ON CANCEL”/>
<input type=”hidden” name=”no_shipping” value=”0″/>
<input type=”hidden” name=”no_note” value=”1″/>
<input type=”hidden” name=”currency_code” value=”USD”/>
<input type=”hidden” name=”lc” value=”AU”/>
<input type=”hidden” name=”bn” value=”PP-BuyNowBF”/>
<input type=”hidden” name=”email” value=”jdoe@zyzzyu.com” />
<input type=”image” name=”submit” border=”0″ src=”https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif” alt=”PayPal – The safer, easier way to pay online”/>
</form>
The ipn url will be hit everytime a payment is made and this can be used to update the data in salesforce instance with the transaction details.
You just need to have a page where you will call below handler to process the transactions.


Source : http://www.saasanalogy.com/paypal-website-payment-standards-in-visualforce/

Comments

Popular posts from this blog

Salesforce.com: Expression Operators in Salesforce lightning Components

Custom Calendar on VisualForce Page

Salesforce.com: Scheduled Apex