title: How to use Google Wallet without Ajax rather like Paypal with submitting a form?
body: <p>I already use PayPal on my website as it does a php header redirect to submit the page and redirects me to paypal shopping cart. They don't support ajax, if you search for PayPal with ajax you will find cheap looking shopping carts which in the end still do a redirect to paypal which is pretty stupid.</p>
  
  <p>On the other hand Google Wallet doesn't support from my research the old way of doing this with submitting forms to open a Google Wallet shopping cart page..</p>
  
  <p>I want to make them both work without ajax as I want them both to use the same form code.</p>
  
  <p>Anyway to use Google Wallet without this AJAX javascript
  <a href="https://sandbox.google.com/checkout/inapp/lib/buy.js" rel="nofollow">https://sandbox.google.com/checkout/inapp/lib/buy.js</a></p>
  
  <p>How would I be able to do something like this</p>
  
  <pre><code>&lt;form method="POST" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/123456789123456" accept-charset="utf-8"&gt;
  </code></pre>
  
  <p>This code above is what Google Checkout used before they retired it and forced everyone to use Google Wallet instead.</p>
  
  <p>I understand they are trying to make everything work of AJAX now but they must have some kind of legacy support for the old form method right?</p>
  
  <p>I understand the new Google Wallet requires you to generate some kind of token which is a Base64 encoded with sha256 hash based message authentication code packet which has also has expiration date you set.</p>
  
  <p><a href="https://code.google.com/p/iap-php/source/browse/#git%2Fiap-php%2Fsrc" rel="nofollow">https://code.google.com/p/iap-php/source/browse/#git%2Fiap-php%2Fsrc</a></p>
  
  <p>Example code for Google Wallet: <a href="http://iap-php.appspot.com/" rel="nofollow">http://iap-php.appspot.com/</a></p>
  
  <p>But I don't see any way to use this with a website redirect, I went with maybe if I sniff the packet I couldn't figure anything out it's all encrypted probably SSL. I don't understand how <a href="https://sandbox.google.com/checkout/inapp/lib/buy.js" rel="nofollow">buy.js</a> works either but I figured out it uses <a href="https://sandbox.google.com/checkout" rel="nofollow">https://sandbox.google.com/checkout</a> which I could probably somehow make into a form? I will have no problem generating the token etc.. as my form first redirects to my own script which sets up the redirection to either paypal cart or google checkout.</p>
  
  <p>Here is how I got my code so far</p>
  
  <pre><code>&lt;form method="POST" action="checkout.php" id="buyForm"&gt;
     All Fields in here
     submit button value="Paypal"
     submit button value="Google"
  &lt;/form&gt;
  </code></pre>
  
  <p>my checkout.php uses like</p>
  
  <pre><code>&lt;?php
    if(isset($_POST['submit']) &amp;&amp; $_POST['submit'] == "PayPal") {
      //Generates all the variables for posting the redirect to PayPal
      $query['cmd'] = '_xclick';
      //Lots of other $query['stuff'] = 'otherstuff'; here
      // Prepare query string
      $query_string = http_build_query($query,'','&amp;');
      header('Location: https://www.paypal.com/cgi-bin/webscr?' . $query_string);
    } else if(isset($_POST['submit']) &amp;&amp; $_POST['submit'] == "Google") {
       //Do the same code as for paypal... with header redirect (no ajax bs)
  
       //I guessed the below of course it doesn't work
       header('Location: https://sandbox.google.com/checkout?' . $query_string);
    }
  ?&gt;
  </code></pre>