Git Product home page Git Product logo

parse-iap-verify's Introduction

parse-iap-verify

TLDR: Payment verification should be easy; now it is.

If you are trying to earn a living or build a product on mobile, you need to monetize it. Many applications utilize 'In App Purchases' as the primary method of monetization. The best way of verifying purchases is via a server to server communication with the store that the purchase was made from.

If you use Parse.com as your backend server, you can use Cloud Code to make those calls. While some stores offer fairly straight forward verification steps, others are more convoluted and poorly documented.

This module makes it quick and easy so you don't have to reinvent the wheel for every new project (or spend days digging through documentation and trying various things), just like Parse does for standard backend db access, user login, etc.

Setup

Parse Project

  • parse-iap-verify cloned into ParseCloud/cloud/iapVerify of your project repo (submodules are nice)
  • ParseCloud running Parse JavaScript SDK 1.3.0+ (to utilize Parse.Config)
  • Parse.Config object named googlePlayAuth w/ key values for clientID, clientSecret and refreshToken

Apple App Store

  • No special setup required

Google Play Store

  1. Open a beer... this is going to take a while.
  2. Create a Google API service account Sign Up
  3. Create a new Project
  4. Enable Google Play Developer API
  5. Create Credentials for this project (skip the automatic setup)
  • Choose New Credentials button)
  • Select OAuth Client ID
  • Select Web Application
  • Fill in: (NOTE: The redirect URI doesn't really matter, but a working site is nice)
    • Name
    • Authorized redirect URIs
  • Record the Client ID and Client Secrect
  1. Visit the following URL in a browser: https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=WEB_REDIRECT_URI&client_id=WEB_CLIENT_ID
  2. Click Allow & authenticate yourself
  3. Once you arrive at the redirect site, copy the URI out of the addres bar
  4. Copy down the 'code' parameter value at the end of the URI ?code="1/......."
  5. Retrieve a refresh token to use when verifying receipts (curl example follows)
  1. Create Parse.Config object named googlePlayAuth with above clientID, clientSecret and refreshToken
  2. Celebrate

##Usage

Only a single method is exposed to verify purchase receipts:

var iap = require('cloud/iapVerify');

var platform = 'apple';
var payment = {
    receipt: 'receipt data',        // must be base64 for Apple
    productId: '0001',
    packageName: 'com.company.app'
};

iap.verifyPayment(platform, payment);

// Returns a Promise w/ JSON result
// SUCCESS - status = 0, receipt information passed verification
// {    'status':0,
//   'productId':'0001',
//     'receipt':{store_specific_receipt_data} 
// }
// FAILURES
// {    'status':123,
//    extraError:'informational string'
// }

References

Apple References

API Reference

Google Play References

API Reference

Receipt Generation

##Thank You Kudos to:

Kalina for outlining the steps required for Android IAP verification. Many people tried, but yours were the only ones that actually worked!

Stackoverflow Post

Wizcorp for highlighting so many great IAP references and a nice API interface in their Node-IAP module

Nick Lockwood for all of the amazing contributions he has shared with the community

Parse for building such a great BaaS and making it so easy to create great mobile products with a strong server component quickly

##Contributing Use Github issues to track bugs and feature requests.

Licence

MIT

parse-iap-verify's People

Contributors

mobilevet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

parse-iap-verify's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.