![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
com.unzer.payment:java-sdk
Advanced tools
This SDK provides for an easy way to connect to the Unzer Rest API.
Java 1.8 or later.
<dependency>
<groupId>com.unzer.payment</groupId>
<artifactId>java-sdk</artifactId>
<version>5.2.0</version>
</dependency>
Documentation is available at https://docs.unzer.com/server-side-integration/java-sdk-integration/.
The Unzer class is instantiated using your private or public key:
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
You can inject a custom implementation of the http-network communication into the Unzer constructor. For implementing a custom communication stack, you have to subclass the AbstractUnzerRestCommunication class together with a UnzerHttpRequest. For an example please refer to the reference implementation HttpClientBasedRestCommunication.
The first step is to create a Payment Type and then do an authorize or charge for this Payment Type
Example for Authorize
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
// Already created the payment type using our Javascript or Mobile SDK's
Authorization authorize = unzer.authorize(BigDecimal.ONE, Currency.getInstance("EUR"), "s-crd-fm7tifzkqewy", new URL("https://www.unzer.com"));
// Without a payment type created before
Card card = new Card("4444333322221111", "12/19");
Authorization authorize2 = unzer.authorize(BigDecimal.ONE, Currency.getInstance("EUR"), card, new URL("https://www.unzer.com"));
Example for Charge
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
// Already created the payment type using our Javascript or Mobile SDK's
Charge charge = unzer.charge(BigDecimal.ONE, Currency.getInstance("EUR"), "s-sft-fm7tifzkqewy", new URL("https://www.unzer.com"));
// Without a payment type created before
Charge charge2 = unzer.charge(BigDecimal.ONE, Currency.getInstance("EUR"), new Sofort(), new URL("https://www.unzer.com"));
As a result for authorize or charge an Authorization or Charge object will be returned which contains a reference to a Payment object.
To query the status of a payment you can fetch the Payment:
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Payment payment = unzer.fetchPayment(authorize.getPayment().getId());
If you started the payment with an authorize (reservation) then you can do a Charge based on this Authorization. There are different options to Charge after an Authorization:
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
// Charge using Authorize object
Authorization authorization = unzer.fetchAuthorization("s-pay-1");
Charge charge = authorization.charge();
// Charge using Payment object
Payment payment = unzer.fetchPayment("s-pay-1");
Charge charge2 = payment.charge();
// Charge using Unzer object
Charge charge3 = unzer.chargeAuthorization("s-pay-1");
Cancelling a payment after authorization. There are again three options how to do this:
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
// Cancel Authorization
Authorization authorization = unzer.fetchAuthorization("s-pay-1");
Cancel cancel = authorization.cancel();
// Cancel Payment
Payment payment = unzer.fetchPayment("s-pay-1");
Cancel cancel2 = payment.cancel(new BigDecimal(0.1));
// Cancel using Unzer object
Cancel cancel3 = unzer.cancelAuthorization("s-pay-1");
Cancelling a charge refunds money from the merchant to the customer. There are several options how to do a refund:
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
// cancel a charge using Charge object
Charge charge = unzer.fetchCharge("s-pay-1", "s-chg-1");
Cancel cancel = charge.cancel();
// cancel a charge using Unzer object
Cancel cancel = unzer.cancelCharge("s-pay-1", "s-chg-1", BigDecimal.ONE);
To execute a Shipment you need to call the shipment method in Unzer object:
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Shipment shipment = unzer.shipment(authorize.getPaymentId());
For any issues or questions please get in touch with our support team.
FAQs
Unzer SDK provides an easy way to use Unzer Payment API.
We found that com.unzer.payment:java-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.