I want payment in paypal with dynamic price entered by user - wordpress

I want payment in paypal with dynamic price entered into textbox in wordpress. can anyone help me?according to user choices and price rate list,total price will change and will be calaulated by user.user will enter that amount in textbox which will be paid in paypal.How to do this? I did research on it.

You could use code similar to the following, where you have a text box for the buyer to enter in the amount. Then they click the button to make a payment and they will be redirected over to PayPal with that amount.
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="my_site#my_site.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Hot Sauce-12 oz. Bottle">
<input type="hidden" name="currency_code" value="USD">
<input type="text" name="amount" maxlength="60">
<br />
<!-- Display the payment button. -->
<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">
<img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
</form>

Related

Paypal IPN not retrieving variables

I have a Paypal account with set subscription button on it. After a subscription is set by a buyer I am sending him to a receipt page. On this page I need to retrieve variables from Paypal to update by database.
form is working
subscription saved on Paypal
buyer correctly redirected to receipt page
but variable are not retrieved.
here is what I have tried so far:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="mybusinessname">
<input type="hidden" name="lc" value="IE">
<input type="hidden" name="item_name" value="Monthly Subscription">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="a1" value="0.00">
<input type="hidden" name="p1" value="1">
<input type="hidden" name="t1" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="a3" value="1.50">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHosted">
<input type="hidden" name="custom" value="test_value">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_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>
Instant Payment Notification (IPN) details on Paypal are enabled and point to:
https://www.mydomain/payments/
IPN history shows that notifications from Paypal are correctly sent to Notification URL (above)
However, the receipt page shows
Error
Undefined index: custom
to get the custom variable I tried GET, POST and even REQUEST method using something like
test 1: <?php echo $_GET["custom"]; ?>
test 2: <?php echo $_POST["custom"]; ?>
Then I tried
<?php
if (isset($_POST['custom'])) {
$custom_display = $_POST['custom'];
}
?>
but this results in: Undefined variable: custom_display
All I need is to get custom variable.
I am guessing that I am doing something wrong, but after many hours of searching for an answer and trying different settings (e.g. sending dynamically notification url within the form, changing settings in paypal, using different urls etc) nothing seems to be working for me and I am stuck
Any help would be greatly appreciated!
I ran into the same issue (?) a few months back. The answer seems to be: PayPal does not pass custom in IPN anymore (nor does it honor the return value). Both of these stopped working sometime last year.
My workaround was to use the subscr_id value to lookup the customer profile. YMMV.

PayPal auto-generated button returning to Default

I'm just starting to develop with ASP.NET and the paypal API and one of the first things I've done is auto-generate the HTML for a PayPal buy now button.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"
target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="//my key">
<input type="image"
src="https://www.paypalobjects.com/en_US/GB/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_GB/i/scr/pixel.gif" width="1" height="1">
</form>
This constructs a button for me which is great. However upon clicking, instead of going to the https://www.paypal.com/cgi-bin/webscr URL as expected. I simply get a page post back to "/Default".
Do I need to set up anything else with the button?

recurring payments for five years

I am setting up a donation page (in WordPress) for a non-profit that has a "5 YEAR DONATION PLAN". Members pay $100 per month for 72 months.
I am attempting to use PayPal's example for recurring payments:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="alice#mystore.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="Alice's Monthly Digest">
<input type="hidden" name="item_number" value="DIG Weekly">
<!-- Set the terms of the recurring payments. -->
<input type="hidden" name="a3" value="69.95">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<!-- Set recurring payments to stop after 6 billing cycles. -->
<input type="hidden" name="src" value="1">
<input type="hidden" name="srt" value="6">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
Here is my code, edited:
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="kcarson#basinwidefoundation.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="Sky's The Limit - Galaxy72">
<input type="hidden" name="item_number" value="STL-G72">
<!-- Set the terms of the recurring payments. -->
<input type="hidden" name="a3" value="100.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<!-- Set recurring payments to stop after 72 billing cycles. -->
<input type="hidden" name="src" value="1">
<input type="hidden" name="srt" value="72">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
If I use the PayPal example, as is, the PayPal page displays exactly as it should. However, when I edit the code, with our specifics, I get this error message:
"The link you have used to enter the PayPal system is invalid. Please review the link and try again."
Thanks for your help!
You are passing the srt=72 which is not allowed . The allowed values for the srt is form 0 - 52 . Here is what docs say :
srt :Optional Recurring times. Number of times that subscription payments recur. Specify an integer with a minimum value of 2 and a maximum value of 52. Valid only if you specify src="1".
You can refer the documentation here.
Once you set it to any value between 0- 52 , it should work fine .

Paypal custom data

Is there a way to send custom data to Paypal when using a simple button to make payments?
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="D9DRKKKXPX5VL">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
I'd like to have field in this form where I can set a value and get it back with IPN. Is this possible at all?
I believe you can pass custom data through a button with this:
<input name="custom" type="hidden" id="custom" value="stuff">

