Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:
- PATCH version when backwards compatible bug **fixes** are implemented.

## [Unreleased]
### Added
- merchantSession, merchantCard, merchantInstallment and merchantPurchase resources

## [2.25.1] - 2026-03-20
### Fixed
Expand Down
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ is as easy as sending a text message to your client!
- [CorporateEnums](#corporate-enums): Query enums related to the corporate purchases, such as merchant categories, countries and card purchase methods
- [Split](#query-splits): Split received Invoice payments between different receivers
- [SplitReceiver](#create-splitreceivers): Receiver of an Invoice split
- [MerchantSession](#merchant-session): The Merchant Session allows you to create a session prior to a purchase. Sessions are essential for defining the parameters of a purchase, including funding type, expiration, 3DS, and more.
- [MerchantPurchase](#merchant-purchase): The Merchant Purchase section allows users to retrieve detailed information of the purchases.
- [Webhooks](#create-a-webhook-subscription): Configure your webhook endpoints and subscriptions
- [WebhookEvents](#process-webhook-events): Manage webhook events
- [WebhookEventAttempts](#query-failed-webhook-event-delivery-attempts-information): Query failed webhook event deliveries
Expand Down Expand Up @@ -2637,6 +2639,133 @@ SplitReceiver.Log log = SplitReceiver.Log.get("5155165527080960");
System.out.println(log);
```

## Merchant Session

The Merchant Session allows you to create a session prior to a purchase.
Sessions are essential for defining the parameters of a purchase, including funding type, expiration, 3DS, and more.

## Create a MerchantSession

```java
import com.starkbank.*;
import java.util.Map;
import java.util.List;
import java.util.HashMap;
import java.util.ArrayList;

Map<String, Object> data = new HashMap<>();
List<String> allowedFundingTypes = new ArrayList<>();
allowedFundingTypes.add("debit");
allowedFundingTypes.add("credit");
data.put("allowedFundingTypes", allowedFundingTypes);

List<Map<String, Object>> allowedInstallments = new ArrayList<>();
Map<String, Object> installment1 = new HashMap<>();
installment1.put("totalAmount", 0);
installment1.put("count", 1);
allowedInstallments.add(installment1);

Map<String, Object> installment2 = new HashMap<>();
installment2.put("totalAmount", 120);
installment2.put("count", 2);
allowedInstallments.add(installment2);

Map<String, Object> installment3 = new HashMap<>();
installment3.put("totalAmount", 180);
installment3.put("count", 12);
allowedInstallments.add(installment3);

data.put("allowedInstallments", allowedInstallments);
data.put("expiration", 3600);
data.put("challengeMode", "disabled");

data.put("tags", new String[]{"Stark", "Suit"});

MerchantSession.create(new MerchantSession(data));

System.out.println(log);
```

You can create a MerchantPurchase through a MerchantSession by passing its UUID.
**Note**: This method must be implemented in your front-end to ensure that sensitive card data does not pass through the back-end of the integration.

### Create a MerchantSession Purchase

```java
import com.starkbank.*;
import java.util.Map;
import java.util.HashMap;

Map<String, Object> purchaseData = new HashMap<>();
purchaseData.put("amount", 1000L);
purchaseData.put("cardExpiration", "2035-01");
purchaseData.put("cardNumber", "36490101441625");
purchaseData.put("cardSecurityCode", "123");
purchaseData.put("holderName", "Margaery Tyrell");
purchaseData.put("fundingType", "credit");

MerchantSession.Purchase purchase= MerchantSession.purchase(
merchantSession.uuid, new com.starkbank.MerchantSession.Purchase(purchaseData););

System.out.println(purchase);
```

### Query MerchantSessions

```java
import com.starkbank.*;
import java.util.Map;
import java.util.HashMap;

HashMap<String, Object> params = new HashMap<>();
params.put("limit", 10);

Generator<MerchantSession> sessions = MerchantSession.query(params);

for (MerchantSession session : sessions) {
System.out.println(session);
}
```

### Get a MerchantSession

```java
import com.starkbank.*;

MerchantSession retrievedSession = MerchantSession.get("5441927222657024");
System.out.println(retrievedSession);
```

## Merchant Purchase

The Merchant Purchase section allows users to retrieve detailed information of the purchases.

### Query MerchantPurchases

```java
import com.starkbank.*;
import java.util.Map;
import java.util.HashMap;

HashMap<String, Object> params = new HashMap<>();
params.put("limit", 10);
Generator<MerchantPurchase> merchantPurchases = MerchantPurchase.query(params);

for (MerchantPurchase purchase : merchantPurchases) {
System.out.println(purchase);
}
```

### Get a MerchantPurchase

```java
import com.starkbank.*;

MerchantPurchase retrievedPurchase = MerchantPurchase.get("5441927222657024");

System.out.println(retrievedPurchase);
```

## Create a webhook subscription

To create a webhook subscription and be notified whenever an event occurs, run:
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/com/starkbank/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ public Event deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
VerifiedAccountEvent.class);
case "payment-request":
return GsonEvent.getInstance().fromJson(jsonObject, PaymentRequestEvent.class);
case "merchant-purchase":
return context.deserialize(jsonObject,
MerchantPurchaseEvent.class);
case "merchant-session":
return context.deserialize(jsonObject,
MerchantSessionEvent.class);
case "merchant-installment":
return context.deserialize(jsonObject,
MerchantInstallmentEvent.class);
case "merchant-card":
return context.deserialize(jsonObject,
MerchantCardEvent.class);
default:
return context.deserialize(jsonObject,
UnknownEvent.class);
Expand Down Expand Up @@ -310,6 +322,58 @@ public PaymentRequestEvent() {
}
}

public final static class MerchantPurchaseEvent extends Event {
public MerchantPurchase.Log log;

public MerchantPurchaseEvent(MerchantPurchase.Log log, String created, Boolean isDelivered, String subscription, String id, String workspaceId) {
super(created, isDelivered, subscription, id, workspaceId);
this.log = log;
}

public MerchantPurchaseEvent() {
super();
}
}

public final static class MerchantSessionEvent extends Event {
public MerchantSession.Log log;

public MerchantSessionEvent(MerchantSession.Log log, String created, Boolean isDelivered, String subscription, String id, String workspaceId) {
super(created, isDelivered, subscription, id, workspaceId);
this.log = log;
}

public MerchantSessionEvent() {
super();
}
}

public final static class MerchantInstallmentEvent extends Event {
public MerchantInstallment.Log log;

public MerchantInstallmentEvent(MerchantInstallment.Log log, String created, Boolean isDelivered, String subscription, String id, String workspaceId) {
super(created, isDelivered, subscription, id, workspaceId);
this.log = log;
}

public MerchantInstallmentEvent() {
super();
}
}

public final static class MerchantCardEvent extends Event {
public MerchantCard.Log log;

public MerchantCardEvent(MerchantCard.Log log, String created, Boolean isDelivered, String subscription, String id, String workspaceId) {
super(created, isDelivered, subscription, id, workspaceId);
this.log = log;
}

public MerchantCardEvent() {
super();
}
}

public final static class UnknownEvent extends Event {
public JsonObject log;

Expand Down
Loading
Loading