I have written a simple add-on browserview for a Plone 3.2.1 site, it is a simple form that uses HTML variables specified by PayPal and then posts to a PayPal address.
Due to the nature of these fields on the PayPal form, there is absolutely no validation when I post directly to PayPal, this is understandable as most of them are optional. I am looking to use urllib and urllib2 in order so that I can instead post the form to a Python script, validate the input and and then post to PayPal.
Layout of BrowserView (trimmed)
paypal.test
|-paypal
|-test
|-browser
|-paypal_validation.py
|-paypal_validation_script.py
|-paypal_view.pt
|-configure.zcml
configure.zcml
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="paypal.test">
...
<browser:page
name="paypal_validation_script"
for="*"
permission="zope2.View"
class=".paypal_validation.PayPalValidation"
/>
<browser:page
name="paypal_validation"
for="*"
permission="zope2.View"
class=".paypal_validation.PayPalView"
/>
</configure>
paypal_validation.py
from Products.Five import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class PayPalView(BrowserView):
template = ViewPageTemplateFile('paypal_view.pt')
def __call__(self):
self.paypal_name = getattr(self.context, 'paypal_name', 'World')
return self.template()
paypal_view.pt
<form action="paypal_validation_script" method="post"
tal:define="did python:request.form['did'];
ourl string:http://www.mysite.co.uk/uploadedfiles/;
dil python:ourl + did">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="paypal-facilitator#someothersite.co.uk" />
<label for="item_name">Design Name:</label>
<input name="item_name" id="item_name" />
<label for="dimensionx">Width (mm):</label>
<input type="hidden" name="on0" value="Width (mm)" />
<input id="dimensionx" name="os0" />
<label for="dimensiony">Height (mm):</label>
<input type="hidden" name="on1" value="Height (mm)" />
<input id="dimensiony" name="os1" />
<label for="dimensionz">Depth (mm):</label>
<input type="hidden" name="on2" value="Depth (mm)" />
<input id="dimensionz" name="os2" />
<label for="design_no">Design Number:</label>
<input type="hidden" name="on3" value="Design Number" />
<input id="design_no" name="os3" />
<label for="tool_no">Tool/Cutter Number:</label>
<input type="hidden" name="on4" value="Tool/Cutter Number" />
<input id="tool_no" name="os4" />
<input type="hidden" name="item_number" id="item_number" tal:attributes="value dil"/>
<label for="street_addr">Street Address:</label>
<input type="hidden" name="on5" value="Street Address" />
<input id="street_addr" name="os5" />
<label for="city">City:</label>
<input type="hidden" name="on6" value="City" />
<input id="city" name="os6" />
<label for="postcode">Post Code:</label>
<input type="hidden" name="on7" value="Post Code" />
<input id="postcode" name="os7" />
<label for="tel">Telephone Number:</label>
<input type="hidden" name="on8" value="Telephone" />
<input id="tel" name="os8" />
<label for="email">Email Address:</label>
<input type="hidden" name="on9" value="Email Address" />
<input id="email" name="os9" />
<input type="hidden" name="amount" value="19.99" />
<input type="hidden" name="no_shipping" value="0" />
<input type="hidden" name="no_note" value="0" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="return" value="http://www.mysite.co.uk" />
<div class="formControls">
<input type="submit" data-env="sandbox" value="Pay with PayPal" />
</div>
</form>
paypal_validation_script.py
This is currently empty as I have so far been unable to get this working... I presume I can just use context.REQUEST here to obtain filed information?
What is happening
Whenever I submit the form I am taken to a 404 explaining that paypal_validation_script is not available, I'm not sure how I can reference this script (see above) in my form so that I can validate and post the necessary information using it.
Related
I have integrated below test php code to integrate gtpay payment in my site.But I am getting following error.
Response Description: Interface Integration Error
It is has key related problem given in the below gtpay integration manual.
https://ibank.gtbank.com/gtpay/IntegrationAPI/mman-tech.html
But I have tried several time to resolve this issue but not getting any solution. Please find the error.
<?php
$the_key = trim('17'.'5664879896'.'200'.'840'.'458742'.'D3D1D05AFE42AD50818167EAC73C109168A0F108F32645C8B59E897FA930DA44F9230910DAC9E20641823799A107A02068F7BC0F4CC41D2952E249552255710F');
$key = hash('sha512',$the_key,false);
?>
<form name="submit2gtpay_form" action="https://ibank.gtbank.com/GTPay/Tranx.aspx" target="_self" method="post">
<!-- <input type="hidden" name="hashkey" value="">-->
<input type="hidden" name="gtpay_mert_id" value="17" />
<input type="hidden" name="gtpay_tranx_id" value="5664879896" />
<input type="hidden" name="gtpay_tranx_amt" value="200" />
<input type="hidden" name="gtpay_tranx_curr" value="840" />
<input type="hidden" name="gtpay_cust_id" value="458742" />
<input type="hidden" name="gtpay_cust_name" value="Test Customer" />
<input type="hidden" name="gtpay_tranx_memo" value="Mobow" />
<input type="hidden" name="gtpay_no_show_gtbank" value="YES" />
<input type="hidden" name="gtpay_echo_data" value="TEST" />
<input type="hidden" name="gtpay_gway_name" value="" />
<input type="hidden" name="gtpay_hash" value="<?php echo trim($key); ?>" />
<input type="hidden" name="gtpay_tranx_noti_url" value="" />
<input type="submit" value="Pay Via GTPay" name="btnSubmit"/>
<input type="hidden" name="gtpay_echo_data" value="">
</form>
You are required to make the hash of [gtpay_mert_id,gtpay_tranx_id,gtpay_tranx_amt,gtpay_tranx_curr,gtpay_cust_id,gtpay_tranx_noti_url,hashkey] (Total 7 params).
You are making the hash key with only 6 params. You missed with the gtpay_tranx_noti_url(gtpay transaction notifying URL).
The gtpay_tranx_noti_url is a required field.
<?php
$the_key = trim('17'.'5664879896'.'200'.'840'.'458742'.'YES'.'D3D1D05AFE42AD50818167EAC73C109168A0F108F32645C8B59E897FA930DA44F9230910DAC9E20641823799A107A02068F7BC0F4CC41D2952E249552255710F');
$key = hash('sha512',$the_key,false);
?>
<form name="submit2gtpay_form" action="https://ibank.gtbank.com/GTPay/Tranx.aspx" target="_self" method="post">
<!-- <input type="hidden" name="hashkey" value="">-->
<input type="hidden" name="gtpay_mert_id" value="17" />
<input type="hidden" name="gtpay_tranx_id" value="5664879899" />
<input type="hidden" name="gtpay_tranx_amt" value="200" />
<input type="hidden" name="gtpay_tranx_curr" value="840" />
<input type="hidden" name="gtpay_cust_id" value="458742" />
<input type="hidden" name="gtpay_cust_name" value="Test Customer" />
<input type="hidden" name="gtpay_tranx_memo" value="Mobow" />
<input type="hidden" name="gtpay_no_show_gtbank" value="YES" />
<input type="hidden" name="gtpay_echo_data" value="TEST" />
<input type="hidden" name="gtpay_gway_name" value="" />
<input type="hidden" name="gtpay_hash" value="<?php echo trim($key); ?>" />
<input type="hidden" name="gtpay_tranx_noti_url" value="" />
<input type="submit" value="Pay Via GTPay" name="btnSubmit"/>
<input type="hidden" name="gtpay_echo_data" value="">
</form>
Its worked if error in gtpay_tranx_id duplicate entry...
Just change any value and reload it.
I have a strange problem.... I'm trying to filling out all data in Paypal request but all fields works execpt contact phone. This is my code:
<form name="f" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="amount" value="7.91" /><input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" /><input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="notify_url" value="http://localhost/ipn.php?idB=37" />
<input type="hidden" name="business" value="info#123.it" />
<input type="hidden" name="item_name" value="Acquisto Prodotti" />
<input type="hidden" name="item_number" value="" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="return" value="http://localhost/sexy/thank_you_page.php" />
<input type="hidden" name="cancel_return" value="http://localhost/" /><input type="hidden" name="first_name" value="John" />
<input type="hidden" name="last_name" value="Doe" />
<input type="hidden" name="address1" value="Viale cattaneo, 23" />
<input type="hidden" name="city" value="Roma" /><input type="hidden" name="state" value="Siracusa" /><input type="hidden" name="zip" value="91230" /><input type="hidden" name="country" value="IT" />
<input type="hidden" name="lc" value="italy" />
<input type="hidden" name="country_code" value="IT" />
<input type="hidden" name="contact_phone" value="1234567" />
<input type="hidden" name="email" value="me#me.com" />
<input type="submit" value="Click here if you are not redirected within 10 seconds" />
</form>
I read here but nothing help
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
Someone knows how to SET Contact Phone?
Screenshot of the issue.
Use the following fields:
night_phone_a
night_phone_b
night_phone_c
These fields, in the US, shall be used to indicate the number format AAA-BBB-CCC. For other parts of the world, just put everything into night_phone_a.
And BTW, you have visited the right document page. These 3 fields are on the page.
I have two Carts on a site I am working on. One works just fine. The other though is not, and I can't find the problem at all.
The code for the form is blow (hidden domain name and email of course):
<form id="paypalpayment" action="https://www.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="order_id" value="24" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="business" value="pay#xxxxxxxx.com" />
<input type="hidden" name="item_name_1" value="Shopping Cart" />
<input type="hidden" name="item_number_1" value="Order-24" />
<input type="hidden" name="amount_1" value="23.49" />
<input type="hidden" name="first_name" value="My" />
<input type="hidden" name="last_name" value="Surname" />
<input type="hidden" name="address1" value="My Street">
<input type="hidden" name="address2" value="My Village">
<input type="hidden" name="city" value="My City">
<input type="hidden" name="zip" value="My Post Code">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="tax_rate" value="20.00" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="return" value="http://www.xxxxxxxx.co.uk/shop/payments/itempaymentreceived/24" />
<input type="hidden" name="cancel_url" value="http://www.xxxxxxxx.co.uk/shop/payments/paymentcancelled" />
<input type="hidden" name="notify_url" value="http://www.xxxxxxxx.co.uk/shop/payments/itemipn/24" />
<div class="form-group">
<input type="submit" class="btn btn-wide btn-primary" value="Pay Now" id="btnSubmit" name="btnSubmit"/>
</div>
</form>
I know it a case of not seeing the wood for the trees, but any pointer would be gratefully received.
Thanks
Trying to send multiple items to a paypal cart and having problems:
This (single item) works fine:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="xxx" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount" value="20.00" />
<input type="hidden" name="item_name" value="1st Item" />
<input type="image" src="addcart.gif" name="submit" alt="cart add" />
</form>
This (multiple items, seems to be suggested solution) fires an error on the cart page that reads "PayPal cannot process this transaction because of a problem with the seller's website. Please contact the seller directly to resolve this problem.":
<
form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="xxx" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount_1" value="20.00" />
<input type="hidden" name="item_name_1" value="1st Item" />
<input type="hidden" name="amount_2" value="20.00" />
<input type="hidden" name="item_name_2" value="2nd Item" />
<input type="image" src="addcart.gif" name="submit" alt="cart add" />
</form>
Two forms (below) work fine, but I am trying to get the submission done with one form and one click.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="xxx" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount" value="20.00" />
<input type="hidden" name="item_name" value="1st Item" />
<input type="image" src="addcart.gif" name="submit" alt="cart add" />
</form>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="xxx" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount" value="20.00" />
<input type="hidden" name="item_name" value="2nd Item" />
<input type="image" src="addcart.gif" name="submit" alt="cart add" />
</form>
If I use the following, it works fine, but it doesn't go to the cart page, rather a "Choose your way to pay" page
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="xxx" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount_1" value="20.00" />
<input type="hidden" name="item_name_1" value="1st Item" />
<input type="hidden" name="amount_2" value="20.00" />
<input type="hidden" name="item_name_2" value="2nd Item" />
<input type="image" src="addcart.gif" name="submit" alt="cart add" />
</form>
Any suggestions?
You would not be able to add multiple items to the cart at once, when using the add to cart button which is indicated by the following two lines of code.
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
You have to use the cart upload command, to be able to upload mutlipe items as once.
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
The reason that it does not take you to cart page, is this method is what you would be using if you were using a 3rd party cart, or a customized cart. If you are wanting to show the buyers what is in their cart, you would need to do this on your webiste prior to passing the data over to PayPal. On your website, they would add, remove or adjust the quantity and then when they are ready to checkout is when you would redirect the buyer over to PayPal to pay.
My site was working fine with PayPal's sandbox, and then all of a sudden it stopped.
Now I get the wonderful error Sandbox "Sorry — your last action could not be completed"
This is my HTML:
<body onload="document.Paypal.submit();">
<!-- item_number should get passed back -->
<form name="Paypal" method="post" action="https://www.sandbox.paypal.com cgi-bin/webscr" id="Paypal">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTkyNTEyNzc0NGRk0LKGvSMTla6LgHpbOsdk7iC0iXE=" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCALKhatPArLPtrsEAreImG4CweeH+AkCgMPhowcC+NaM4gQC+Y2VqwoCouzSnwEVXI9UvQxqI2UcdQ4SmcSWqfEZNw==" />
</div>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<!-- The following is for itemized PayPal data instead of the aggregated version -->
<input type="hidden" name="item_name_1" value="LEADING SKILLS 4/10/2012 6:00 PM Section: Members " />
<input type="hidden" name="amount_1" value="250.00" />
<input type="hidden" name="quantity_1" value="2" />
<input type="hidden" name="handling_cart" value="7.00" />
<input type="hidden" name="tax_cart" value="35.00" />
<!-- STANDARD DATA -->
<input name="business" type="hidden" id="business" value="paypal#rockclimbing.venueblue.com" />
<input name="invoice" type="hidden" id="invoice" value="TS-1E8B59A0-B" />
<input type="hidden" name="no_note" value="0" />
<input name="currency_code" type="hidden" id="currency_code" value="USD" />
<input name="shipCountry" type="hidden" id="shipCountry" />
<input type="hidden" name="return" value="http://rockclimbing.venueblue.com/Gateway/paypal/Complete.aspx?id=db86c0bf-beb8-4e37-b495-bed1d3e7e6f3" />
<input name="cancel_returnUrl" type="hidden" id="cancel_returnUrl" value="http://rockclimbing.venueblue.com/ShoppingCart.aspx" />
<input type="hidden" name="cn" value="How did you hear about us?" />
<input name="custom" type="hidden" id="custom" value="db86c0bf-beb8-4e37-b495-bed1d3e7e6f3" />
<input name="notify_url" type="hidden" id="notify_url" value="http://rockclimbing.venueblue.com/Gateway/Paypal/IPN.aspx" />
<input type="submit" value="Submit Payment Info" style="display:none;" />
Processing Order....
</form>
</body>
Anyone have a clue what happened?
Well i had the same thing today earlier, I thought i screwed smth up. I was using Opera, then changed to FireFox and there was no such error. then i deleted Browsing history, cookies, cash, everything and the problem disapeared in opera. maybe you could try that too.