Coder Social home page Coder Social logo

acorn's Introduction

Acorn

A fun script to apply custom ruleset to store money in jars every time you receive money

Use this at your own risk. It was developed within a few hours during our mission days and doesn't meet the normal quality standards that we uphold at wise, for example, it has no tests. We felt it could be a useful starting point for people to play around with Wise APIs, rather than being used as a standalone.

How it works

We listen to a webhook on balance deposits into an account, then we create or find a specific jar. Then looking at incoming deposits, we apply rules to understand if and how they should be moved to the jars. We then call the /balance-movements API to move this money between balances.

Pre-requisites

Make sure you have java 15 and docker installed.

How to run locally?

  1. Create your account on https://ngrok.com and copy paste your ngrok token to ngrok-exec/ngrok.conf. (Only use ngrok if you don't want to set up a public https server that can handle incoming webhooks on its own)
  2. Go to src/java/resources/application.yml to edit your ruleset. Each currency can have specific threshold, and there's also a default ruleset. For a transfer from your balance to your jar to be triggered, the amount received must between the min and max value for the balance currency, and the amount of money to be transferred will be equal to the percentage defined in that same rule set multiplied by the received amount. In the absence of a currency specific ruleset, the default ruleset will apply as defined in wise.ruleset.default.
  3. Go to wise.com/settings, get a personal token with full access and add it to the environment variable "WISE_TOKEN" NB: you need to keep this token secret. It will have full access to your account through the API.
  4. Now go to the root of this repository and run bash start.bash, this will package up the application in a docker container and run it alongside an ngrok container.
  5. The console will now show tons of logs, including the ngrok url from the ngrok container. Copy the one that starts with https to your clipboard. WebHook Setup
  6. Go to wise.com, login, then settings > webhooks. Choose deposit events and use the ngrok https url and then append /balance-deposits to it.
  7. You're all set, enjoy!

acorn's People

Contributors

louis-tw avatar

Watchers

 avatar

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.