Save Your First Payment Entry

The payment-warehouse-mongo artefact introduces a Spring Bean of MongoPaymentWarehouse in your application. This class implements the PaymentWarehouse interface. This interface is the entrypoint to the application.

To save your first Payment Entry you simply call the save(PaymentEntry paymentEntry) method. Below is an example.

package com.iconsolutions.ipf.core.warehouse.port.mongo;

import com.iconsolutions.ipf.core.shared.domain.context.ProcessingContext;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
import com.iconsolutions.ipf.core.warehouse.BusinessDataEntry;
import com.iconsolutions.ipf.core.warehouse.PaymentEntry;
import com.iconsolutions.ipf.core.warehouse.PaymentEntryId;
import com.iconsolutions.ipf.core.warehouse.PaymentEntryType;
import com.iconsolutions.ipf.core.warehouse.port.PaymentWarehouse;
import lombok.RequiredArgsConstructor;
import reactor.core.publisher.Mono;

import java.util.List;

@RequiredArgsConstructor
public class ExampleSave {

    private final PaymentWarehouse paymentWarehouse;

    public Mono<PaymentEntry> save() {
        var unitOfWorkId = UnitOfWorkId.createRandom();
        var parentUnitOfWorkId = UnitOfWorkId.createRandom();
        var businessData = List.of(BusinessDataEntry.builder().objectId("xyz").build());
        var paymentEntry = PaymentEntry.builder()
                .id(PaymentEntryId.of("association", 1))
                .processingContext(ProcessingContext.of(unitOfWorkId))
                .relatedUnitOfWorkId(parentUnitOfWorkId)
                .globalState("PENDING")
                .type(PaymentEntryType.TRANSACTION)
                .data(businessData)
                .build();
        return paymentWarehouse.save(paymentEntry);
    }

}
ttl and expiryDate fields do not need to be set when saving a PaymentEntry. These fields are set when Housekeeping is triggered and determine the expiration of the PaymentEntry object. If you set these fields you will be manually controlling the expiration of your objects instead of delegating it to the Housekeeping process. For more details on these two fields see Set ttl and expiryDate fields.
The fields on the PaymentEntry object are intentionally loosely defined (such as globalState) so that the fields can be tailored to your specific use-cases.