Skip to content

Commit

Permalink
Added test cases and updated docs
Browse files Browse the repository at this point in the history
Updated documentation and added basic test cases for the server.  Need
to add more cases for the react/redux components.
  • Loading branch information
TheF1rstPancake committed Aug 8, 2016
1 parent 62daca3 commit 8475df6
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 153 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ Kvasir (Vas-eer) is a support dashboard meant for WePay partners to be able to p
It will perform:

- account lookups
- Get the status of a merchant's account

- account statuses

- withdrawal info
- Get a merchant's withdrawal info including their bank info and when the next withdrawal will take place

- user lookups

- resending user confirmation

- refunding checkouts

- Both full and partial refunds are possible

## Functionality
All of the functionality has been tested repeatedly, but there may be some cases that I missed. The WePay API isn't always predicatable, so if you run into an error, be sure to report it as an issue so that I can investigate furhter. Giving me the original call information (without your client_secret or any access tokens) is extremely helpful so that I can try and reproduce the error.
All of the functionality has been tested, but there may be some cases that I missed. The WePay API isn't always predicatable, so if you run into an error, be sure to report it as an issue so that I can investigate furhter. Giving me the original call information (without your client_secret or any access tokens) is extremely helpful so that I can try and reproduce the error.

To see how the framework behaves in action go to: https://nameless-hollows-55554.herokuapp.com/

## More Info
To see more info and the full documentation on Kvasir's specs and what's required to use Kvasir, checkout the full documentation: https://wedemoapp.gitlab.io/kvasir/index.html

## License
Copyright 2016 Giovanni Briggs

Expand Down
16 changes: 16 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# configuration file for GAE
#

runtime: nodejs
vm: true
threadsafe: true
service: kvasir

vm_health_check:
enable_health_check: False

handlers:
- url: /.*
script: server.js
secure: always
login: admin
1 change: 1 addition & 0 deletions components/Checkouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ var Checkouts = React.createClass({
</TableHeaderColumn>
<TableHeaderColumn
dataField = "create_time"
dataFormat = {Base.formatDate}
dataSort={true}
>
Date
Expand Down
2 changes: 1 addition & 1 deletion docs/herokudeploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Scripting Makes Life Easier
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you already have a `.env` file defined (which you generally should during development), then you can use this Python script to set all of the environment variables on Heroku for you.

..code-block:: python
.. code-block:: python
from subprocess import call
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Contents
frontend
backend
middleware
usecases
herokudeploy
googleappengine

Expand Down
2 changes: 1 addition & 1 deletion docs/middleware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ When developing Kvasir, we constructed a middleware that connected to a set of f

Middleware Specifications
---------------------------
If you read the :ref:`back-end server documentation <kvasirbackend>` then you know that Kvasir's NodeJS server comes with one function for communicating with the middleware (:func:`getDataFromMiddleware`).
If you read the :ref:`back-end server documentation <kvasirbackend>` then you know that Kvasir's NodeJS server comes with one function for communicating with the middleware (:func:`getDataFromMid2dleware`).

This function is very simple, all it does is format it's parameters into a POST request with a callback function.

Expand Down
76 changes: 76 additions & 0 deletions docs/usecases.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Kvasir Use Cases
=====================
This page will explain what functionality Kvasir was built for and how to work with it in common use cases.

Features
----------------
Kvasir is built to perform the following actions:
- account lookups
- account statuses
- withdrawal info

- user lookups

- resending user confirmation

- refunding checkouts

The combination of all of these actions allows you to complete most custom support items for your users.

Account and User Lookups
------------------------------
A common question from users is 'Why can't I withdraw funds?' And the first thing a customer support rep should check is if the user completed KYC. To do that, we need to do an account lookup and check if the user has a bank account tied to the account.

**Any action involving a user requires that we get their email**.

To perform an account lookup:
1) Go to the search bar and make sure the select box is set to "User" since we are searching for a merchant
2) Type in the merchant's email
3) Hit enter and wait. You should see a set of spinning animations indicating that Kvasir is fetching.
4) Once the spinners stop, there will be 2 tables
a) A table that has the merchant's information (name, email and whether or not they've confirmed their email)
b) A table with the merchant's accounts
5) Table *b* contains a column with the merchant's bank info. If that column is blank, then the account does not have an associated bank account

.. note::
If the spinners stop and no tables appear, it is because an error occurred. You should receive an error message that tells you why it died, but that's dependent on how you implemented the middleware.

During these steps, you can also check to make sure that the user has confirmed their email with WePay. The user table has a "State" column that tells you what state the user is in. If the user's state is not "Registered", then there will be box on the screen that will allow you to resend the user the confirmation email so that they can complete registration.

Performing Refunds
-------------------
Another common operation is issuing refunds to payers. Kvasir can handle both full and partial refunds with some caveats.

In both cases, you'll want to get the payer's email address that they entered when making the payment.