Paypal Form Inside ASP.NET Form

Cheers,
I have a problem with integrating Paypal Shopping Cart to my ASP.NET C# project.
The problem is that Paypal Shopping Cart is inside a FORM tag, so if I place that inside my server form tag it won't work.
It would look like this:
<body>
<form id="form1" runat="server">
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="MySecretEmail#hidden.com">
<input type="hidden" name="display" value="1">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_viewcart_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>
</form>
</body>
Is there any way I can prevent this from happening? I've search on google and here on Stackoverflow where I found this link: PayPal Name-Value Pair API Basics, but honestly, it doesn't make any sense to me since I'm not a programmer.
Thank you!
The simplest way to solve this problem is to use the PostBackUrl property of the asp:button. Using this method, the ASP generates your JavaScript to handle the external post.
This allows the rendering of the form to happen correctly and doesn't require any workaround. Remember that as your code is already in a form tag, your paypal items don't need to be wrapped in an extra tag.
e.g.
<input type='hidden' name='cmd' value='_cart'/>
<input type='hidden' name='upload' value='1'/>
<input type='hidden' name='business' value='business#business.com'/>
<input type='hidden' name='currency_code' value='aud'/>
<input type='hidden' name='item_number_1' value='item number_1'>
<input type='hidden' name='item_name_1' value='16x16 inch square canvas'>
<input type='hidden' name='amount_1' value='70'>
<input type='hidden' name='item_number_2' value='item number_2'>
<input type='hidden' name='item_name_2' value=' 48x20 rectangular canvas'>
<input type='hidden' name='amount_2' value='104'>
<asp:Button ID="Button1" PostBackUrl='https://www.paypal.com/cgi-bin/webscr' runat="server" />
Hope this helps.
Technically, your example isn't valid HTML. In the longer term, you might be best refactoring this code to remove your 'technical debt'. (See "must not contain other form elements" under element prohibitions on the W3C site for XHTML 1.0)
In the meantime, you could try submitting the nested form with jQuery.
1. Replace Submit Button
<button class="submit-button" id="submit-button">Submit Payment</button>
2. Amend Form Tag
<form id="nested-form" target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
3. Submit form using jQuery
<script type="text/javascript">
$('#submit-button').live('click',function() {
$('#nested-form').submit();
});
</script>
I haven't had a chance to test this, so please test and let me know if it works for you.
Here's a very easy method. It's what I use exclusively so I know with 100% certainty that it works.
Create a "false" image only PayPal button.
User clicks this button (it's just an image)
This image has an onclick method which calls a 2 line javascript function (see below)
Put your "real" PayPal button form at the end of your page AFTER the closing form tag.
Enclose it in a SPAN tag with style="display:none;"
Add ID="ppsubmit" to the "real" button's image input
When user click the false button, the onclick method calls a javascript function that does just 2 things ... a) changes span display to inline and b) automatically clicks the real PayPal button.
<form id="form1" runat="server">
<!-- Here's the image only "false" paypal button -->
<input type="image"
src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"
onclick="javascript:doPPform();" />
</form> <!-- this closes your asp.net form -->
<!-- Here's the hidden span with the real paypal button
at the bottom of your webpage -->
<span id="ppform" style="display: none;">
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"
target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="xxxxx">
<input id="ppsubmit" type="image"
src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif"
border="0" name="submit"
alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0"
src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif"
width="1" height="1">
</form>
</span>
<!-- Here's the 2 line javascript code when the user clicks the "false" button -->
<script language="javascript" type="text/javascript">
function doPPform() {
document.getElementById("ppform").style.display = "inline";
document.getElementById("ppsubmit").click();
}
</script>
A quick solution would be to put the paypal form inside an iframe.
On the form element, change target="_parent" so it posts back to the parent page.
Why don't you make the page the payment form is on use a MasterPage that has the tag removed. I do this on all the sites and it works without problems.
I discovered the PayPal button problem before I discovered that it is an ASP.NET problem.
In the process of creating buttons and adding to my page, sometimes they would work and sometimes they would not. Then I would have 2 identical buttons and the second would work and the first would not. Remove the first and then the button that worked would not. To get to the point if I added a form tag before my PayPal button the Paypal button works.
<%-- simple form tag --%>
<form action="">
</form>
<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="hughet_1335403121_biz#yahoo.com">
<input type="hidden" name="lc" value="US">
<input id="iptItemName" type="hidden" name="item_name" value="testBuyNow">
<input type="hidden" name="amount" value="10.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="bn"
value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image"
src="https://www.sandbox.paypal.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.sandbox.paypal.com/en_US/i/scr/pixel.gif"
width="1" height="1">
</form>
I understand this a "hack fix", and I'm not sure why this works. Curious if this works for others.

Resources