Add invoice format id (#37)

This commit is contained in:
struga 2022-05-25 11:27:25 +03:00 committed by GitHub
parent b0b410cef2
commit ba28dbab68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View File

@ -12,7 +12,7 @@
</parent>
<artifactId>adapter-flow-lib</artifactId>
<version>0.1.7</version>
<version>0.1.8</version>
<packaging>jar</packaging>
<name>adapter-flow-lib</name>

View File

@ -63,12 +63,14 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
Map<String, String> adapterConfigurations = context.getOptions();
Invoice invoice = paymentInfo.getInvoice();
InvoiceDetails details = invoice.getDetails();
String invoiceFormatPaymentId = getInvoiceFormatPaymentId(payment, invoice);
return EntryStateModel.builder()
.baseRequestModel(BaseRequestModel.builder().recurrentPaymentData(recurrentPaymentData)
.mobilePaymentData(mobilePaymentData)
.cardData(cardData)
.refundData(initRefundData(paymentInfo))
.paymentId(idGenerator.get(invoice.getId()))
.paymentId(idGenerator.get(invoiceFormatPaymentId))
.invoiceFormatPaymentId(invoiceFormatPaymentId)
.createdAt(paymentInfo.getPayment().getCreatedAt())
.currency(Currency.builder()
.symbolicCode(payment.getCost().getCurrency().getSymbolicCode())
@ -91,6 +93,10 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
.build();
}
private String getInvoiceFormatPaymentId(InvoicePayment payment, Invoice invoice) {
return invoice.getId() + "." + payment.getId();
}
private String getSuccessRedirectUrl(InvoicePayment payment, Map<String, String> adapterConfigurations) {
return callbackUrlExtractor.getSuccessRedirectUrl(
adapterConfigurations,

View File

@ -49,7 +49,8 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
var mobilePaymentData = initMobilePaymentData(context, generalExitStateModel);
TransactionInfo transactionInfo = tokenInfo.getTrx();
Long orderId = idGenerator.get(tokenInfo.getPaymentTool().getId());
String invoiceFormatPaymentId = tokenInfo.getPaymentTool().getId();
Long orderId = idGenerator.get(invoiceFormatPaymentId);
var temporaryContext = temporaryContextService.getTemporaryContext(context, temporaryContextDeserializer);
return entryStateModelBuilder
@ -65,6 +66,7 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
.cardData(cardData)
.refundData(initRefundData(recurrentPaymentTool, orderId))
.paymentId(orderId)
.invoiceFormatPaymentId(invoiceFormatPaymentId)
.currency(Currency.builder()
.symbolicCode(
recurrentPaymentTool.getMinimalPaymentCost().getCurrency().getSymbolicCode())

View File

@ -20,6 +20,10 @@ public class BaseRequestModel {
* Uniq Long identifier for payment.
*/
private Long paymentId;
/**
* Uniq String identifier for payment invoice format.
*/
private String invoiceFormatPaymentId;
/**
* Uniq identifier from provider (if exists), not come in first methods.
*/