.. note::
It is possible that you do not associate a payer's email with the checkout. In that case, you cannot use Kvasir for this. Allowing for more searchable options is part of the future plans.

First set the select box to be "Payer" to indicate that you are searching payer information, not merchant information. Once you enter in their email address, you'll see the spinning wheels indicating that Kvasir is working. It should come back with a table that has all of that payer's checkouts. If the table is empty or you receive an error message, it means that no payer with that email exists in your system.

With that list of checkouts, you need to identify which one the payer wants to refund. You can use the time of the checkout to help narrow it down. Once you know which checkout it is, click on the radio button for that row.

This will cause Kvasir to go fetch more information about the checkout including:
- Information about the merchant
- Information about the account
- All of the information about the checkout from the WePay API

Once we have all of this, we can perform the refund. If the refund hasn't already been refunded, you will see a blue button in a column titled "Refund." Clicking on that button will bring up a modal that includes information about the checkout along with two options - full and partial refund.

When you do a full refund, you will refund the original amount paid to the merchant as well as all app and processing fees. Clicking the full refund button will ask you to enter a reason for the refund. This is may be sent to the merchant depending on your app configuration, so be careful what you put in.

For a partial refund, you get to decide how much of the original amount paid to the merchant and how much of the app fees you want to refund. There are three fields that appear when you click partial refund - amount, percentage, and fees. The amount and percentage field are tied together. This was designed to make issuing a refund easier. If your refund policy is that you only refund half of the amount paid to the merchant, you can type in "50" into the "Percentage" field and Kvasir will calculate what 50% of the amount is for you right there. Takes out some of the guess work in calculating refunds.

If you leave a field blank, the default value will be 0. So if you want to refund the entirety of the amount paid to the merchant but keep the app fees, you can do that in a partial refund.

.. note::
The WePay processing fees are untouchable when doing a partial refund.

Partial refunds also require a reason. After you type in the reason, go ahead and press enter and the refund will happen. If the refund is successful, you will see a green box that says, "Refund successful!" and the row in the table will update with the refund information. This update is actually Kvasir requesting the checkout object again from the WePay API to see if the state changed. If it doesn't update, don't be alarmed. Sometimes it takes a while for the checkout object to update, but if you see the "Refund successful" message, that means that the refund went through.

Potential Refund Errors
~~~~~~~~~~~~~~~~~~~~~~~~~~
Any errors sent back from the WePay API will be displayed in the modal above the submit button.

The most common error is trying to refund the checkout before the checkout is in state "released." The WePay API will return an error in this case, but the state of the checkout is also included in the checkouts table, so you can check before attempting the refund.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "node server.js",
"postinstall": "webpack --config ./webpack.config.js",
"bundle": "webpack --config webpack.config.js",
"test": "cross-env NODE_ENV=test mocha --recursive --compilers js:babel-register --require ./test/setup.js",
"test": "mocha --reporter spec",
"test:watch": "npm test -- --watch"
},
"repository": {
Expand All @@ -30,6 +30,7 @@
"babel-preset-react-hmre": "^1.1.1",
"babel-register": "^6.3.13",
"body-parser": "^1.15.2",
"chai": "^3.5.0",
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-alpha.1",
"csurf": "^1.9.0",
Expand All @@ -38,6 +39,7 @@
"express": "^4.13.3",
"express-winston": "^2.0.0",
"foreman": "^1.4.1",
"mocha": "^3.0.2",
"react": "^15.3.0",
"react-bootstrap": "^0.29.5",
"react-bootstrap-table": "^2.3.7",
Expand All @@ -49,9 +51,9 @@
"request": "^2.74.0",
"url": "^0.11.0",
"webpack": "^1.13.1",
"wepay": "git://github.com/wepay/NodeJS-SDK.git",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.12.2",
"wepay": "git://github.com/wepay/NodeJS-SDK.git",
"winston": "^2.2.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function verifyConfig(conf) {
*/
function sendResponse(package, res) {
res.setHeader('Content-Type', 'application/json');
if ("error_code" in package) {
if (package.error_code) {
var error_package = {
"error_code":500,
"error_description":"wepay call died. Check server logs for more details.",
Expand Down Expand Up @@ -258,7 +258,7 @@ function parseMiddlewareResponse(req, res, error, response, body, wepay_endpoint
}
else {
if (body.access_token) {
winston.info("Setting access token cookie:\t", body.access_token);
winston.info("Requesting data from wepay: ", wepay_endpoint);
return getWePayData(res, wepay_endpoint, body.access_token, wepay_package);
}
return sendResponse(body, res);
Expand Down
26 changes: 0 additions & 26 deletions test/actions/todos.spec.js

This file was deleted.

112 changes: 0 additions & 112 deletions test/reducers/todos.spec.js

This file was deleted.

Loading

0 comments on commit 8475df6

Please sign in to comment.