Investec Developer Community Wiki
  • 🏠Home
    • Investec Developer community wiki
  • ⚒️Get Started
    • Get started overview
    • Investec Developer Docs
    • Self-enrollment guide
    • API quick start guide
      • 🔑How to create your API keys
      • 👤How to authenticate against the Investec API
      • 🏦How to get your account, balance, and transaction data
      • 💸How to make transfers and payments
    • Programmable card quick start guide
      • 🙌How to activate your programmable card
      • 🚀How to add low-code snippets to your card on Investec Online
      • 🖥️How to add code to your card and run a simulation using the online IDE
      • 💳How to use the programmable card API
    • Sample apps
  • ⚒️Get Building
    • Get building overview
    • Community GitHub
    • Community libraries & tools
    • Build tutorials & guides
      • 💳Card | Slack Integration
      • 🚗Card | How to create a DIY petrol card
      • 🎯API | No-code Budget Expense App
    • Build challenges & hackathons
      • 🎯[Closed] Q1 2025 Bounty Challenge | Path to Financial Health
      • 🎁[CLOSED] Q4 2024 Bounty Challenge | Festive API Wrappers
      • 🚂[CLOSED] Q3 2024 Bounty Challenge | Everyday Solutions
      • ☄️[CLOSED] Q2 2024 Bounty Challenge | Card Code Snippets
      • 💰[CLOSED] Bounties Playground | banking.make.dev
      • 👩‍💻👩💻 [CLOSED] Mindjoy | Kid at Heart Build Challenge
      • ⚡[CLOSED] EskomSePush Build Challenge
        • EskomSePush Build Challenge Submissions
      • 💳[CLOSED] 2022 Hackathon | low-code/no-code
        • 2022 Hackathon | low-code/no-code | Submissions
      • 💰[CLOSED] Spreadsheet Banking | Bounties
        • 👩‍💻👩💻 Spreadsheet Banking | Basic Functions
      • 🏔️[CLOSED] Q1 2023 Bounty Challenge
      • 💳[CLOSED] Q2 2023 Bounty Challenge
        • 🗺️Checklist for Bounty Hunters 🏆
        • 🚀Bounty Challenge #2: Code Snippet Showdown 🚀
      • 🍕[CLOSED] Q1 2024 Bounty Challenge | The Tutorial Quest
    • Open-source projects
  • 🙌Community
    • Get involved
    • Community champions
    • Community events
    • Community manifesto
    • Blog posts
    • Community integration pros
    • Investec Developer's QRious Puzzle Challenge
  • 💬Feedback and Support
    • Get support
    • Community FAQs
    • Feature requests
    • Submit product issues
Powered by GitBook
On this page
  • The Investec Online IDE
  • Adding code to your card via the IDE and running a simulation

Was this helpful?

  1. Get Started
  2. Programmable card quick start guide

How to add code to your card and run a simulation using the online IDE

The Investec Online IDE

The Investec Online IDE (integrated development environment) enables Investec Private Banking clients to execute custom functionality on your programmable card.

  1. Navigate to the Investec Developer homepage by clicking on “Manage”, followed by “Investec Developer”.

  2. Click on “manage code” on the Programmable Card IDE tile.

  3. You will be presented with a list of your cards. Ensure it is enabled by toggling the card on.

  4. Click on the card to which you would like to add your code.

  5. The IDE or code editor for your card will open up, ready for you to start adding your code.

Pro-Tip: The IDE can be slow to load and you might need to refresh the page.

Adding code to your card via the IDE and running a simulation

There are three main functions that can be used to execute custom functionality on your card:

  • beforeTransaction

    • Every time you initiate a transaction from your Investec card, the beforeTransaction method intercepts the authorisation before it is approved by Investec.

    • This gives you the ability to apply logic to either decline or approve the transaction based on data from the card authorization itself.

    • This function needs to return a true or false value in order for it to work.

    • Time is limited for this function so use minimal code.

  • afterTransaction

    • This function will execute after every transaction that has been processed by the card.

  • afterDecline

    • This function will execute if a transaction has been declined on the card.

  1. Navigate to the main.js file and paste in the code snippet below to test.

    1. The code snippet declines card purchases that are made in bakeries (using a specified merchant code) and that are over R50 (or 5000 cents).

  2. Click "Save changes". By doing so it won't have an effect on your card until you click "deploy code to card"

// ```javascript
const beforeTransaction = async (authorization) => {
  if (authorization.merchant.category.key === 'bakeries') {
    return authorization.centsAmount < 5000
  }
  return true
}
```

Pro-Tip: When referring to amounts in the code it is the cent value of the transaction. R55 equals 5500 cents.

  1. Navigate to the right-hand side of the code editor to the simulator. The simulator allows you to simulate transactions to test out the code on your card before you deploy it.

  2. Type in a value of 5100 cents (R51.00), which is above the R50 limit we have set with the code.

  3. Click "Simulate card transaction".

  4. A simulation.json file will be created, showing that the transaction failed (authorizationApproved will be false) because the amount is over the limit specified.

  5. Once you have tested the code and would like to deploy the code to the card click "Deploy code to card".

Pro-Tip: The log.json file shows all the logs from the code. You can also log certain outcomes using the console.log function.

PreviousHow to add low-code snippets to your card on Investec OnlineNextHow to use the programmable card API

Last updated 4 months ago

Was this helpful?

⚒️
🖥️