Hi, displaying a PayPal button with a proper price and title at the bottom of Ad details page is quite simple you can do that by adding the code below in your theme functions.php file
add_action("adverts_tpl_single_bottom", "paypal_adverts_tpl_single_bottom", 1000);
function paypal_adverts_tpl_single_bottom( $post_id ) {
$post = get_post( $post_id );
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="YOUR EMAIL HERE">
<input type="hidden" name="lc" value="BM">
<input type="hidden" name="item_name" value="<?php echo esc_attr($post->post_title) ?>">
<input type="hidden" name="amount" value="<?php echo esc_attr(get_post_meta( $post_id, "adverts_price", true)) ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_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_US/i/scr/pixel.gif" width="1" height="1">
</form>
<?php
}
Just replace “YOUR EMAIL HERE” with your actual email, this will create a PayPal button which will allow users to pay to your account price equal to the price on the Advert, however this will do just that. If you would like the payment to be automatically processed and the purchase to be sent to the user then this will require some additional custom programming.
Thank you very much for the information! However this has gotten 10 times more complicated in the last 24 hours. It seems that the payment structure I had in my head is way more complicated to achieve than I was thinking.
I want my users to be able to post their items for sale (seller) and then another user to be able to purchase that item with a direct PayPal transaction (buyer). That part seems easy enough however my website needs to take a very small commission for the transaction.
I was thinking to do that the payment must come to my website first and then I would need to auto generate another payment to the seller minus the small commission. Even still making a buy now button that pays the selling user instead of my websites email address has been a challenge as well.
Yesterday I added another plugin which allows “vendors” and sets the site up as a marketplace. This allows me to charge a commission like I want and appears to solve the payment thing completely, however I hate the layout and much prefer the advert layout and ad management. So I’m brainstorming of how I can incorporate the payment structure of the marketplace plugin with the layout and management of the advert plugin.
This might take a while because I have limited programming knowledge and the PayPal guides aren’t very helpful in this regard. Anyways thanks for reading all this. I appreciate the feedback.
The code provided above does indeed add a buy button to the listing page that allows the buyer to purchase their item at the listed price. Thank you so much for the help with that! However, I am stuck attempting to take a small commission per transaction.
The biggest hurdle is that I want every transaction to be Paypal protected between the buyer and seller, so the payment must come from the buyer to the seller. I was at first thinking that I would have the first payment come from the buyer straight to my website and then I would generate another payment from my website to the seller, minus my small commission. The issue arises if there is a problem with the product, I am then in the middle if one party wants to dispute. So I need to figure out a way for the payment to go directly between the two customers while still capturing the commission/fee.
Any ideas? Thank you for reading. This is the final hurdle I have to launch the website by the way.
You would first need some custom field where user would enter his PayPal email then update the code i sent you earlier to use the saved email address instead of your own email.
There at least few drawbacks to your solution to keep in mind:
1. the PayPal button does not allow to make a payment which will send a percentage of the fee to your account, at least not as far as i know, but you can search for proper variables here https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
2. the PayPal button will work only with PayPal verified emails if someone has unverified email address the payments to his account will not work.
I found this variable:
handling
Handling charges. This variable is not quantity-specific. The same handling cost applies, regardless of the number of items on the order.
By default, no handling charges are included.
I’m not charging the customer a percentage, only a 3 dollar fee, so a 3 dollar handling fee should work. I could possibly even change the code to reflect “website fee” or something of that nature.
I don’t mind the users having to be address verified, I want this is be as legit and protected as possible.
As far as the custom email fields, I am using woo commerce with wpadverts on top. Each ad is listed by a user and every user must be logged in, so the email address of the person who posted the ad should be stored in the code of the ad page. Then when another user (who must be registered and logged in) wants to purchase said item, it shouldn’t be too hard to grab their email from the account page.
This still doesn’t solve the issue of my site collecting the 3 dollar payment as the 3 dollars would just go to the seller with the payment. I know of one website that has accomplished this payment setup: swappa.com. Maybe there is a PayPal specific coding forum that I can use because these questions are actually unrelated to your plugin. You did your part when you told me where in the code I should be placing the PayPal button for it to appear on my ad pages.
Thanks again for reading.
The official PayPal developers forum you can find here https://developer.paypal.com/support/ hopefully they will be able to help you.
Hi @seh6183
https://developer.paypal.com/docs/classic/adaptive-payments/integration-guide/APIntro/
I think the above link from Paypal developers forum may give you some help.
It seems you may be able to implement parallel adaptive payments. Payment for product would go from your website to the API which splits payment to 2 or more receivers.
Thanks! This is really useful :).
Excellent. I believe this will be the key to making this all work. Now to just get it implemented lol
Greg if I can get some code started would you be able to help iron out some things to get me rolling? Such as extracting the sellers email address from the ad page?
For now i cannot help you with this as i am not familiar with the Adaptive Payments at all, when i will find some free time i will then need to read the documentation, sorry.