Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Repository files navigation

Skeerel JAVA

A Java library for the Skeerel API https://doc.skeerel.com

Requirements

Minimum java version: 8

Install

Via Gradle

Add this dependency to your project's build file:

implementation "com.arcansecurity.skeerel:skeerel-java:2.0.0"

Via Maven

Add this dependency to your project's POM:

<dependency>
<groupId>com.arcansecurity.skeerel</groupId>
<artifactId>skeerel-java</artifactId>
<version>2.0.0</version>
</dependency>

Usage

Dealing with delivery method

When a user pays with Skeerel, it's likely that you will have to ship its order. In that case, just set the url that Skeerel should call to get your delivery methods in your data-delivery-methods-url parameter. For instance:

https://site.com/path/to/delivery/methods_
https://site.com/path/to/delivery/methods?uid=__USER___
https://site.com/path/to/delivery/methods?uid=__USER__&zip_code=__ZIP_CODE&city=__CITY__&country=__COUNTRY__
https://site.com/path/to/delivery/methods?some_var=some_value&zip_code=__ZIP_CODE&city=__CITY__&country=__COUNTRY__

You can personalize as you like your url, so you can send accurate shipping pricing.

Note that __USER__ (user identifier), __ZIP_CODE__, __CITY__, __COUNTRY__ (two letters country code) are generics values that will be replaced automatically before calling your page.

In case of a guest checkout, __USER__ value will be set to empty string.

To format delivery methods, we recommend that you use our embedded method:

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.data.address.Country;
importcom.arcansecurity.skeerel.data.delivery.*;
publicclassMain {
publicstaticvoidmain(String[] args) {
// A standard delivery modeDeliveryMethoddeliveryMethod = newDeliveryMethod();
deliveryMethod.setId("standard");
deliveryMethod.setType(Type.HOME);
deliveryMethod.setPrimary(true);
deliveryMethod.setName("Standard shipping");
deliveryMethod.setDeliveryTextContent("delivery in 3 days");
deliveryMethod.setPrice(499);
// But also a pick up modeDeliveryMethoddeliveryMethodRelay = newDeliveryMethod();
deliveryMethodRelay.setId("my_relay");
deliveryMethodRelay.setType(Type.RELAY);
deliveryMethodRelay.setName("Pick-up & go");
deliveryMethodRelay.setDeliveryTextContent("Deliver on ");
deliveryMethodRelay.setPrice(299);
// Pick up pointsPickUpPointpickUpPoint1 = newPickUpPoint();
pickUpPoint1.setId("1");
pickUpPoint1.setName("Pick-up 1");
pickUpPoint1.setAddress("Address 1");
pickUpPoint1.setZipCode("zip");
pickUpPoint1.setCity("city");
pickUpPoint1.setCountry(Country.fromAlpha2("FR"));
pickUpPoint1.setDeliveryTextContent("tomorrow");
pickUpPoint1.setDeliveryTextColor(Color.GREEN);
pickUpPoint1.setPrice(399);
pickUpPoint1.setPriceTextColor(Color.RED);
PickUpPointpickUpPoint2 = newPickUpPoint();
pickUpPoint2.setId("2");
pickUpPoint2.setPrimary(true);
pickUpPoint2.setName("Pick-up 2");
pickUpPoint2.setAddress("address 2");
pickUpPoint2.setZipCode("zip");
pickUpPoint2.setCity("city");
pickUpPoint2.setCountry(Country.fromAlpha2("FR"));
PickUpPointpickUpPoint3 = newPickUpPoint();
pickUpPoint3.setId("3");
pickUpPoint3.setName("Pick-up 3");
pickUpPoint3.setAddress("Address 3");
pickUpPoint3.setZipCode("zip");
pickUpPoint3.setCity("city");
pickUpPoint3.setCountry(Country.fromAlpha2("FR"));
PickUpPointspickUpPointsRelay = newPickUpPoints();
pickUpPointsRelay.add(pickUpPoint1);
pickUpPointsRelay.add(pickUpPoint2);
pickUpPointsRelay.add(pickUpPoint3);
deliveryMethodRelay.setPickUpPoints(pickUpPointsRelay);
// And why not getting the order directly in the storeDeliveryMethoddeliveryMethodCollect = newDeliveryMethod();
deliveryMethodCollect.setId("store_collect");
deliveryMethodCollect.setType(Type.COLLECT);
deliveryMethodCollect.setName("Click & collect");
deliveryMethodCollect.setDeliveryTextContent("Available in two hours");
deliveryMethodCollect.setPrice(0);
// Collect pointsPickUpPointcollectPoint1 = newPickUpPoint();
collectPoint1.setId("1");
collectPoint1.setName("Store 1");
collectPoint1.setAddress("Address 1");
collectPoint1.setZipCode("zip");
collectPoint1.setCity("city");
collectPoint1.setCountry(Country.fromAlpha2("FR"));
PickUpPointcollectPoint2 = newPickUpPoint();
collectPoint2.setId("2");
collectPoint2.setName("Store 2");
collectPoint2.setAddress("Address 2");
collectPoint2.setZipCode("zip");
collectPoint2.setCity("city");
collectPoint2.setCountry(Country.fromAlpha2("FR"));
PickUpPointcollectPoint3 = newPickUpPoint();
collectPoint3.setId("3");
collectPoint3.setName("Store 3");
collectPoint3.setAddress("Address 3");
collectPoint3.setZipCode("zip");
collectPoint3.setCity("city");
collectPoint3.setCountry(Country.fromAlpha2("FR"));
PickUpPointspickUpPointsCollect = newPickUpPoints();
pickUpPointsCollect.add(collectPoint1);
pickUpPointsCollect.add(collectPoint2);
pickUpPointsCollect.add(collectPoint3);
deliveryMethodCollect.setPickUpPoints(pickUpPointsCollect);
// We add everything to the main objectDeliveryMethodsdeliveryMethods = newDeliveryMethods();
deliveryMethods.add(deliveryMethod);
deliveryMethods.add(deliveryMethodRelay);
deliveryMethods.add(deliveryMethodCollect);
// And we show the jsonSystem.out.println(deliveryMethods.toJson());
}
}

