Below is my code. I copied the interoperable access keys.. The client and secret both from the same page. I used client key in the ClientAccess ID in the form and secret for hashing.
But i get the error saying invalid argument.
Detail error being shown as "Cannot create buckets using a POST"
Below is the python code i used.
import webapp2
import cgi
import datetime
import urllib
import base64
import hmac, hashlib
import sha
policy_document = '''{"expiration": "2016-06-16T11:11:11Z",
"conditions": [
["starts-with", "$key", "" ],
{"acl": "public-read" },
]
}'''
policy = base64.b64encode(policy_document).strip()
h = hmac.new('xxx', digestmod=sha.sha)
h.update(policy)
signature = base64.b64encode(h.digest())
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('<html><body>')
self.response.write('<form action="http://storage.googleapis.com/www.xyz.com" method="post" enctype="multipart/form-data">')
self.response.write('<input type="text" name="key" value="">')
self.response.write('<input type="hidden" name="bucket" value="www.xyz.com">')
#self.response.write('<input type="hidden" name="Content-Type" value="image/jpeg">')
self.response.write('<input type="hidden" name="GoogleAccessId" value="GOOGxxxxx">')
self.response.write('<input type="hidden" name="acl" value="public-read">')
self.response.write('<input type="hidden" name="success_action_redirect" value="http://www.linklip.com/storage.html">')
self.response.write('<input type="hidden" name="policy" value="%s">' % policy )
self.response.write('<input type="hidden" name="signature" value="%s">' % signature )
self.response.write('<input name="file" type="file">')
self.response.write('<input type="submit" value="Upload">')
self.response.write('</form>')
self.response.write('</body></html>')
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
I had the same issue, and after trying to be as close as possible to the documentation, I found that what was wrong is that my file input was the first child of the form instead of at the end.
Does not work:
<form action="https://***.storage.googleapis.com" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="hidden" name="signature" value="***" />
<input type="hidden" name="key" value="test/alexis.png" />
<input type="hidden" name="policy" value="***" />
<input type="hidden" name="Content-Type" value="image/png" />
<input type="hidden" name="GoogleAccessId" value="***#developer.gserviceaccount.com" />
<input type="hidden" name="bucket" value="***" />
<input type="hidden" name="success_action_status" value="201" />
<input type="submit" value="Upload">
</form>
Works:
<form action="https://***.storage.googleapis.com" method="post" enctype="multipart/form-data">
<input type="hidden" name="signature" value="***" />
<input type="hidden" name="key" value="test/alexis.png" />
<input type="hidden" name="policy" value="***" />
<input type="hidden" name="Content-Type" value="image/png" />
<input type="hidden" name="GoogleAccessId" value="***#developer.gserviceaccount.com" />
<input type="hidden" name="bucket" value="***" />
<input type="hidden" name="success_action_status" value="201" />
<input type="file" name="file" />
<input type="submit" value="Upload">
</form>
I'm still puzzled about why it works this way and not the other...
To create a bucket, you need to perform an HTTP PUT:
https://developers.google.com/storage/docs/reference-methods#putbucket
Your form method is set to 'POST'.
I found the answer for the above problem.
self.response.write('<input type="hidden" name="bucket" value="www.xyz.com">')
In the value, i tried value="Bucket/filename-i-want-to-put" and i was able to see file created in the bucket.
Solution for me was to add <input type="hidden" name="key" value="${filename}">.
<form action="http://container-name.storage.googleapis.com" method="POST" enctype="multipart/form-data">
<input type="hidden" name="acl" value="public-read">
<input type="hidden" name="Content-Type" value="application/pdf">
<input type="hidden" name="key" value="${filename}">
<input type="hidden" name="bucket" value="container-name">
<input type="hidden" name="GoogleAccessId" value="XXXXXXXXX">
<input type="hidden" name="policy" value="XXXXXXXXXXXXXXXXXXXXXXX=">
<input type="hidden" name="signature" value="XXXXXX==">
<input type="file" name="file" />
<input type="submit" value="Upload">
<form>
See Upload file using POST/PUT Object of Google Cloud Storage HTML Form.
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
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.
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.