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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.adyen.model.reportwebhooks.ReportNotificationRequest;
import com.adyen.model.reportwebhooks.ReportWebhooksHandler;
import com.adyen.model.transactionwebhooks.BankCategoryData;
import com.adyen.model.transactionwebhooks.IssuedCard;
import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4;
import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler;
import com.adyen.model.transferwebhooks.BalanceMutation;
Expand Down Expand Up @@ -280,6 +281,41 @@ public void testTransactionWebhookBankCategoryDataParsing() {
Assertions.assertEquals(BankCategoryData.PriorityEnum.REGULAR, bankCategoryData.getPriority());
}

/**
* Verifies that a transaction.created webhook for an issued card is fully deserialized: the card
* category data, including the network variant of the payment network used for the transaction.
*/
@Test
public void testTransactionWebhookIssuedCardCategoryDataParsing() {
String json =
getFileContents("mocks/notification/balancePlatform-transaction-created-issued-card.json");
TransactionWebhooksHandler webhookHandler = new TransactionWebhooksHandler(json);
Optional<TransactionNotificationRequestV4> requestOptional =
webhookHandler.getTransactionNotificationRequestV4();
Assertions.assertTrue(requestOptional.isPresent());
TransactionNotificationRequestV4 request = requestOptional.get();
Assertions.assertEquals("EVJN00000000000000000000000004USD", request.getData().getId());

IssuedCard issuedCard = request.getData().getTransfer().getCategoryData().getIssuedCard();
Assertions.assertNotNull(issuedCard);
Assertions.assertEquals(IssuedCard.TypeEnum.ISSUEDCARD, issuedCard.getType());
Assertions.assertEquals(
IssuedCard.NetworkVariantEnum.MAESTRO_US, issuedCard.getNetworkVariant());
}

/**
* Verifies the wire-value mapping of the card network variant enum and its forward compatibility:
* known values deserialize to the matching enum constant, while values not yet known to this
* library deserialize to null instead of throwing an exception.
*/
@Test
public void testIssuedCardNetworkVariantDeserialization() {
Assertions.assertEquals("maestro_us", IssuedCard.NetworkVariantEnum.MAESTRO_US.getValue());
Assertions.assertEquals(
IssuedCard.NetworkVariantEnum.VISA, IssuedCard.NetworkVariantEnum.fromValue("visa"));
Assertions.assertNull(IssuedCard.NetworkVariantEnum.fromValue("some_future_network"));
}

@Test
public void testNegativeBalanceCompensationWarning() {
String json =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"data": {
"id": "EVJN00000000000000000000000004USD",
"amount": {
"value": -2500,
"currency": "USD"
},
"status": "booked",
"transfer": {
"categoryData": {
"type": "issuedCard",
"authorisationType": "pos",
"networkVariant": "maestro_us",
"panEntryMode": "chip",
"processingType": "pos"
},
"id": "3JNC3O5ZVFLLGV4C",
"reference": "Your internal reference for the transfer"
},
"valueDate": "2023-08-11T16:19:35+02:00",
"bookingDate": "2023-08-11T16:31:02+02:00",
"creationDate": "2023-08-11T16:19:35+02:00",
"description": "Card authorisation",
"accountHolder": {
"id": "AH00000000000000000000001",
"reference": "Your reference for the account holder",
"description": "Your description of the account holder"
},
"balanceAccount": {
"id": "BA00000000000000000000001",
"description": "Your description of the balance account from where the amount is debited."
},
"paymentInstrument": {
"id": "PI00000000000000000000001",
"description": "Your description of the payment instrument"
},
"balancePlatform": "YOUR_BALANCE_PLATFORM"
},
"environment": "test",
"timestamp": "2023-08-11T16:16:35+02:00",
"type": "balancePlatform.transaction.created"
}
Loading