├── .env.example ├── .gitignore ├── .travis.yml ├── LICENSE ├── Procfile ├── README.md ├── app.js ├── app.json ├── package.json ├── public ├── css │ └── index.css ├── images │ ├── App.png │ ├── App_Create_1.png │ ├── App_Create_2.png │ └── App_Create_3.png ├── index.html └── js │ └── index.js └── views ├── Ratesample.png ├── Thumbdown.png └── Thumbup.png /.env.example: -------------------------------------------------------------------------------- 1 | # Environment Variables. 2 | 3 | 4 | PAYMENT_ENVIRONMENT= Sandbox 5 | PORT= 6 | NGROK_ENABLED= true 7 | TOKEN_URL= https://sandbox.api.intuit.com/quickbooks/v4/payments/tokens 8 | CHARGE_URL= https://sandbox.api.intuit.com/quickbooks/v4/payments/charges 9 | ACCESS_TOKEN= <> 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | 17 | # Bower dependency directory (https://bower.io/) 18 | bower_components 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directories 27 | node_modules/ 28 | jspm_packages/ 29 | 30 | # Typescript v1 declaration files 31 | typings/ 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional eslint cache 37 | .eslintcache 38 | 39 | # Optional REPL history 40 | .node_repl_history 41 | 42 | # Output of 'npm pack' 43 | *.tgz 44 | 45 | # Yarn Integrity file 46 | .yarn-integrity 47 | 48 | # dotenv environment variables file 49 | .env 50 | 51 | # config variables 52 | config.json 53 | 54 | # idea files 55 | .idea/ 56 | 57 | # DS Store files 58 | .DS_Store 59 | 60 | # package 61 | package-lock.json -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 7 5 | - 6 6 | 7 | 8 | before_script: 9 | - npm install 10 | script: 11 | - node app.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Rate your Sample](views/Ratesample.png)][ss1][![Yes](views/Thumbup.png)][ss2][![No](views/Thumbdown.png)][ss3] 2 | 3 | Intuit Payment Sample - NodeJS 4 | ========================================================== 5 | 6 | ## Overview 7 | 8 | This is a `Sample` app built using Node.js and Express Framework to showcase how to make API calls using the [Intuit-Payment API's](https://developer.intuit.com/docs/00_quickbooks_payments/2_build/20_explore_the_quickbooks_payments_api) 9 | 10 | ![APP screenshots](public/images/App.png) 11 | 12 | 13 | ## Installation 14 | 15 | ### Requirements 16 | 17 | * [Node.js](http://nodejs.org) >= 8.x. 18 | * [Intuit Developer](https://developer.intuit.com) Account 19 | 20 | ### Via Github Repo (Recommended) 21 | 22 | ```bash 23 | $ git clone https://github.com/IntuitDeveloper/SampleApp-Payments-Nodejs 24 | $ cd SampleApp-Payments-Nodejs 25 | $ npm install 26 | ``` 27 | 28 | 29 | ## Pre-requisites 30 | 31 | ### Create an App 32 | * **Create an Intuit Developer account and app**: 33 | You must have an Intuit Developer account and have created an app. To know more refer to [Get Started](https://developer.intuit.com/docs/00_quickbooks_online/1_get_started/00_get_started) 34 | * **Create an App with Payment Scope**: 35 | Login to [Developer Portal](https://developer.intuit.com) and click on `My Apps` on the top right corner and create an App as shown below 36 | ![APP screenshots1](public/images/App_Create_1.png) 37 | Select the `Payments` scope while creating the app. 38 | ![APP screenshots2](public/images/App_Create_2.png) 39 | 40 | 41 | ### Get Access Token from OAuth Playground 42 | * **Get AccessToken**: 43 | Use [OAuth Playground](https://developer.intuit.com/v2/ui#/playground) to get the OAuth2.0 accessToken from the app you just created above. 44 | Note: Please make sure to select Payment Scope 45 | ![APP screenshots3](public/images/App_Create_3.png) 46 | 47 | ## Configuration 48 | 49 | Copy the contents from `.env.example` to `.env` from the root directory: 50 | ```bash 51 | $ cp .env.example .env 52 | ``` 53 | Edit the `.env` file to add your: 54 | 55 | * **ACCESS_TOKEN:** You can generate `accessToken` using the [OAuth Playground](https://developer.intuit.com/v2/ui#/playground) 56 | * **NGROK_ENABLED:(optional)** By default it is set to `false`. If you want to serve the Sample App over HTTPS, set the variable to `true` 57 | * **PORT:(optional)** Optional port number for the app to be served 58 | 59 | ** Please note, that we are testing this Sample in **Sandbox Environment**. To test in Production please use the below `.env` variables: 60 | * TOKEN_URL=`https://sandbox.api.intuit.com/quickbooks/v4/payments/tokens` 61 | * CHARGE_URL=`https://sandbox.api.intuit.com/quickbooks/v4/payments/charges` 62 | 63 | 64 | 65 | ### TLS / SSL (**optional**) 66 | 67 | If you want your enpoint to be exposed over the internet. The easiest way to do that while you are still developing your code locally is to use [ngrok](https://ngrok.com/). 68 | 69 | You dont have to worry about installing ngrok. The sample application does that for you. 70 | 1. Just set `NGROK_ENABLED` = `true` in `.env` 71 | 72 | 73 | ## Usage 74 | 75 | ```bash 76 | $ npm start 77 | ``` 78 | 79 | ### Without ngrok (if you are using localhost i.e `NGROK_ENABLED`=`false` in `.env`) 80 | You will see an URL as below: 81 | ```bash 82 | 💻 Server listening on port 8000 83 | 💳 See the Sample App in your browser: http://localhost:8000 84 | ``` 85 | 86 | 87 | ### With ngrok (if you are using ngrok i.e `NGROK_ENABLED`=`true` in `.env`) 88 | 89 | Your will see an URL as below : 90 | ```bash 91 | 💻 Server listening on port 8000 92 | 💳 See the Sample App in your browser: https://9b4ee833.ngrok.io 93 | ``` 94 | 95 | Click on the URL and follow through the instructions given in the sample app. 96 | 97 | 98 | ### Running `Sample-Payments-Nodejs App` on Heroku 99 | 100 | If you already have an Heroku account, you can use [Heroku One-Button Deployment](https://devcenter.heroku.com/articles/heroku-button) to deploy this sample and test it right away. 101 | 102 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 103 | 104 | 105 | Unable to follow ? Please use the link below to follow the step by step procedure to get started with this sample: 106 | 107 | [![Instructions to Get Started with this Sample App]()](https://www.youtube.com/watch?v=Q4pSndbcY_E&feature=youtu.be) 108 | 109 | 110 | ## Links 111 | 112 | Project Repo 113 | 114 | * https://github.com/IntuitDeveloper/SampleApp-Payments-Nodejs 115 | 116 | Intuit Payment API Reference 117 | 118 | * https://developer.intuit.com/docs/api/payments 119 | 120 | Intuit Payments API Explorer 121 | 122 | * https://developer.intuit.com/v2/apiexplorer?apiname=Payments 123 | 124 | ## Contributions 125 | 126 | Any reports of problems, comments or suggestions are most welcome. 127 | 128 | Please report these on [Issue Tracker in Github](https://github.com/IntuitDeveloper/SampleApp-Payments-Nodejs/issues). 129 | 130 | [ss1]: # 131 | [ss2]: https://customersurveys.intuit.com/jfe/form/SV_9LWgJBcyy3NAwHc?check=Yes&checkpoint=SampleApp-Payments-Nodejs&pageUrl=github 132 | [ss3]: https://customersurveys.intuit.com/jfe/form/SV_9LWgJBcyy3NAwHc?check=No&checkpoint=SampleApp-Payments-Nodejs&pageUrl=github 133 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('dotenv').config(); 4 | 5 | const express = require('express'); 6 | const request = require('request'); 7 | const app = express(); 8 | const path = require('path'); 9 | const bodyParser = require('body-parser'); 10 | const uuidv1 = require('uuid/v1'); 11 | const ngrok = (process.env.NGROK_ENABLED==="true") ? require('ngrok'):null; 12 | 13 | 14 | app.use(bodyParser.urlencoded({extended: true})); 15 | app.use(express.static(path.join(__dirname, '/public'))); 16 | app.engine('html', require('ejs').renderFile); 17 | app.set('view engine', 'html'); 18 | app.use(bodyParser.json()) 19 | 20 | var urlencodedParser = bodyParser.urlencoded({ extended: false }); 21 | var chargeID=''; 22 | 23 | app.use(express.static('views')); 24 | 25 | app.get('/', function(req, res) { 26 | 27 | // Render home page with params 28 | res.render('index'); 29 | }); 30 | 31 | app.post('/authorizePurchase', urlencodedParser, function(req,res) { 32 | 33 | var postBody = { 34 | url: process.env.CHARGE_URL, 35 | headers: { 36 | 'Content-Type': 'application/json', 37 | 'Request-Id' : uuidv1(), 38 | 'Authorization' : 'Bearer ' + process.env.ACCESS_TOKEN 39 | }, 40 | body: req.body.json, 41 | json: true 42 | }; 43 | 44 | request.post(postBody, function (err, response) { 45 | chargeID = response.body.id; 46 | res.send(response.body); 47 | }); 48 | 49 | 50 | }); 51 | 52 | app.post('/captureCharge', urlencodedParser, function(req,res) { 53 | 54 | var postBody = { 55 | url: process.env.CHARGE_URL +'/'+ chargeID +'/capture', 56 | headers: { 57 | 'Content-Type': 'application/json', 58 | 'Request-Id' : uuidv1(), 59 | 'Authorization' : 'Bearer ' + process.env.ACCESS_TOKEN 60 | }, 61 | body: req.body.json, 62 | json: true 63 | }; 64 | 65 | request.post(postBody, function (err, response, data) { 66 | res.send(response.body); 67 | }); 68 | 69 | }); 70 | 71 | 72 | // Start server on HTTP 73 | const server = app.listen(process.env.PORT || 8001, () => { 74 | console.log(`💻 Server listening on port ${server.address().port}`); 75 | if(!ngrok){ 76 | console.log(`💳 See the Sample App in your browser: ` + 'http://localhost:' + `${server.address().port}`); 77 | } 78 | 79 | }); 80 | 81 | // Turn on the ngrok tunnel in development, which provides both the mandatory HTTPS support for all card payments 82 | if (ngrok) { 83 | console.log("NGROK Enabled"); 84 | ngrok.connect( 85 | { 86 | addr: process.env.PORT || 8000, 87 | subdomain: '', 88 | authtoken: '', 89 | }, 90 | (err, url) => { 91 | if (err) { 92 | if (err.code === 'ECONNREFUSED') { 93 | console.log(`Connection refused at ${err.address}:${err.port}`); 94 | } else { 95 | console.log(`⚠️ ${err}`); 96 | } 97 | process.exit(1); 98 | } else { 99 | console.log(`💳 See the Sample App in your browser: ${url}`); 100 | } 101 | } 102 | ); 103 | } -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SampleApp-Payments-Nodejs", 3 | "description": "A sample Nodejs application to demonstrate Inutit Payment API's", 4 | "repository": "https://github.com/IntuitDeveloper/SampleApp-Payments-nodejs.git", 5 | "keywords": [ 6 | "Intuit", 7 | "IntuitPaymentAPI", 8 | "IntuitDev" 9 | ], 10 | "scripts": { 11 | "postdeploy": "npm install" 12 | }, 13 | "formation": [ 14 | { 15 | "process": "web", 16 | "quantity": 1 17 | } 18 | ], 19 | "website": "https://developer.intuit.com", 20 | "env": { 21 | "PORT": { 22 | "description": "The port on which you want to run the app ", 23 | "required": false 24 | }, 25 | "TOKEN_URL": { 26 | "description": "The URL to get the tokens", 27 | "required": true 28 | }, 29 | "CHARGE_URL": { 30 | "description": "The URL to create Charge'", 31 | "required": true 32 | }, 33 | "ACCESS_TOKEN": { 34 | "description": "AccessToken from the OAuthPlayground", 35 | "required": true 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SampleApp-Payments-Nodejs", 3 | "version": "0.0.1", 4 | "description": "A sample Nodejs application to demonstrate Inutit Payment API's", 5 | "scripts": { 6 | "start": "node app", 7 | "test": "./node_modules/mocha/bin/mocha test/**/*-test.js --reporter spec" 8 | }, 9 | "author": "anil_kumar3", 10 | "license": "MIT", 11 | "homepage": "https://github.com/IntuitDeveloper/SampleApp-Payments-nodejs", 12 | "dependencies": { 13 | "body-parser": "latest", 14 | "dotenv": "^5.0.1", 15 | "ejs": "^2.5.2", 16 | "express": "^4.14.0", 17 | "express-session": "^1.14.2", 18 | "request": "^2.78.0", 19 | "save": "^2.3.2", 20 | "uuid": "^3.3.2" 21 | }, 22 | "devDependencies": { 23 | "ngrok": "^2.2.9" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /public/css/index.css: -------------------------------------------------------------------------------- 1 | /*@import "compass"; */ 2 | .stepper .nav-tabs { 3 | position: relative; 4 | } 5 | .stepper .nav-tabs > li { 6 | width: 25%; 7 | position: relative; 8 | } 9 | .stepper .nav-tabs > li:after { 10 | content: ''; 11 | position: absolute; 12 | background: #f1f1f1; 13 | display: block; 14 | width: 100%; 15 | height: 5px; 16 | top: 30px; 17 | left: 50%; 18 | z-index: 1; 19 | } 20 | .stepper .nav-tabs > li.completed::after { 21 | background: #34bc9b; 22 | } 23 | .stepper .nav-tabs > li:last-child::after { 24 | background: transparent; 25 | } 26 | .stepper .nav-tabs > li.active:last-child .round-tab { 27 | background: #34bc9b; 28 | } 29 | .stepper .nav-tabs > li.active:last-child .round-tab::after { 30 | content: '✔'; 31 | color: #fff; 32 | position: absolute; 33 | left: 0; 34 | right: 0; 35 | margin: 0 auto; 36 | top: 0; 37 | display: block; 38 | } 39 | .stepper .nav-tabs [data-toggle='tab'] { 40 | width: 25px; 41 | height: 25px; 42 | margin: 20px auto; 43 | border-radius: 100%; 44 | border: none; 45 | padding: 0; 46 | color: #f1f1f1; 47 | } 48 | .stepper .nav-tabs [data-toggle='tab']:hover { 49 | background: transparent; 50 | border: none; 51 | } 52 | .stepper .nav-tabs > .active > [data-toggle='tab'], .stepper .nav-tabs > .active > [data-toggle='tab']:hover, .stepper .nav-tabs > .active > [data-toggle='tab']:focus { 53 | color: #34bc9b; 54 | cursor: default; 55 | border: none; 56 | } 57 | .stepper .tab-pane { 58 | position: relative; 59 | padding-top: 50px; 60 | } 61 | .stepper .round-tab { 62 | width: 25px; 63 | height: 25px; 64 | line-height: 22px; 65 | display: inline-block; 66 | border-radius: 25px; 67 | background: #fff; 68 | border: 2px solid #34bc9b; 69 | color: #34bc9b; 70 | z-index: 2; 71 | position: absolute; 72 | left: 0; 73 | text-align: center; 74 | font-size: 14px; 75 | } 76 | .stepper .completed .round-tab { 77 | background: #34bc9b; 78 | } 79 | .stepper .completed .round-tab::after { 80 | content: '✔'; 81 | color: #fff; 82 | position: absolute; 83 | left: 0; 84 | right: 0; 85 | margin: 0 auto; 86 | top: 0; 87 | display: block; 88 | } 89 | .stepper .active .round-tab { 90 | background: #fff; 91 | border: 2px solid #34bc9b; 92 | } 93 | .stepper .active .round-tab:hover { 94 | background: #fff; 95 | border: 2px solid #34bc9b; 96 | } 97 | .stepper .active .round-tab::after { 98 | display: none; 99 | } 100 | .stepper .disabled .round-tab { 101 | background: #fff; 102 | color: #f1f1f1; 103 | border-color: #f1f1f1; 104 | } 105 | .stepper .disabled .round-tab:hover { 106 | color: #4dd3b6; 107 | border: 2px solid #a6dfd3; 108 | } 109 | .stepper .disabled .round-tab::after { 110 | display: none; 111 | } 112 | 113 | #main { 114 | margin: 10px auto; 115 | } 116 | 117 | .payment-sample { 118 | display: flex; 119 | flex-direction: row; 120 | align-items: center; 121 | background: #193048; 122 | } 123 | 124 | /*body { margin:50px auto; width:600px;}*/ 125 | 126 | /* CSS for Credit Card Payment form */ 127 | .credit-card-box .panel-title { 128 | display: inline; 129 | font-weight: bold; 130 | } 131 | .credit-card-box .form-control.error { 132 | border-color: red; 133 | outline: 0; 134 | box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(255,0,0,0.6); 135 | } 136 | .credit-card-box label.error { 137 | font-weight: bold; 138 | color: red; 139 | padding: 2px 8px; 140 | margin-top: 2px; 141 | } 142 | .credit-card-box .payment-errors { 143 | font-weight: bold; 144 | color: red; 145 | padding: 2px 8px; 146 | margin-top: 2px; 147 | } 148 | .credit-card-box label { 149 | display: block; 150 | } 151 | /* The old "center div vertically" hack */ 152 | .credit-card-box .display-table { 153 | display: table; 154 | } 155 | .credit-card-box .display-tr { 156 | display: table-row; 157 | } 158 | .credit-card-box .display-td { 159 | display: table-cell; 160 | vertical-align: middle; 161 | width: 50%; 162 | } 163 | /* Just looks nicer */ 164 | .credit-card-box .panel-heading img { 165 | min-width: 180px; 166 | } 167 | 168 | .result-section { 169 | margin:0px -2px 0px 0px; 170 | height:200px; 171 | width:200px; 172 | overflow-y: scroll; 173 | } 174 | 175 | #textarea { 176 | left:100px; 177 | top:-60px; 178 | vertical-align: middle; 179 | white-space: normal; 180 | text-align: justify; 181 | -moz-text-align-last: center; /* Firefox 12+ */ 182 | text-align-last: center; 183 | display: block; 184 | margin-left: auto; 185 | margin-right: auto; 186 | } 187 | 188 | .col-xs-12 col-md-4 { 189 | margin: 0 auto; 190 | left: 50px; 191 | } 192 | 193 | .intuit-payment-demo { 194 | float:right; 195 | color:white; 196 | padding-top: 18px; 197 | padding-right: 16px; 198 | font-size: 30px; 199 | } 200 | .qblogo { 201 | width:250px; 202 | } 203 | 204 | .emulateSandbox { 205 | margin: 0 auto; 206 | left: 50px; 207 | padding-left: 120px; 208 | } 209 | 210 | .dl-horizontal dt { 211 | text-align: left !important; 212 | } 213 | 214 | .dl-horizontal dd { 215 | margin-left: 200px !important; 216 | } -------------------------------------------------------------------------------- /public/images/App.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/public/images/App.png -------------------------------------------------------------------------------- /public/images/App_Create_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/public/images/App_Create_1.png -------------------------------------------------------------------------------- /public/images/App_Create_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/public/images/App_Create_2.png -------------------------------------------------------------------------------- /public/images/App_Create_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/public/images/App_Create_3.png -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Intuit Payments Sample 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 |

