Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send notification webhook about new balances #92

Closed
alexanmtz opened this issue Jul 3, 2018 · 2 comments
Closed

Send notification webhook about new balances #92

alexanmtz opened this issue Jul 3, 2018 · 2 comments
Labels
node.js Taks that requires node.js knowledge
Projects
Milestone

Comments

@alexanmtz
Copy link
Member

alexanmtz commented Jul 3, 2018

Stripe send notifications on our webhook route (https://gitpay.me/webhooks) sending information about the balance of an account. This balance is very useful to control the transfer about the bounties being sent.

The webhook notifications is already setup and integrated with the e-mails, tested and working for a lot of notifications that happens in many actions inside the Gitpay platform, as we have here:
https://github.com/worknenjoy/gitpay/blob/master/modules/load/controllers/webhook.js

We need to support this new webhook that give information about the balance.

This is the request received:

{
  "id": "evt_1234",
  "object": "event",
  "api_version": "2018-02-28",
  "created": 1530508059,
  "data": {
    "object": {
      "object": "balance",
      "available": [
        {
          "currency": "usd",
          "amount": 6420,
          "source_types": {
            "card": 6420
          }
        },
        {
          "currency": "brl",
          "amount": -2448,
          "source_types": {
            "card": -2448
          }
        }
      ],
      "connect_reserved": [
        {
          "currency": "usd",
          "amount": 0
        },
        {
          "currency": "brl",
          "amount": 0
        }
      ],
      "livemode": true,
      "pending": [
        {
          "currency": "usd",
          "amount": 0,
          "source_types": {
            "card": 0
          }
        },
        {
          "currency": "brl",
          "amount": 0,
          "source_types": {
            "card": 0
          }
        }
      ]
    }
  },
  "livemode": true,
  "pending_webhooks": 1,
  "request": {
    "id": null,
    "idempotency_key": null
  },
  "type": "balance.available"
}

The webhooks is not configured locally, so to test it you should run the tests:
https://github.com/worknenjoy/gitpay/blob/master/test/webhook.test.js

With npm run test

Why

Stripe send the balances that update the value available to transfer that is really useful to control the transfer that is being made by the platform. So we need to be notified when the balance update

Level

Beginner

Current behavior

The current behavior is a webhook being send to the route /webhooks and isn't recognized and nothing happens, just a pending webhook that should be be send by email to notifications@gitpay.me

Expected behavior

When a webhook of new balances is send, a e-mail should be send to notifications@gitpay.me
The email format should be

Subject: Um novo balanço da sua conta no Gitpay

<p>Temos um novo balanço para a conta do Gitpay:</p>
<ul>
  <li>currency: value</li>
</ul>

How to solve this issue

Create a test in https://github.com/worknenjoy/gitpay/blob/master/test/webhook.test.js

The test should return sucessful for the new balance object, you should create a fixture with the object received at https://github.com/worknenjoy/gitpay/tree/master/test/data with the name balance.js with the data provided here

How to reproduze the user scenario

  • Make a request to webhooks with the data described in this issue
  • The request will return with fail because the webhook isn't recognized

What you will need to complete this issue

  • You will need the sendgrid keys to be able to receive the e-mails
  • You will need to sucessful run npm run test

All the keys will be provided once you accept this issue

Tips

It's a great task to practice TDD, so first create the test setup and run. After you have the desired result, make requests (with POSTMAN or curl) and you will receive the emails (First you need to test to send in your own email, after you have the desired result, switch to notifications@gitpay.me)

@alexanmtz alexanmtz self-assigned this Jul 3, 2018
@alexanmtz alexanmtz added this to To do in Gitpay via automation Jul 3, 2018
@alexanmtz alexanmtz added this to the v1.3 milestone Jul 3, 2018
@alexanmtz alexanmtz removed their assignment Jul 7, 2018
@alexanmtz alexanmtz changed the title Send to notifications@gitpay.me new balances Send notification webhook about new balances Jul 9, 2018
@alexanmtz alexanmtz added node.js Taks that requires node.js knowledge and removed help wanted labels Jul 9, 2018
@alexanmtz
Copy link
Member Author

@alexanmtz alexanmtz added the to do label Jul 9, 2018
alexanmtz pushed a commit that referenced this issue Jul 28, 2018
@alexanmtz
Copy link
Member Author

Thanks @lucianojfj for contribution. Merged 🚀

Gitpay automation moved this from To do to Done Jul 28, 2018
@ghost ghost removed the to do label Jul 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node.js Taks that requires node.js knowledge
Projects
Gitpay
  
Done
Development

No branches or pull requests

1 participant