Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal button with 'min_amount' AND 'set_customer_limit'

Tags:

php

paypal

I have created a non-hosted PayPal-Button with a text input to let users define an amount to pay. It's a subscription button.

Now the problem is that there must be a minimum amount to pay, say 101 (CHF - Swiss francs).

According to the docs of PayPal HTML-Variables I have the possibility to add the following vars in hidden inputs to my form to get it to work.

  • set_customer_limit with a value of max_limit_own
  • min_amount with a value of 101

The set_customer_limit is working but not the min_amount. Any amount is accepted.

I opened a ticket at the technical support, but no reply till now.

Here's my form:

<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="cancel_return" value="mydomain.com/cancel">     <input type="hidden" name="return" value="mydomain.com/paid">     <input type="hidden" name="token" value="<?php echo $token; ?>">     <input type="hidden" name="src" value="1">     <input type="text" name="a3" value="101.00">     <input type="hidden" name="p3" value="1">     <input type="hidden" name="t3" value="Y">     <input type="hidden" name="currency_code" value="CHF">     <input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHostedGuest"> <!-- the concerned inputs -->     <input type="hidden" name="set_customer_limit" value="max_limit_own">     <input type="hidden" name="min_amount" value="101"> <!-- ---- -->     <input type="image" src="https://www.paypalobjects.com/de_DE/CH/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.">     <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1"> </form> 

As for the moment, I just validate the minimum amount with JavaScript, which isn't really secure...


EDIT

As an idea, I could implement another form (submit it by AJAX, onchange, onkeyup, whatever), which sets the minimum amount given by the user before the PayPal-form and put it into the PayPal-input then (set to hidden again):

<input type="hidden" name="a3" value="<?php echo $_POST['pre_min_amount'] ?>"> 

That way I could validate the minimum amount with PhP, before submitting the PayPal-form. But that doesn't seem a clean way to me. Really Glad if anybody could give me a hint!

like image 983
toesslab Avatar asked May 04 '15 08:05

toesslab


People also ask

What is the benefit of using PayPal buttons?

PayPal doesn't have any ongoing fees or long term contracts which makes it convenient. “Buy Now” buttons can be encoded to allow your customers to purchase an item with a fixed amount. Buyers may purchase multiples of the same items. PayPal will track inventory of these items if that is required.

Where is the PayPal Tools button?

Log in to PayPal and click the blue My PayPal button in the top right corner, next to the Log out button. Scroll down to the bottom of the page, and click on the Selling tools link. Don't worry!

How many saved payment buttons can a PayPal account have?

Note: A merchant's PayPal account can have a maximum of 1,000 saved payment buttons. An identifier of the source that built the code for the button that the buyer clicked, sometimes known as the build notation. Specify a value using the following format: Important: The BuyNow is deprecated.

What information is required for PayPal instant payment notification messages?

The URL to which PayPal posts information about the payment, in the form of Instant Payment Notification messages. Character Length: 255 Required for buttons that have been saved in PayPal accounts. Otherwise, not allowed. The ID of the button that was saved in a merchant's PayPal account.

Why is my default payment type PayPal?

Default is primary if you added a custom payment page style to your account profile. Otherwise, Default is paypal. The button that the person clicked was a Buy Gift Certificate button. Set to 1 to have PayPal generate usernames and initial passwords for subscribers. For more information, see Generate Subscriber User Names and Passwords.

What character lengths are required for payment buttons?

Character Length: 255 Required for buttons that have been saved in PayPal accounts. Otherwise, not allowed. The ID of the button that was saved in a merchant's PayPal account. PayPal assigns the value when payment buttons are first created and saved in merchants' PayPal accounts.


1 Answers

The answer of the PayPal technical support is: No it is not possible!

(Date of answering was 05/02/2015) Hopefully, this will be possible in the future. If so please post your answer!


I'd really suggest using the PayPal API for this kind of thing (including creating a developer account, byting thru the docs, etc).

So this "solution" is a quick & dirty workaround.


First, add a small form (I call it the min_amount -form for now) to the page (telling the user, he has to set the amount first):

<form id="min_amount" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">     <input type="text" id="pre_min_amount" name="pre_min_amount" value="101">     <input type="submit" value="Set min. Amount"> </form> 

Then, add the whole PayPal form to a PHP variable with NowDoc and add the posted value from the min_amount-form to the a3 input:

$min_amount = 0; $payPalForm = <<<SOME <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">     <!-- //... -->     <input type="hidden" name="a3" value="$min_amount"> </form> SOME; 

After submitting, check if the minimum amount is true and then only show the PayPal-form:

if (isset($_POST['pre_min_amount']) && is_numeric($_POST['pre_min_amount']) && floatval($_POST['pre_min_amount']) >= 101) {     $min_amount = htmlspecialchars($_POST['pre_min_amount']);     echo $payPalForm; } 

As I said, it's quick and dirty (no more time for this project), but you ensure to validate the minimum amount on the server-side, not just with Javascript. You could also submit the min_amount-form with an AJAX call, but then the return of this call is on the client-side, which isn't really secure either. (Sure you may also)

BTW, I am not proud of this solution at all, but sometimes, a programmers life is hard and I'm sure all you coders out there had to do some q&d code somehow, somewhere ;-)...


Update: 08/05/2015

All depends on the country in which the concerning account is registered. Full services guaranted by PayPal only in the USA and Canada

like image 188
toesslab Avatar answered Oct 05 '22 14:10

toesslab