Intuit Payment Demo - Javascript

26 | 27 |
28 |
29 |
30 |
31 | 53 |
54 |
55 |
56 | 57 |
58 |

Click here to emulate credit card numbers in sandbox

59 |
60 | 61 |

1. Create Token :

62 | 63 |
64 |
65 |
66 |

Payment Details

67 |
68 | 69 |
70 |
71 |
72 |
73 | 74 |
75 |
76 |
77 | 78 |
79 | 88 | 89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | 97 | 106 |
107 |
108 |
109 |
110 | 111 | 120 |
121 |
122 |
123 | 124 |
125 |
126 |
127 | 128 | 129 |
130 |
131 |
132 |
133 |
134 |
135 | 136 | 137 |
138 |
139 |
140 |
141 |
142 |
143 | 144 | 145 |
146 |
147 | 148 |
149 |
150 | 151 | 152 |
153 |
154 |
155 | 156 |
157 |
158 |
159 | 160 |
161 |
162 | 217 |
218 |
219 |
220 |
221 | 222 |
223 |
224 | 225 | 226 |
227 |
228 |
229 | 230 |
231 |
232 |
233 | 234 |
235 |
236 | 237 |
238 |
239 | 240 | 241 | 242 |
243 |
244 |
245 |

JSON Payload

