0

I found this helpful tutorial about integrating paypal buynow button with wordpress using custom post type.

 <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
 <input type="hidden" name="cmd" value="_cart">
 <input type="hidden" name="business" value="example@example.com">
 <input type="hidden" name="lc" value="GB">
 <input type="hidden" name="item_name" value="<?php $meta_values = get_post_meta($post_id, 'product-name'); ?>">
 <input type="hidden" name="item_number" value="<?php $meta_values = get_post_meta($post_id, 'product-reference'); ?>">
 <input type="hidden" name="amount" value="<?php $meta_values = get_post_meta($post_id, 'product-value'); ?>">
 <input type="hidden" name="currency_code" value="GBP">
 <input type="hidden" name="button_subtype" value="products">
 <input type="hidden" name="no_note" value="0">
 <input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-    ShopCartBF:btn_cart_LG.gif:NonHostedGuest">
<input type="image"   src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0"   name="submit" alt="PayPal — The safer, easier way to pay online.">
 <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>

But I am wondering if there is an option to add a redirect for downloading the product/file after payment is completed? I wanna build a wordpress digital sale shop the simplest way without relying on plugins. However, is this method secured at all or will I be better off using an SSL/secured connection? Any help will be appreciated.

  • Thank you for your support guys! Do anyone knows if there is an easy way to buy multiple products using this method? So if a client is on the store with multiple item, can they have an option to comeback to the store again and select another product after they are been taken to paypal after the first product selection? I don't wanna have to build a full cart for the option. – cmsdeployed Jan 19 '14 at 9:03
2

It's far better to use a plugin such as Easy Digital Downloads as there are many steps you will need to code in e.g.

1) Check if user has paid (by checking if they were referred back successfully by Paypal) and then set the option in the admin area to say yes you have paid 2) Check what you have bought and direct you to download the item 3) Set a limit on number of downloads of product 4) Stop anyone accessing the download page without a download token

Far easier to use one of the many plugins that have been built as there is a lot of work involved in building a custom one which it's just not worth doing unless you are trying to build something unique.

  • I understand that, but I am looking for something very simple without going through extra setting that easy download brings. I just need to create a product post with name, description, image, url to digital file, and price using wordpress custom post type. All payment will be handle by paypal nothing complex for the client. Sometimes, the beauty is in simplicity. the digitals files will be outside of www and will only be available once to customer as download link after purchase. If easy issue, it will be email based on paypal invoice. – cmsdeployed Jan 18 '14 at 12:14
1

To answer the question directly, it is a setting within your PayPal that allows user to auto return to your site. More information can be found here. It is located at My Account > Profile > Website Payment Preferences within your PayPal account. You will need to set a default here.

Following that, you can overwrite the return URL on a case by case basis by adding the following into your HTML

<input type="hidden" name="return" value="http://www.example.com/page-to-return-to">
  • Thank you for your tips. So basically can I have this added as part of the form button? and I could create a dynamic return value as: – cmsdeployed Jan 18 '14 at 12:22
  • Thank you for your tips. So basically can I have this added as part of the form button? and I could create a dynamic return value as: [code] <input type="hidden" name="return" value="@root/download/<?php $meta_values = get_post_meta($post_id, 'product-name'); ?>.pdf"> [/code] by making sure I name the file properly based on product-name. I guess in theory it should be working. – cmsdeployed Jan 18 '14 at 12:29
  • Your code didn't format, in comments use the ` to wrap code instead of [code]. But yes include it within your PayPal button form and set the the return value to be dynamic with php, just as you have already. Though be sure to actually echo out the value, because you've omitted that in your example. Also don't forget to setup auto return in your PayPal account. – user10106 Jan 18 '14 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.