Many applications need to process payments for digital or physical goods. Implementing payment functionality can be very cumbersome though: many payment service providers support or don't support various types of payment methods and payment method registration and usage flows. The Stash! SDK simplifies the integration of payments into our applications and abstracts away a lot of the internal complexity that different payment service providers' solutions have. With the Stash! SDK it does not matter which payment service provider one chooses to register payment methods with - the API is standardized and works across the board.
There are many ways to contribute to this project. Get started here and make sure to take a look at our code of conduct.
At the moment, the Stash! backend supports the following PSPs:
This repository contains multiple modules:
payment-ws
- the main service module that contains the Stash! backend domain model, repositories and API endpointspayment-commons
- contains error handling, project validations and common models and data shared between payment-ws
and the PSP modulespayment-adyen
, payment-braintree
, payment-bs-one
payment-notifications
- the notification service that contains the notification domain model, repositories, and webhook endpoints for each PSPTo build this project, you will need to have at least the following:
The Stash! backend uses the ktlint
formatter. When making changes, you can run this command to auto-format the code:
mvn antrun:run@ktlint-format
After that, you can build the package by running this command:
mvn clean install
If you want to start only the ws service, you should run docker-compose up
from the payment-ws
folder. It will start the following services:
payment:payment
If you want to start both the ws service and the notification service, you should run docker-compose up
from the root folder. It will start the following services:
payment:payment
notifications:notifications
To shut down the services gracefully run ctrl+c
. To reset the data of the environment run docker-compose down -v
.
If you want to create a database instance on your own, you will need to set the configuration properties below. You can either put them in your local application-properties.local
, or define the environment variables:
- spring.datasource.url: DB url
- spring.datasource.username: DB username
- spring.datasource.password: DB password
- postgres.db.port: DB port
- postgres.db.host: DB host
- postgres.db.name: DB name
- spring.jpa.show-sql=true
- authorization.server.signingKey: oauth signing key
- payment.ws.notification.apiKey= notification service api key
- initial.data.loader.oauthClientId: oauth client id
- initial.data.loader.oauthClientPassword: oauth client password
- initial.data.loader.adminUsername: admin username
- initial.data.loader.adminPassword: admin password
After that, you can run the app directly from Maven using the Spring Boot plugin by simply running the following command:
mvn spring-boot:run -Dspring.profiles.active=local
You can now access the Stash! Backend here: http://localhost:8080/
For setting up infrastructure on Google Cloud Platform, the provided Terraform scripts can be used.
Editor
role. Create a new private key in JSON format and download it. Then create a directory called creds
inside the
terraform
root directory and copy this JSON file into it.stash-terraform-states
and prefix of mobility
for
storing the terraform states.terraform
root directory and your infrastructure will be ready in few
minutes
$ terraform init
$ terraform plan
$ terraform apply
In the Stash! Backend, there are the secret
and publishable
keys that should be generated for merchants. These keys will later be used for the authentication requests.
The publishable key is used to authenticate alias registration requests:
The secret key is used to authenticate transactions requests and alias deletion:
The Stash! SDK uses idempotence keys for both aliases and transactions. This prevents adding the same alias more than once or performing the same transaction several times. Idempotence works via an Idempotent-Key
header for Create Alias
, Preauthorization
, Authorization
and Refund
requests.
The value of the header and the request body are stored in the Stash! backend. If a second request comes with the same idempotent key and the same body, the original response is returned. However, if the second request has the same idempotent key as the original one, but a different body, an error is returned.
The Stash! Backend is in active development, we welcome your feedback! Please use GitHub Issues or write us at stash@mobilabsolutions.com to report an issue or give a feedback.