Giter VIP home page Giter VIP logo

stitch-payment-request-lambda's Introduction

Stitch Payment Request Lambda

A lambda that retrieves a token, and uses it to create a Stitch PaymentInitiationRequest and returns the URL and ID

Code

If you're just here to see code examples for integrating with the Stitch API. The files you'll want are:

  1. function/stitch/retrieve-client-token.ts -- generates a client assertion and fetches a token.
  2. function/stitch/payment-request-create.ts -- builds the GraphQL query to generate a PaymentInitiationRequest
  3. function/stitch/fetch-graqhql.ts -- simply executes the network request to the Stitch API

Getting started

If you would like to implement and deploy the function, you'll need to follow the guide below.

1. Set up environment

Take a look at function/settings.ts to see how the environment variables are loaded. In order to run the Lambda, the following environment variables will need to be present:

  • STITCH_PRIVATE_KEY -- the private key portion of the certificate issued to you by Stitch.
  • STITCH_CLIENT_ID -- the client ID issued to you by Stitch.

This will need to be done locally, and on the environment the lambda will be running, see: Configuring environment variables for AWS Lambdas. If you would rather set these values using a different method, you will need to configure that behaviour in function/settings.ts.

2. Running locally

Install: npm run install

Build: npm run build

3. Invoking function

Curl example (replace the function URL, and beneficiary information):

curl --request POST \
  --url <FUNCTION-URL> \
  --header 'Content-Type: application/json' \
  --data '{
	"quantity": 1,
	"currency": "ZAR",
	"payerReference": "Test",
	"beneficiaryReference": "Test",
	"beneficiaryBank": "<BANK-ID>",
	"beneficiaryAccountNum": "<BENEFICIARY-ACCOUNT-NUMBER>",
	"beneficiaryName": "<BENEFICIARY-NAME>"
}'

Community

Feel free to open any issues, PRs, and direct any conversation to the Stitch Slack community

⚠️ Warning

This function offers no authorization. It merely serves as an example, and accepts beneficiary information via the POST body. It is strongly recommended you secure this function to avoid malicious generation of payment requests using your client information. See: Lambda authorizers

stitch-payment-request-lambda's People

Contributors

jaywaa avatar

Stargazers

Pivendren Naik avatar Taylor  avatar Marcel Prinsloo avatar

Watchers

Marcel Prinsloo avatar  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.