Insert code for PayPal minimum order dollar amount - paypal

While searching for days for answers to how to set a minimum order subtotal in WordPress with PayPal, I found this thread: Can I set a maximum and minimum payment amount on Paypal
But now that I found an answer, I don't know how to implement it! Can anyone tell me where to put the code suggested?:
function checkMinimum() {
var min = 5;
if( parseFloat( document.formName.fieldName.value ) < min ) {
alert("Minimum amount should be not less than $" + min + ". Spend more.");
return false;
}
return true;
}

If you have a form or page before your site redirects to the paypal site you can place the code on that page

Related

i can't show space in formula in Crystal Report

I use this code to show the sum of my bank
if {?Bank} = {Bank.sum} then {#1} else 0
I have 6 bank accounts and when the bank = Bank has operations, then I show the sumand else I do not show anything.
I do not want to show "0" in my report.
I want to show " "(space), but when I change it to " ".
When I do it, I get the error
A number is required here
How can I fix it?
In that case, use:
if {?Bank} = {Bank.sum} then ToText({#1},0) else ""
The 2nd arg indicates zero decimal points. See online documentation of the ToText() function.
One option:
if {?Bank} = {Bank.sum} then ToText({#1}) else ""
Another option is to use formatting.

Rounding amount in javascript

I'm trying to round the amount in my form's total, tried several methods provided in different threads but none worked for me.
my form url is http://indushospital.org.pk/qurbani/
The amount shown in total is multiplied with 2.5% additional charges due to which its showing the amount like USD 186.63372, I want to show it like 186.64 Or simply 187.
The additional charges formula is mentioned below:
function getAmountPlusCharges(amount) {
// additionalCharges would result here '250' when '20000' is passed as amount.
var additionalCharges = (amount * 2.564) / 100;
return additionalCharges + amount;
Please help, I
'm not familiar with java functions at all
Thanks in advance.
You just have to use Math.round, then you can use to fixed to make sure its always 2 decimal places.
function getAmountPlusCharges(amount) {
return (Math.round(amount * 102.564 ) / 100).toFixed(2);
}

PayPal error "Currency amount must be non-negative number"

I'm trying to implement the CFC (coldfusion) code found here:
http://www.sitekickr.com/blog/integrating-paypal-payflow-pro-rest-api/
I'm still at the testing stage and haven't even tried passing my own variables, just using the CFSET example provided.
<cfset response = paypal.capture( card_type = "visa"
, card_number = "4556747948786484"
, card_exp_month = "12"
, card_exp_year = "2018"
, card_firstname = "Bob"
, card_lastname = "Smith"
, amount = 15.25
, description = "Order 1011"
)>
I'm getting this error:
{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount.total","issue":"Currency
amount must be non-negative number, may optionally contain exactly 2
decimal places separated by '.', optional thousands separator ',',
limited to 7 digits before the decimal point"}],"message":"Invalid
request - see
details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"dfb7b0588d38e"}
It makes no sense because the currency value I'm passing is NOT a negative and contains only two decimal places. There is no obvious error with the "amount" value I'm passing.
So I'm stuck.
Here's how I solved my problem.
I discovered that in my PayPal developer account, I could go to the menu Sandbox/Transactions and get more details on transaction attempts.
Through this, I discovered the value I was actually passing for total was "15.25|||"
PayPal was receiving: "total": "15.25|||"
Upon further investigation, at line 57 of the CFC, I found
"total"= (NumberFormat(arguments.amount, "9.99")) & "|||",
I removed the: & "|||"
And got a successful response from PayPal's sandbox.

Crystal Report Counting

My question is similar to the link.
Crystal Reports - Count Formula
The answer only works when the certain status type is giving to you.
Now I am wondering that what if the status type is not giving to you (You dont know what's inside this filed first), and the type of the status can be varied based what's in {statustype} field.
And I want to be able to list all distinct status type and calculate it's total appearance in the report.
Well its easy if you see it my way, I read that thread which you referenced.
Make different Formulas for all the status types that you may know of, I am pretty sure that they will be maximum 4 or 5. Make formula like
localvar int x;
if(statustype = 'Accepted')
(
x = x++;
)
x;
Or you can put all the formulas to one, using the same if clause but changing the display string, make sure that its a summary field or is placed at the report footer.
localvar int accept;
localvar int reject;
localvar int Pending;
if(statustype = 'Accepted')
(
accept= accept++;
)
else if
(
reject = reject ++;
)
else if
(
Pending = Pending++;
);
"Accepted "+ accept + " Rejected " + reject + " Pending "+ Pending;
Hope this helps,
I figured out that a easy way that we can create a placeholder in main report for subreport. And we can make the manipulation in the subreport

Can I set a maximum and minimum payment amount on Paypal

I am new to making a payment gate way and require restricting purchases between a predefined minimum and maximum. I searched Google, finding this as the most useful result. Is there a way to accomplish this?
You can set the maximum with MAXAMT - read more
However there is no option to set the minimum with Paypal. But you can write a simple JS that checks on submit the form field value and throws an error if the amount is less than expected:
function checkMinimum() {
var min = 5;
if( parseFloat( document.formName.fieldName.value ) < min ) {
alert("Minimum amount should be not less than $" + min + ". Spend more.");
return false;
}
return true;
}