This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Initial commit.

  • Loading branch information...
shantanusaini committed Sep 3, 2013
1 parent dae08e6 commit aaa94afdf64ba2cf885f871ec86800ccd80480ed
Showing with 746 additions and 180 deletions.
  1. +56 −0 CONTRIBUTING.md
  2. +190 −179 LICENSE
  3. +29 −1 README.md
  4. +22 −0 app.yaml
  5. +31 −0 css/style.css
  6. +53 −0 generate_token.php
  7. BIN images/cake.jpg
  8. +60 −0 index.php
  9. +167 −0 lib/JWT.php
  10. +105 −0 payload.php
  11. +33 −0 seller_info.php
View
@@ -0,0 +1,56 @@
+# How to become a contributor and submit your own code
+
+## Contributor License Agreements
+
+We'd love to accept your sample apps and patches! Before we can take them, we
+have to jump a couple of legal hurdles.
+
+Please fill out either the individual or corporate Contributor License Agreement
+(CLA).
+
+ * If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual CLA]
+ (http://code.google.com/legal/individual-cla-v1.0.html).
+ * If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA]
+ (http://code.google.com/legal/corporate-cla-v1.0.html).
+
+Follow either of the two links above to access the appropriate CLA and
+instructions for how to sign and return it. Once we receive it, we'll be able to
+accept your pull requests.
+
+## Contributing A Patch
+
+1. Sign a Contributor License Agreement, if you have not yet done so (see
+ details above).
+1. Create your change to the repo in question.
+ * Fork the desired repo, develop and test your code changes.
+ * Ensure that your code is clear and comprehensible.
+ * Ensure that your code has an appropriate set of unit tests which all pass.
+1. Submit a pull request.
+1. The repo owner will review your request. If it is approved, the change will
+ be merged. If it needs additional work, the repo owner will respond with
+ useful comments.
+
+## Contributing A New Sample App
+
+1. Sign a Contributor License Agreement, if you have not yet done so (see
+ details above).
+1. Create your own repo for your app following this naming convention:
+ * {platformapi}-{app-name}-{language}
+ * apps: quickstart, sample
+ * example: instantbuy-quickstart-java
+ * For multi-language apps, concatenate the primary languages like this:
+ instantbuy-sample-java-python.
+
+1. Create your sample app in this repo.
+ * Be sure to clone the README.md, CONTRIBUTING.md and LICENSE files from the
+ googlewallet repo.
+ * Ensure that your code is clear and comprehensible.
+ * Ensure that your code has an appropriate set of unit tests which all pass.
+ * Instructional value is the top priority when evaluating new app proposals for
+ this collection of repos.
+1. Submit a request to fork your repo in googlewallet organization.
+1. The repo owner will review your request. If it is approved, the sample will
+ be merged. If it needs additional work, the repo owner will respond with
+ useful comments.
View
369 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
30 README.md 100644 → 100755
@@ -1,4 +1,32 @@
+PHP Quick Start Sample for Digital Goods API Copyright (C) 2013 Google Inc.
+
digitalgoods-sample-php
=======================
-Basic PHP implementation of the Google Wallet for digital goods Subscription API.
+Basic PHP implementation of the Google Wallet for Digital Goods API.
+
+### Setup
+
+To setup the sample, edit seller_info.php.
+
+* Sign up for Google Wallet for digital goods. Then get your Seller Identifier and Seller Secret.
+ [Sign up for Wallet for digital goods (sandbox)](https://sandbox.google.com/checkout/inapp/merchant/signup.html)
+ [Sign up for Wallet for digital goods (production)](https://checkout.google.com/inapp/merchant/signup.html)
+* Replace $issuerId and $secretKey in seller_info.php with your Seller Identifier and Seller Secret.
+
+### Google appengine.
+
+To run application on google appengine requires [Google App Engine SDK](https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP) and PHP5.4+
+
+1. Create new application at your [appengine account](https://appengine.google.com).
+2. You need to register your application to be whitelisted before uploading it on appengine. To register your PHP application visit [https://gaeforphp.appspot.com]( https://gaeforphp.appspot.com).
+3. Change application name in app.yaml file.
+4. Follow instruction to install google appengine sdk and to upload the application on [Google Appengine for PHP Docs](https://developers.google.com/appengine/docs/php/gettingstarted/introduction).
+
+### Local dev.
+
+To run application on local server requires [apache HTTP server](http://apache.org/) 2.0 or greater and PHP5+.
+
+1. Make sure "allow_url_include" option is enabled in php.ini file.
+2. Copy the files to default DocumentRoot of the server.
+3. You can now visit http://localhost in your browser to see the application in action.
View
@@ -0,0 +1,22 @@
+application: APPLICATION_NAME
+version: 1
+runtime: php
+api_version: 1
+
+handlers:
+
+- url: /css
+ static_dir: css
+
+- url: /js
+ static_dir: js
+
+- url: /images
+ static_dir: images
+
+- url: /
+ script: index.php
+
+- url: /index.php
+ script: index.php
+
View
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2013 Google Inc. All Rights Reserved
+ */
+
+body {
+ font-family: Verdana;
+ font-size: 10pt;
+ text-align: center;
+}
+
+img {
+ border: 2px solid green;
+ display: block;
+ height:250px;
+ margin-left: auto;
+ margin-right: auto;
+ width: 250px;
+}
+
+.img-label {
+ font-family: COMIC SANS MS;
+ font-weight:bold;
+}
+
+.buy-button {
+ color: #7F5A58;
+ font-size: 15px;
+ font-weight: bold;
+ height:50px;
+ width: 150px;
+}
View
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Copyright 2013 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @author Rohit Panwar <panwar@google.com>
+ *
+ * This code is generating JWT of a product.
+ */
+
+/**
+ * JWT class to encode/decode payload into JWT format.
+ */
+include_once 'lib/JWT.php';
+/**
+ * Get merchant account information.
+ */
+include_once 'seller_info.php';
+/**
+ * Get payload of the product.
+ */
+include_once 'payload.php';
+
+$sellerIdentifier = SellerInfo::$issuerId;
+$sellerSecretKey = SellerInfo::$secretKey;
+
+$payload = new Payload();
+$payload->SetIssuedAt(time());
+$payload->SetExpiration(time()+3600);
+$payload->AddProperty('name', 'Piece of Cake');
+$payload->AddProperty('description',
+ 'Virtual chocolate cake to fill your virtual tummy');
+$payload->AddProperty('price', '10.50');
+$payload->AddProperty('currencyCode', 'USD');
+$payload->AddProperty('sellerData',
+ 'user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j');
+// Creating payload of the product.
+$Token = $payload->CreatePayload($sellerIdentifier);
+// Encoding payload into JWT format.
+$jwtToken = JWT::encode($Token, $sellerSecretKey);
View
Binary file not shown.
View
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * Copyright 2013 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @author Rohit Panwar <panwar@google.com>
+ *
+ * The sample application that demonstrates Google Wallet for Digital Goods API.
+ */
+
+include_once 'generate_token.php';
+
+echo <<< INDEX
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv='content-type' content='text/html; charset=UTF-8'>
+ <title>Digital Goods Sample Application</title>
+ <meta name='viewport' content='width=device-width, initial-scale=1,
+ maximum-scale=1'>
+ <script src="https://sandbox.google.com/checkout/inapp/lib/buy.js"></script>
+ <script type='text/javascript'>
+ function DemoButton(jwt_value) {
+ runDemoButton = document.getElementById('runDemoButton');
+ google.payments.inapp.buy({
+ jwt: jwt_value,
+ success: function() {console.log('success');},
+ failure: function(result) {console.log(result.response.errorType);}
+ });
+ return false;
+ }
+ </script>
+ <link href='css/style.css' rel='stylesheet' type='text/css' />
+</head>
+<body>
+<div>
+ <figure>
+ <img src='images/cake.jpg' /> <br /> <br />
+ <figcaption class='img-label'>
+ A Virtual chocolate cake to fill your virtual tummy </figcaption>
+ </figure>
+ <button id='runDemoButton' value='buy' class='buy-button'
+ onclick='DemoButton("$jwtToken");'><b>Purchase</b></button>
+</div>
+</body>
+</html>
+INDEX;
Oops, something went wrong.

0 comments on commit aaa94af

Please sign in to comment.