I am processing a simple form to PayPal's Express Checkout using the basic standard free account and the standard form "_xclick" option.
When passing through the item name or description, I understand you are limited to 144 characters but I want to have the information inside the title or the description on different lines to separate the information when on PayPals checkout area so the user can clearly see what they are paying for.
I have tried to use "\r" and "\n" to seperate the lines, as seen below in the "item_name" input using "This is line 1\r\nThis is line 2\r\nThis is line 3", but it just ignores the "\r" and the "\n" when passed through to the PayPal payment page and when sent in the receipt email.
Current Example Code:
<form name="TheForm" method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="item_name" value="This is line 1\r\nThis is line 2\r\nThis is line 3">
<input type="hidden" name="price" id="price" value="" />
<input type="hidden" name="business" value="test#test.com">
<input type="hidden" name="amount" value="">
<input type="hidden" name="no_shipping" value="1">
<input type="submit" name="Submit" id="Submit" value="Process Payment" />
</form>
I have also tried using
,
, <br> and <br /> and none of these work either and are passed through as text.
How can I achieve separating the item information on seperate lines using the form option INPUT value, as shown above, for the item description or title please as the way I have tried does not work and I cannot find any solution?
Thanks.
Currently there is not a way to do this. The standard buy now buttons do not support this. The closest you can come to putting things on a different line would be using a cart upload method. Instead of passing over 1 item, with 3 values in the item name that you want displayed on 3 different lines you would pass over 3 individual items which would cause them to be on 3 different lines.
Related
Using MechanicalSoup, does one have to set values for hidden fields in a form as well? Or can we just ignore them?
Here is their code in the HTML form:
<input type="hidden" name="details[sid]" />
<input type="hidden" name="details[page_num]" value="1" />
<input type="hidden" name="details[page_count]" value="1" />
<input type="hidden" name="details[finished]" value="0" />
<input type="hidden" name="form_build_id" value="form-OoBDi0_aQvgHZN-Iyc" />
<input type="hidden" name="form_id" value="webform_client_form_337" />
<input type="hidden" name="honeypot_time" value="1519679330|-x8kCHBe6qh7E" />
Hidden fields are typically used internally by the website you're browsing: they are generated with a value, and this value is sent together with non-hidden fields when you submit the form.
MechanicalSoup does what you expect here: it sends the values of hidden fields when you submit the form, so essentially you don't have to care about them: their value will be set by the website you're visiting, and then taken into account by MechanicalSoup just like a normal browser.
You shouldn't need to modify their value, because when using the website with a real browser, the user has no simple way to set a value (that's the point of hiding the fields ...).
You can add your own hidden input name:value pairs using the new_control() method. I've had to do this when the form used javascript to set a hidden element before form submission.
browser.new_control('hidden','name','value')
https://mechanicalsoup.readthedocs.io/en/stable/mechanicalsoup.html#mechanicalsoup.Form.new_control
I'm trying to add payfort as a payent gateway to a new section in a website. The same code works correctly in another section. I always get "Error code: 00002 Invalid parameter format"
<form method="post" action="https://checkout.payfort.com/FortAPI/paymentPage" class="pay_form" name="form1">
<input type="hidden" name="access_code" value="access_code">
<input type="hidden" name="amount" value="1000.00">
<input type="hidden" name="command" value="PURCHASE">
<input type="hidden" name="currency" value="USD">
<input type="hidden" name="customer_email" value="user#mail.com">
<input type="hidden" name="customer_name" value="customer name">
<input type="hidden" name="language" value="en">
<input type="hidden" name="merchant_identifier" value="identifier_code">
<input type="hidden" name="merchant_reference" value="order_id">
<input type="hidden" name="return_url" value="my_return_url">
<input type="hidden" name="signature" value="form_signature">
</form>
I compared this form to another form in the other section and they are similar to each other but order id, return url and amount are different but the first form works without any issues. Any ideas?
It's because payfort only accepts whole number as amount. You need to multiply the actual amount by 100 and before sending request to payfort make sure its whole number.
I have a contact form on my site. I use formit for its FormIT validation. I want email be not more than 40 characters, be reqired and be correct email address. Message field is required too and has max length set.
Validator doesn't work correctly:
When required fields are empty, it shows error message and doesn't allow to send the form (this situation is absolutely correct)
When in email is any text (valid or not), form is sent but redirect to success page doesn't work (so it happens also when we enter more than max length)
[[!FormIt?
&hooks=`spam,email,redirect,FormItAutoResponder`
&emailTpl=`emailTplContact`
&emailSubject=`Message from site.com`
&emailTo=`myemail#gmail.com`
&validate=`email:email:required:maxLength=^40^,
message:required:maxLength=^150^`
&redirectTo=`11`
&fiarTpl=`emailAutoRespond`
&fiarSubject=`Your message is sent`
&fiarFromName=`My Site`
&fiarFrom=`myemail#gmail.com`
&fiarToField=`email`
&fiarReplyTo=`email`
]]
<form id="contact-form" method="post" action="[[~[[*id]]]]" enctype="application/x-www-form-urlencoded" role="form" data-toggle="validator" name="order">
<input type="text" id="name" name="name" type="name" placeholder="Name" value="[[!+fx.name]]" size=25>
<input type="text" required="required" type="email" id="email" name="email" placeholder="Email" value="[[!+fx.email]]">
[[!+fx.error.email]]
<textarea required="required" placeholder="Message" id="message" name="message">[[!+fx.message]]</textarea>
<button name="send">Send</button>
</form>
</div>
You have type attribute twice in the name input and the email input, so that might be the problem.
<input type="text" id="name" name="name" type="name">
<input type="text" required="required" type="email">
Remove type="name" and type="email" -- (leave type="text")
Also - I have only ever used a prefix of fi for Formit placeholders; do you know for sure that fx will work? Did you set that somewhere else? You say you're seeing the error message so I guess the error placeholder must be working...
Be sure to add placeholderPrefix to your FormIt call:
[[!FormIt?
&placeholderPrefix=`fx`
&hooks=`spam,email,redirect,FormItAutoResponder`
&emailTpl=`emailTplContact`
&emailSubject=`Message from site.com`
&emailTo=`myemail#gmail.com`
&validate=`email:email:required:maxLength=^40^,
message:required:maxLength=^150^`
&redirectTo=`11`
&fiarTpl=`emailAutoRespond`
&fiarSubject=`Your message is sent`
&fiarFromName=`My Site`
&fiarFrom=`myemail#gmail.com`
&fiarToField=`email`
&fiarReplyTo=`email`
]]
For example item price is £6.78 postage and packaging should be:
Single copy: £1.50
2-3 copies £3.00
4-6 copies: £4.00
7-8 copies: £5.00
9 copies: £6.00
10 or more free
Any idea how I can do this? The current code for the item is:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CUWB7BQEL337J">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_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>
I read somewhere that I need to do something like:
<input type="hidden" name="shipping" value="1.50">
<input type="hidden" name="shipping2" value="3.00">
<input type="hidden" name="shipping3" value="3.00">
<input type="hidden" name="shipping4" value="4.00">
<input type="hidden" name="shipping5" value="4.00">
<input type="hidden" name="shipping6" value="4.00">
<input type="hidden" name="shipping7" value="5.00">
<input type="hidden" name="shipping8" value="5.00">
<input type="hidden" name="shipping9" value="6.00">
<input type="hidden" name="shipping10" value="0.00">
Where would this go as when I tried it it didn't work.
it looks like your on the right lines (although you might try 'shipping_1', 'shipping_2',etc. you have missed out the underscore) but you may find that you are need to send "shipping_1 = £1.00", "Quantity_1 = 2", which Paypal may interpret as 'shipping = 2 times £1.00', but I think it will assume shipping_1 is for the button item as a whole because you are using a button to specify a specific item not a bunch of items (i.e. 1 button = 1 item).
What happens if the person presses the button twice, im not sure. The only thing I've found in Paypal's documentation talks about setting up weight's for postage costs within your Paypal account, then prices per weight (i.e. 1 item weighs 1kg, cost = £1.00, 2 items weigh 2kg, cost = 2 x 1kg weight = £2.00, etc.). You could also look into this area.
I found the buttons to restictive and built my own shopping cart in my code behind including shipping costs (which I calculate), then send just one "shipping_1 = x.xx" cost to paypal along with the items details, this works fine.
I think I may add a new post on here with my working code for a shopping cart to help others, just need to tidy it up a bit. (I'll add a link from this post if your interested).
You could try referring to this page.
https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/cart_upload/
Trev.
I have a content type which is only viewable (not editable) to a certain role. I've customised the form output completely (manually outputting each field as they display in a certain way).
However there's one field I would like this user to be able to 'edit' which is a custom 'revision comment' field I've made. I can hardcode in the form fields, except of course it won't work without the token, build id etc that Drupal generates like this:
<input type="hidden" name="form_build_id" value="<?php print render($form['#build_id']); ?>">
<input type="hidden" name="form_token" value="<?php print drupal_get_token($form['#token']); ?>">
<input type="hidden" name="form_id" value="<?php print render($form['#form_id']); ?>">
So essentially I'm wondering what workaround I could use, as $form and it's variable are obviously only generated when 'editing' the node.
In case anyone else needs to know, I hardcoded this into the template file and it works:
<form class="node-form node-project-form" action="/dashboard" method="post" id="project-node-form" accept-charset="UTF-8">
<input type="hidden" name="nid" value="<?php print $nodeid; ?>">
<input type="hidden" name="uid" value="<?php print $user->uid; ?>">
<div id="revision-comments" style="margin:0">
<label for="log-comments">Log Message</label>
<textarea id="log-comments" name="log_comments"" cols="60" rows="4" class="form-textarea"></textarea>
</div>
<input type="submit" id="edit-submit" name="op" value="Post Comment" class="form-submit">
</form>