246 | 247 |
248 |
249 |

TOKEN

250 | 251 |
252 |
253 |
254 | 255 |
    256 |
  • 257 | Next 258 |
  • 259 |
260 |
261 |
262 |
263 | 264 | 266 |
267 |

2. Authorize Purchase

268 | 269 | 270 |
271 |
272 |
273 |
274 |
275 |
276 | 277 |
278 | 287 | 288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 | 296 | 377 |
378 |
379 |
380 | 381 | 382 | 383 |
384 |
385 |
386 | 387 | 388 |
389 |
390 |
391 | 392 |
393 |
394 | 395 |
396 |
397 | 402 |
403 |
404 |
405 | 406 | 407 | 408 |
409 | 410 |
411 |
412 |

API Response

413 | 414 |
415 |
416 | 417 |
418 | 419 |
    420 |
  • 421 | Back 422 |
  • 423 |
  • 424 | Next 425 |
  • 426 |
427 |
428 |
429 |
430 | 431 | 433 |
434 | 435 |

3. Capture the Charge

436 | 437 |
438 |
439 |
440 |
441 |
442 |
443 | 444 |
445 | 454 | 455 |
456 |
457 |
458 |
459 | 460 | 461 |
462 |
463 | 464 |
465 |
466 | 471 |
472 |
473 |
474 | 475 | 476 | 477 |
478 |
479 |
480 |

