Search in sources :

Example 16 with InvoiceModel

use of com.paypal.invoices.invoicesextract.model.InvoiceModel in project mirakl-hyperwallet-connector by paypal.

the class OperatorInvoiceModelToHyperwalletPaymentConverterTest method convert_shouldReturnNullWhenCommissionIsZero.

@Test
void convert_shouldReturnNullWhenCommissionIsZero() {
    // @formatter:off
    final InvoiceModel invoice = InvoiceModel.builder().destinationToken(DESTINATION_TOKEN).shopId(SHOP_ID).invoiceNumber(INVOICE_NUMBER).transferAmountToOperator(0.0D).currencyIsoCode(CURRENCY_ISO_CODE).build();
    // @formatter:on
    final HyperwalletPayment result = testObj.convert(invoice);
    assertThat(result).isNull();
}
Also used : HyperwalletPayment(com.hyperwallet.clientsdk.model.HyperwalletPayment) InvoiceModel(com.paypal.invoices.invoicesextract.model.InvoiceModel) Test(org.junit.jupiter.api.Test)

Example 17 with InvoiceModel

use of com.paypal.invoices.invoicesextract.model.InvoiceModel in project mirakl-hyperwallet-connector by paypal.

the class OperatorInvoiceModelToHyperwalletPaymentConverterTest method convert_shouldConvertAnInvoiceIntoHyperwalletPayment.

@Test
void convert_shouldConvertAnInvoiceIntoHyperwalletPayment() {
    final Double transferAmountToOperator = 100.10D;
    when(hyperwalletSDKServiceMock.getProgramTokenByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(PROGRAM_TOKEN);
    when(invoicesOperatorCommissionsConfigMock.getBankAccountToken(HYPERWALLET_PROGRAM)).thenReturn(OPERATOR_BANK_ACCOUNT_TOKEN);
    // @formatter:off
    final InvoiceModel invoice = InvoiceModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).destinationToken(DESTINATION_TOKEN).shopId(SHOP_ID).invoiceNumber(INVOICE_NUMBER).transferAmountToOperator(transferAmountToOperator).currencyIsoCode(CURRENCY_ISO_CODE).build();
    // @formatter:on
    final HyperwalletPayment result = testObj.convert(invoice);
    assertThat(result.getDestinationToken()).isEqualTo(OPERATOR_BANK_ACCOUNT_TOKEN);
    assertThat(result.getClientPaymentId()).isEqualTo(INVOICE_NUMBER + PAYMENT_OPERATOR_SUFFIX);
    assertThat(result.getAmount()).isEqualTo(transferAmountToOperator);
    assertThat(result.getCurrency()).isEqualTo(CURRENCY_ISO_CODE);
    assertThat(result.getPurpose()).isEqualTo("OTHER");
    assertThat(result.getProgramToken()).isEqualTo(PROGRAM_TOKEN);
}
Also used : HyperwalletPayment(com.hyperwallet.clientsdk.model.HyperwalletPayment) InvoiceModel(com.paypal.invoices.invoicesextract.model.InvoiceModel) Test(org.junit.jupiter.api.Test)

Aggregations

InvoiceModel (com.paypal.invoices.invoicesextract.model.InvoiceModel)17 Test (org.junit.jupiter.api.Test)16 Date (java.util.Date)9 LocalDateTime (java.time.LocalDateTime)7 HyperwalletPayment (com.hyperwallet.clientsdk.model.HyperwalletPayment)5 MiraklGetShopsRequest (com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest)4 MiraklErrorResponseBean (com.mirakl.client.core.error.MiraklErrorResponseBean)2 MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)2 MiraklGetInvoicesRequest (com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest)2 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)1 MiraklAccountingDocumentPaymentStatus (com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentPaymentStatus)1 PENDING (com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentPaymentStatus.PENDING)1 AUTO_INVOICE (com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentType.AUTO_INVOICE)1 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)1 MiraklShops (com.mirakl.client.mmp.domain.shop.MiraklShops)1 MiraklAccountingDocumentState (com.mirakl.client.mmp.request.payment.invoice.MiraklAccountingDocumentState)1 COMPLETE (com.mirakl.client.mmp.request.payment.invoice.MiraklAccountingDocumentState.COMPLETE)1 MIRAKL_MAX_RESULTS_PER_PAGE (com.paypal.infrastructure.constants.HyperWalletConstants.MIRAKL_MAX_RESULTS_PER_PAGE)1 Converter (com.paypal.infrastructure.converter.Converter)1 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)1