Get details on completion

When a user logs in or pays with Skeerel, the browser will redirect him automatically to your data-redirect-url parameter. To retrieve his data, you just have to call the following lines

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.exception.SkeerelException;
importjava.util.UUID;
publicclassMain {
publicstaticvoidmain(String[] args) throwsSkeerelException {
Skeerelskeerel = newSkeerel(UUID.fromString("WEBSITE_ID"), "WEBSITE_SECRET");
System.out.println(skeerel.getData("ACCESS_TOKEN"));
}
}

For more information about getting user information, you can look at the classes in the package com.arcansecurity.skeerel.data.

Get details of a payment

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.exception.SkeerelException;
importjava.util.UUID;
publicclassMain {
publicstaticvoidmain(String[] args) throwsSkeerelException {
Skeerelskeerel = newSkeerel(UUID.fromString("WEBSITE_ID"), "WEBSITE_SECRET");
System.out.println(skeerel.getPayment(UUID.fromString("PAYMENT_ID")));
}
}

List payments

Payments are ordered by date DESC. Last payment appears first

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.exception.SkeerelException;
importjava.util.UUID;
publicclassMain {
publicstaticvoidmain(String[] args) throwsSkeerelException {
Skeerelskeerel = newSkeerel(UUID.fromString("WEBSITE_ID"), "WEBSITE_SECRET");
System.out.println(skeerel.listPayments()); // last ten paymentsSystem.out.println(skeerel.listPayments(true)); // last ten live paymentsSystem.out.println(skeerel.listPayments(15, 20)); // list twenty payments starting from the fifteenth indexSystem.out.println(skeerel.listPayments(true, 15, 20)); // list twenty live payments starting from the fifteenth index
}
}

Refund payment

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.exception.SkeerelException;
importjava.util.UUID;
publicclassMain {
publicstaticvoidmain(String[] args) throwsSkeerelException {
Skeerelskeerel = newSkeerel(UUID.fromString("WEBSITE_ID"), "WEBSITE_SECRET");
System.out.println(skeerel.refundPayment(UUID.fromString("PAYMENT_ID"))); // full refundSystem.out.println(skeerel.refundPayment(UUID.fromString("PAYMENT_ID"), 100)); // partial refund (amount is in the currency's smallest unit. Ex 50€ => 5000)
}
}

Reviewing a payment

When a payment seems suspect, Skeerel hold the money but does not capture it.

This way you can review the payment manually and only capture the amount if the payment is legit (thus, avoiding dispute). If it is fraudulent you can just reject the payment. If the payment is not rejected within seven days, the payment is automatically canceled.

The following code shows how to capture or reject a payment.

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.exception.SkeerelException;
importjava.util.UUID;
publicclassMain {
publicstaticvoidmain(String[] args) throwsSkeerelException {
Skeerelskeerel = newSkeerel(UUID.fromString("WEBSITE_ID"), "WEBSITE_SECRET");
System.out.println(skeerel.capturePayment(UUID.fromString(""))); // payment is legit, capture itSystem.out.println(skeerel.rejectPayment(UUID.fromString(""))); // payment is fraudulent, reject it
}
}

Get details of a website

importcom.arcansecurity.skeerel.Skeerel;
importcom.arcansecurity.skeerel.exception.SkeerelException;
importjava.util.UUID;
publicclassMain {
publicstaticvoidmain(String[] args) throwsSkeerelException {
Skeerelskeerel = newSkeerel(UUID.fromString("WEBSITE_ID"), "WEBSITE_SECRET");
System.out.println(skeerel.getWebsiteDetails());
}
}

Sample App

If you'd like to see an example of this library in action, check out the Skeerel JAVA sample application here.

Resources

Check out the API documentation.
Access your customer dashboard.

About

A java library for the Skeerel API https://docs.skeerel.com

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages