Multiple PayPal buttons inside single Form Element - php

Currently I can have single paypal button in a form element like:
<form id="pkg1" name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="seller_1360303883_biz#gmail.com"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="item_name" value="Digital Download"/>
<input type="hidden" name="amount" value="$<?php echo $price1 ?>"/>
<input type="hidden" name="return" value="https://www.sandbox.paypal.com/cgi-bin/success.php"/>
<input type="hidden" name="notify_url" value="notify.php"/>
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
</form>
I wonder if there is a way to place more than one paypal buttons in single form??
I'm no talking about adding to cart.
So is there a way that i be able to make individual transactions while putting them in single form?
Thanx in Advance

Related

PayPal html button for digital goods

I'm having a problem with a PayPal button that I made. Yesterday I got my first sale of a digital good on my website, everything worked well except at the end when PayPal blocked the payment.
I called them to know why and they explained me that it was because the order was made for physical products and the shipping information was missing.
They unblocked the payment but I can't find how to set that the payment is for digital goods.
My code below:
<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="my email">
<input type="hidden" name="lc" value="IT">
<input type="hidden" name="item_name" value="product">
<input type="hidden" name="amount" value="00.00">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="mysite">
<input type="hidden" name="cancel_return" value="mysite">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_SM.gif:NonHosted">
<input type="hidden" name="custom" value="userid" />
<input type="hidden" name="notify_url" value="IPN ">
<input type="image" src="img/paypal1.png" style="width: 100%; height: 100%;" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>
Your code is correct to not collect shipping for a digital good, no_shipping=1. Ref: https://developer.paypal.com/docs/paypal-payments-standard/integration-guide/Appx-websitestandard-htmlvariables/#paypal-checkout-page-variables
Perhaps you were misinformed as to why the payment was on hold.
One thing you can do is to ensure the item name makes clear that it is something digital.

Unable to pass amount in paypal using _xclick

I am trying to create simple PayPal button who pass amount and quantity details to PayPal. I am unable to pass hardcore amount in PayPal. I am expecting to show result like this:
Expected output
Problem is that my amount is not transferring to PayPal. Please support to resolve. Here is my code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" amount="1.0">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="hmmdmlk#gmail.com">
<input type="hidden" name="item_name_1" value="Item #1">
<input type="hidden" name="amount_1" value="1.00">
<input type="submit" value="PayPal">
</form>
When using _xclick, which is for operations on a single item, you want:
<input type="hidden" name="item_name" value="The item name.">
<input type="hidden" name="amount" value="1.00">
The multi-item parameters you were using would be for _cart with upload=1, not _xclick
Documentation: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx-websitestandard-htmlvariables/

how to use paypal subscription form for multiple subscriptions?

I am trying to use paypal subscription form for multiple product, but its not working.
Here is my form which i used.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="archirayan9#gmail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="item_name" value="Baseball Hat Monthly - test2 " />
<input type="hidden" name="item_number" value="asd">
<input type="hidden" name="a3" value="10.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
</form>
This form is for 1 product subscription. I want to make it for multiple products with different item_id.
I cant found any thing that help me to setup multiple product subscription using this form.
Anyone have solution how to do?

paypal notify_url not working and tx ID variable not pass to thank you page

Here is my paypal buy now html code:
<form name="_xclick" action="https://www.paypal.com/ca/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="alex#xumanii.com">
<input type="hidden" name="item_name" value="Bewolf Shooping Cart">
<input type="hidden" name="amount" value="<? echo $grandtotal2;?>">
<input type="hidden" name="add" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="member_id" value="<? echo $info['member_id'];?>">
<input type="hidden" name="return" value="http://www.bewolfclothing.com/thankyou.php">
<input type="hidden" name="notify_url" value="http://www.bewolfclothing.com/notify_paypal2.php">
<input type="hidden" name="cancel_return" value="http://www.bewolfclothing.com/mycart.php">
<input type="hidden" name="undefined_quantity" value="0">
<div class="submit-container"><input class="submit-button" type="submit" name="submit" value="CHECK OUT" /></div>
</form>
In my paypal account, under profile, my selling tools, I have set the AUTO RETURN to ON and I put the thankyou page in there.
After the purchase, it goes to the thankyou page, but the $_REQUEST['tx'] for the paypal transaction ID is not working and the notify_url NEVER gets called.
I searched online and saw that lots of people seem to have trouble with that, but I couldn't find a solution.
notify_url is used to Instant Payment Notification and the url should always be a live URL.
To get the tx ID, you need to
-Auto Return is set to ON
-Valid Return URL
-Payment Data Transfer is set to ON
and in your "http://www.bewolfclothing.com/thankyou.php"
$tx_id = $_GET['tx']; //gives you tx id

Replace shortcode with HTML multiple times on a page

My client wants the ability to put PayPal add-to-cart buttons anywhere on a page, with potentially multiple buttons on a single page. He will use a shortcode like [price MONKEY] to have a PaylPal button replace that text, with the price and description for "monkey".
So every time we find a [price] shortcode on the page, I need to query the database to get value, insert then into the following PayPal button code, and display the button at that place on the page. Then move to the next replacement, if any.
Here's the PayPal button code:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" value="_cart" name="cmd" />
<input type="hidden" value="me#mydomain.com" name="business" />
<input type="hidden" value="1" name="add" />
<input type="hidden" value="MONKEY" name="item_name" />
<input type="hidden" value="" name="item_number" />
<input type="hidden" value="17.00" name="amount" />
<input type="hidden" value="2" name="no_shipping" />
<input type="hidden" value="USD" name="currency_code" />
<input border="0" type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" alt="Make payments with PayPal - it's fast, free and secure!" />
</form>
I've been trying to do this with a preg_replace_callback() function, but having problems inserting all the HTML for the button, and then with looking for more shortcode instances on the page and replacing them.
Appreciate any help on this! It's so simple in Wordpress where all this code is already written (but where?) -- this is an application that I created from scratch and now needs some enhancement. Thanks!
Here's my regex:
$pattern = '/\[price (.*?)\]/';
You can just use a basic preg_replace to accomplish this task using your pattern. something like so:
<?php
function myexamplefunction($html){
$pattern = '/\[price (.*?)\]/';
$replace = '<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" value="_cart" name="cmd" />
<input type="hidden" value="me#mydomain.com" name="business" />
<input type="hidden" value="1" name="add" />
<input type="hidden" value="$1" name="item_name" />
<input type="hidden" value="" name="item_number" />
<input type="hidden" value="17.00" name="amount" />
<input type="hidden" value="2" name="no_shipping" />
<input type="hidden" value="USD" name="currency_code" />
<input border="0" type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" alt="Make payments with PayPal - it\'s fast, free and secure!" />
</form>';
return preg_replace($pattern,$replace,$html);
}

Categories