GithubHelp home page GithubHelp logo

morphinewan / firebase-function-iap-verification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zsafder/firebase-function-iap-verification

0.0 0.0 0.0 6 KB

Google and iOS IAP Verification Using Firebase Function and FireCloud

JavaScript 100.00%

firebase-function-iap-verification's Introduction

InApp Billing Verification Handler

InApp Purchase and Subscription for Apple, Google Play, Amazon Store, Roku, and Windows Verification Handler in Firebase Functions using popular node in-app-purchase module https://github.com/voltrue2/in-app-purchase

Resources Required

Setup Guide

Setup for Android

To set up purchase verification, follow these steps.

  1. Log in to the Google API console with your credentials
  2. Under Select a project find your app's project
  3. Select your organization, application, then OPEN
  4. Select API Credentials > Credentials > Create credentials
  5. From the drop-down menu, select Service account key
  6. Select an existing service account or create a new one
  7. Select JSON as your Key type
  8. Select Project > Viewer as your Role from the drop-down menu
  9. Select Create

Now, a JSON key will be downloaded to your computer. Next, follow these steps to complete the setup.

  1. Go to the Google Play Store and log in
  2. Select Settings
  3. Select Developer account > API access
  4. Find your application project and select LINK
  5. Under Service Accounts, on the relevant email address, select GRANT ACCESS
  6. In the Add a new user dialogue, select Finance from the Role drop-down menu
    • If you want this user to have global access, select ADD USER
    • If you want this user to have access only to one app, select Add an app, then ADD USER
  7. Navigate to Developer account > Users & permissions to view information on your users and access permissions

Great job! Purchase verification is now active for Android.

Setup for iOS

Nothing Special Need to be Done For iOS.

Setup Other Platforms

Refer https://github.com/voltrue2/in-app-purchase for other platform setup

Integration Guide

Integration Google IAP

  1. Copy Base64 public key string from the Developer Console account for your application in file ./functions/google/iap-live and ./functions/google/iap-sandbox

  2. replace ./functions/google/api-test.json with you private key (created in the setup process)

  3. Open ./function/index.js and replace

    let serviceAccount = require("./google/api-test.json");

    with

    let serviceAccount = require("./google/<your_private_key_name>.json");

Integration Google Subscription

provide following credentails that you have acquired in setup process

  • googleAccToken
  • googleRefToken
  • googleClientID
  • googleClientSecret

Integration iOS IAP

Nothing Special Need to be Done For iOS.

Integration iOS Subscription

provide following credentails that you have acquired in setup process

Integration Other Platforms

Refer https://github.com/voltrue2/in-app-purchase for other platform setup

Project Setup

You have two option here

  1. Setup a new Firebase Project and replace functions folder content
  2. Project Firebase Application Id in .firebaserc json under 'default' key

That is it! Deploy on Firebase Function

Usage Instructions

Url

<firebase_function_baseurl>/verifyInAppPurchase

Method

POST

Header

Content-Type: application/json

Params

type=[string] (apple/google)
transactionId=[string]
receipt=[string|json] (refer https://github.com/voltrue2/in-app-purchase for detail)

Success Response

Code: 200
Content: Verified

Error Response

Code: 400
Content: Invalid Request | Duplicate Transaction | Invalid TransactionId | Item is Canelled

Sample Format iOS

curl --location --request POST 'https://<firebase_function_baseurl>/verifyInAppPurchase' \
--header 'Content-Type: application/json' \
--data-raw '{"receipt":"<recipt>", "transactionId":"<transcation_id>", "type":"apple"}'

Sample Format Android

curl --location --request POST 'https://<firebase_function_baseurl>/verifyInAppPurchase' \
--header 'Content-Type: application/json' \
--data-raw '{"receipt":{"packageName": <package_name>, "productId": <product_id>, "purchaseToken":<purchase_token>}, "transactionId":"<purchase_token>", "type":"google"}'

Happy Coding

firebase-function-iap-verification's People

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.