https://github.com/spare-technologies/java-sdk
https://github.com/spare-technologies/java-sdk
fintech fintech-api openbanking payment payment-gateway webpaymentapi
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/spare-technologies/java-sdk
- Owner: spare-technologies
- License: mit
- Created: 2021-05-21T14:48:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T21:13:58.000Z (over 3 years ago)
- Last Synced: 2025-03-17T10:36:38.121Z (over 1 year ago)
- Topics: fintech, fintech-api, openbanking, payment, payment-gateway, webpaymentapi
- Language: Java
- Homepage: https://docs.tryspare.com
- Size: 76.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# java-sdk
[](https://search.maven.org/search?q=g:%22com.tryspare%22%20AND%20a:%22java.sdk%22)


### Usage
#### I- Add dependencies to ```pom.xml``` file
```xml
com.tryspare
java.sdk
1.1.0
```
#### II- To Generate ECC key pair
```java
import com.spare.sdk.security.crypto.SpCrypto;
public class MyClass {
SpEcKeyPair eccKeyPair = SpCrypto.generateKeyPair();
System.out.println("Private key \n", eccKeyPair.getPrivateKey());
System.out.println("\n\n");
System.out.println("Private key \n", eccKeyPair.getPublicKey());
}
```
#### III- To create your first payment request
```java
import com.spare.sdk.payment.models.builder.SpDomesticPaymentRequestBuilder;
import com.spare.sdk.payment.models.payment.domestic.SpDomesticPaymentRequest;
public class MyClass {
// Business ECC private key
public static String privateKey = """""";
// Spare ECC public key
public static String serverPublicKey = """""";
public static void main(String[] args) {
// Configure client
SpPaymentClientOptions clientOptions = new SpPaymentClientOptions();
clientOptions.setBaseUrl(URI.create("https://payment.tryspare.com"));
clientOptions.setApiKey("Your API key");
clientOptions.setAppId("Your app id");
SpPaymentClient client = new SpPaymentClient(clientOptions);
// Initialize payment
SpDomesticPaymentRequestBuilder paymentRequestBuilder = new SpDomesticPaymentRequestBuilder();
SpDomesticPaymentRequest paymentRequest = paymentRequestBuilder.setAmount(10.0)
.setDescription("Shopping")
.setOrderId("12345")
.build();
// Sign the payment
String signature = SpEccSignatureManager.Sign(privateKey, paymentRequest.toJsonString());
// Create payment
SpCreateDomesticPaymentResponse paymentResponse = client.CreateDomesticPayment(paymentRequest, signature);
// To verify signature of the created payment
if (SpEccSignatureManager.Verify(serverPublicKey, paymentResponse.getPayment().toJsonString(), createPayment.getSignature())) {
// signature verified
}
}
}
```