API Response

481 | 482 |
483 | 484 |
485 | 486 |
487 | 488 | 496 |
497 |
498 |

4. All done!

499 |

You have successfully completed all steps.


500 |

Explore more on the Payment API's :


501 |
502 |
API Explorer
503 |
Be sure you review our API Explorer
504 |
Postman
505 |
Postman is a powerful HTTP client for testing the QuickBooks Payments API
506 |
Making calls with REST API
507 |
Here is a quick reference of REST API essentials that will help you get going with the QuickBooks Payments API.
508 |
Subscription States
509 |
Click here to know more about Subscription states.
510 |
Error Codes
511 |
Click here to know more about Error Codes.
512 |
Sample Apps and Code
513 |
The following sample apps are available for the Payments API : samples
514 |
Tutorials
515 |
These tutorials focus on specific ways to use the Payments API, including how to process credit card payments on your eCommerce website or set up online processing for your customer's site.
516 |
517 |
518 |
519 | 520 |
521 |
522 |
523 |
524 | 525 |
526 | 527 | 528 | 529 | -------------------------------------------------------------------------------- /public/js/index.js: -------------------------------------------------------------------------------- 1 | /*jslint browser: true*/ 2 | /*global $, jQuery, alert*/ 3 | (function($) { 4 | 'use strict'; 5 | 6 | $(function() { 7 | 8 | $(document).ready(function() { 9 | function triggerClick(elem) { 10 | $(elem).click(); 11 | } 12 | var $progressWizard = $('.stepper'), 13 | $tab_active, 14 | $tab_prev, 15 | $tab_next, 16 | $btn_prev = $progressWizard.find('.prev-step'), 17 | $btn_next = $progressWizard.find('.next-step'), 18 | $tab_toggle = $progressWizard.find('[data-toggle="tab"]'), 19 | $tooltips = $progressWizard.find('[data-toggle="tab"][title]'); 20 | 21 | 22 | //Initialize tooltips 23 | $tooltips.tooltip(); 24 | 25 | //Wizard 26 | $tab_toggle.on('show.bs.tab', function(e) { 27 | var $target = $(e.target); 28 | 29 | if (!$target.parent().hasClass('active, disabled')) { 30 | $target.parent().prev().addClass('completed'); 31 | } 32 | if ($target.parent().hasClass('disabled')) { 33 | return false; 34 | } 35 | }); 36 | 37 | $btn_next.on('click', function() { 38 | $tab_active = $progressWizard.find('.active'); 39 | 40 | $tab_active.next().removeClass('disabled'); 41 | 42 | $tab_next = $tab_active.next().find('a[data-toggle="tab"]'); 43 | triggerClick($tab_next); 44 | 45 | }); 46 | $btn_prev.click(function() { 47 | $tab_active = $progressWizard.find('.active'); 48 | $tab_prev = $tab_active.prev().find('a[data-toggle="tab"]'); 49 | triggerClick($tab_prev); 50 | }); 51 | 52 | /* 53 | Function to diplsay the card details as JSON as we type // TODO : Cookie Points 54 | */ 55 | $(".form-control").keyup(function () { 56 | // var app="{\n" + "\t" + "card: {\n" 57 | // $(".form-control").each(function () { 58 | // if( $(this).val() ) { 59 | // var value=$(this).val(); 60 | // var name=$(this).attr('name'); 61 | // app +="\t\t\t"+value+"*"+name+ "\n" ; 62 | // } 63 | // }); 64 | // $("#token-payload").text(app); 65 | 66 | }); 67 | 68 | /* 69 | Display JSON Payload 70 | */ 71 | 72 | $("#createtoken").click(function(e) { 73 | 74 | var card = {}; 75 | var exp = $('#expYear').val().split('/'); 76 | card.expYear = exp[1]; 77 | card.expMonth = exp[0]; 78 | card.address = {}; 79 | card.address.region = $('#state').val(); 80 | card.address.postalCode = $('#postalCode').val(); 81 | card.address.streetAddress = $('#streetAddress').val(); 82 | card.address.country = 'US'; 83 | card.address.city = $('#city').val(); 84 | card.name = $('#name').val(); 85 | card.cvc = $('#cvc').val(); 86 | card.number = $('#cardNumber').val(); 87 | 88 | var cardObj = {"card":card}; 89 | 90 | $("#token-payload").text(JSON.stringify(cardObj, null, 2)); 91 | e.preventDefault(); 92 | 93 | var baseUrl = "https://sandbox.api.intuit.com/quickbooks/v4/payments/tokens"; 94 | $.ajax({ 95 | url: baseUrl, 96 | data: JSON.stringify(cardObj), 97 | type: 'POST', 98 | dataType: "text", 99 | headers: {"Content-Type": "application/json"}, 100 | success: function (resp) { 101 | alert(resp); 102 | $("#token-result").text(resp); 103 | }, 104 | error: function(e) { 105 | $("#token-result").text(e); 106 | } 107 | }); 108 | 109 | }); 110 | 111 | /* 112 | Function to Authorize the Purchase 113 | */ 114 | $('#authorizePurchase').click(function(e){ 115 | 116 | e.preventDefault(); 117 | 118 | var jsonBody = {}; 119 | jsonBody.amount = $('#amount1').val(); 120 | jsonBody.capture = false; 121 | jsonBody.currency = $('#currency').val(); 122 | jsonBody.token = $('#token').val(); 123 | jsonBody.context = {}; 124 | jsonBody.context.mobile = false; 125 | jsonBody.context.isEcommerce = true; 126 | 127 | $("#amount2").val(jsonBody.amount); 128 | 129 | $.post('/authorizePurchase', {json:jsonBody}, function(data) { 130 | 131 | var json = JSON.stringify(data, null, 2); 132 | $("#purchase-result").text(json); 133 | }); 134 | }); 135 | 136 | /* 137 | Function to Capture Charge 138 | */ 139 | $('#captureCharge').click(function(e){ 140 | 141 | e.preventDefault(); 142 | var jsonBody = {}; 143 | jsonBody.amount = $('#amount2').val(); 144 | jsonBody.context = {}; 145 | jsonBody.context.mobile = false; 146 | jsonBody.context.isEcommerce = true; 147 | 148 | console.log('The JSON Body is : '+ JSON.stringify(jsonBody.amount)); 149 | 150 | 151 | $.post('/captureCharge', {json:jsonBody}, function(data) { 152 | var json = JSON.stringify(data, null, 2); 153 | console.log("The data returned is :" + json); 154 | $("#capture-result").text(json); 155 | }); 156 | }); 157 | 158 | }); 159 | }); 160 | 161 | }(jQuery, this)); -------------------------------------------------------------------------------- /views/Ratesample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/views/Ratesample.png -------------------------------------------------------------------------------- /views/Thumbdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/views/Thumbdown.png -------------------------------------------------------------------------------- /views/Thumbup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/SampleApp-Payments-Nodejs/c63c5e0af7e6562b333897ca31020113ac5b3c79/views/Thumbup.png --------------------------------------------------------------------------------