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: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = 'com.altapay'
version = '3.1.21'
version = '3.1.22'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/pensio/api/PensioMerchantAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ protected void setPaymentRequestParameters(
if (paymentRequest.getSessionId() != null) {
addParam(params, "session_id", paymentRequest.getSessionId());
}
addParam(params, "sale_invoice_number", paymentRequest.getSaleInvoiceNumber());
}

protected void setInvoiceReservationRequestParameters(
Expand Down Expand Up @@ -729,7 +730,6 @@ public APIResponse cardWalletAuthorize(CardWalletAuthorizeRequest request) throw
addParam(params, "payment_id", request.getPaymentId());

addParam(params, "sale_reconciliation_identifier", request.getSaleReconciliationIdentifier());
addParam(params, "sale_invoice_number", request.getSaleInvoiceNumber());
addParam(params, "sales_tax", request.getSalesTax());

setPaymentRequestParameters(request, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class CardWalletAuthorizeRequest extends PaymentRequest<CardWalletAuthori

// Optional parameters -- deprecated as others payment request attributes (reusing existing payment by payment_id)
private String saleReconciliationIdentifier;
private String saleInvoiceNumber;
private String salesTax;

public CardWalletAuthorizeRequest(String providerData, String paymentId, String terminal, String shopOrderId, Amount amount) {
Expand Down Expand Up @@ -45,15 +44,6 @@ public CardWalletAuthorizeRequest setSaleReconciliationIdentifier(String saleRec
return this;
}

public String getSaleInvoiceNumber() {
return saleInvoiceNumber;
}

public CardWalletAuthorizeRequest setSaleInvoiceNumber(String saleInvoiceNumber) {
this.saleInvoiceNumber = saleInvoiceNumber;
return this;
}

public String getSalesTax() {
return salesTax;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/pensio/api/request/PaymentRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class PaymentRequest<T extends PaymentRequest<T>>
private String giftCardToken;
private String dynamicDescriptor;
private String sessionId;
private String saleInvoiceNumber;

protected PaymentRequestConfig config;
protected CustomerInfo customerInfo;
Expand Down Expand Up @@ -255,6 +256,16 @@ public T setSessionId(String sessionId) {
return (T)this;
}

public String getSaleInvoiceNumber() {
return saleInvoiceNumber;
}

@SuppressWarnings("unchecked")
public T setSaleInvoiceNumber(String saleInvoiceNumber) {
this.saleInvoiceNumber = saleInvoiceNumber;
return (T)this;
}

public List<OrderLine> getOrderLines()
{
return orderLines;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.pensio.api;

import com.pensio.Amount;
import com.pensio.Currency;
import com.pensio.api.generated.APIResponse;
import com.pensio.api.generated.Body;
import com.pensio.api.request.PaymentRequest;
import com.pensio.api.request.PaymentReservationRequest;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

class MerchantApi_PaymentRequestParameterTests {

@Test
void createPaymentRequestEmitsSaleInvoiceNumberParam() throws PensioAPIException {
final var api = new PensioMerchantAPI("http://base", "user", "pass") {
@Override
protected APIResponse getAPIResponse(String method, HttpMethod httpMethod, Map<String, String> requestVars) {
assertEquals("createPaymentRequest", method);
assertEquals(HttpMethod.POST, httpMethod);
assertEquals("INV-12345", requestVars.get("sale_invoice_number"));
assertNull(requestVars.get("invoiceNumber"));

APIResponse response = new APIResponse();
Body body = new Body();
body.setUrl("http://checkout.pensio.com");
response.setBody(body);
return response;
}
};

PaymentRequest<?> request = new PaymentRequest<>()
.setTerminal("Terminal")
.setAmount(Amount.get(100, Currency.DKK))
.setShopOrderId("order123")
.setSaleInvoiceNumber("INV-12345");

api.createPaymentRequest(request);
}

@Test
void reservationEmitsSaleInvoiceNumberParam() throws PensioAPIException {
final var api = new PensioMerchantAPI("http://base", "user", "pass") {
@Override
protected APIResponse getAPIResponse(String method, HttpMethod httpMethod, Map<String, String> requestVars) {
assertEquals("reservation", method);
assertEquals(HttpMethod.POST, httpMethod);
assertEquals("INV-99999", requestVars.get("sale_invoice_number"));
assertNull(requestVars.get("invoiceNumber"));

APIResponse response = new APIResponse();
Body body = new Body();
response.setBody(body);
return response;
}
};

PaymentReservationRequest request = new PaymentReservationRequest("order123", "Terminal", Amount.get(100, Currency.DKK));
request.setSaleInvoiceNumber("INV-99999");

api.reservation(request);
}
}