Search in sources :

Example 1 with MoneyAmount

use of jp.ne.paypay.model.MoneyAmount in project paypayopa-sdk-java by paypay.

the class PaymentApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    payment = new Payment();
    payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
    MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
    merchantOrderItems.add(merchantOrderItem);
    payment.orderItems(merchantOrderItems);
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with MoneyAmount

use of jp.ne.paypay.model.MoneyAmount in project paypayopa-sdk-java by paypay.

the class PaymentApiTest method createQRCodeTest.

/**
 * Create a Code
 *
 * Create a Code to receive payments.  **Timeout: 30s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void createQRCodeTest() throws ApiException {
    QRCode qrCode = new QRCode();
    qrCode.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    qrCode.setMerchantPaymentId(UUID.randomUUID().toString());
    qrCode.setCodeType("ORDER_QR");
    qrCode.setStoreId(RandomStringUtils.randomAlphabetic(8));
    qrCode.setStoreInfo("Just Bake");
    qrCode.setTerminalId(RandomStringUtils.randomAlphanumeric(8));
    qrCode.requestedAt(Instant.now().getEpochSecond());
    qrCode.redirectUrl("https://www.justbake.in/payment");
    // For Deep Link, RedirectTypeEnum.APP_DEEP_LINK
    qrCode.redirectType(QRCode.RedirectTypeEnum.WEB_LINK);
    qrCode.setOrderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
    MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
    merchantOrderItems.add(merchantOrderItem);
    qrCode.setOrderItems(merchantOrderItems);
    String storeInfo = "Just Bake";
    String codeType = "ORDER_QR";
    String redirectUrl = "https://www.justbake.in/payment";
    QRCodeDetails qrCodeDetails = new QRCodeDetails();
    qrCodeDetails.setResultInfo(resultInfo);
    QRCodeResponse qrCodeResponse = new QRCodeResponse();
    qrCodeResponse.amount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    qrCodeResponse.setMerchantPaymentId(UUID.randomUUID().toString());
    qrCodeResponse.setCodeType(codeType);
    qrCodeResponse.setStoreId(RandomStringUtils.randomAlphabetic(8));
    qrCodeResponse.setStoreInfo(storeInfo);
    qrCodeResponse.setTerminalId(RandomStringUtils.randomAlphanumeric(8));
    qrCodeResponse.requestedAt(Instant.now().getEpochSecond());
    qrCodeResponse.redirectUrl(redirectUrl);
    // For Deep Link, RedirectTypeEnum.APP_DEEP_LINK
    qrCodeResponse.redirectType(QRCodeResponse.RedirectTypeEnum.WEB_LINK);
    qrCodeResponse.setOrderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
    MerchantOrderItemResponse merchantOrderItemResponse = new MerchantOrderItemResponse().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    List<MerchantOrderItemResponse> merchantOrderItemsList = new ArrayList<>();
    merchantOrderItemsList.add(merchantOrderItemResponse);
    qrCodeResponse.setOrderItems(merchantOrderItemsList);
    qrCodeDetails.setData(qrCodeResponse);
    ApiResponse<QRCodeDetails> qrCodeDetailsApiResponse = new ApiResponse<>(00001, null, qrCodeDetails);
    Mockito.when(api.createQRCodeWithHttpInfo(qrCode)).thenReturn(qrCodeDetailsApiResponse);
    QRCodeDetails response = api.createQRCode(qrCode);
    Assert.assertNotNull(response.toString());
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
    Assert.assertEquals(response.getData().getStoreInfo(), storeInfo);
    Assert.assertEquals(response.getData().getCodeType(), codeType);
    Assert.assertEquals(response.getData().getRedirectUrl(), redirectUrl);
    Assert.assertEquals(response.getData().getRedirectType(), QRCodeResponse.RedirectTypeEnum.WEB_LINK);
    Assert.assertNotNull(response.getData());
    Assert.assertNotNull(response.getData().getMerchantPaymentId());
    Assert.assertNotNull(response.getData().getOrderItems());
    Assert.assertNotNull(response.getData().getRequestedAt());
    Assert.assertNotNull(response.getData().getTerminalId());
    Assert.assertNotNull(response.getData().getOrderDescription());
}
Also used : LinkQRCodeResponse(jp.ne.paypay.model.LinkQRCodeResponse) QRCodeResponse(jp.ne.paypay.model.QRCodeResponse) QRCode(jp.ne.paypay.model.QRCode) AccountLinkQRCode(jp.ne.paypay.model.AccountLinkQRCode) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) MerchantOrderItemResponse(jp.ne.paypay.model.MerchantOrderItemResponse) QRCodeDetails(jp.ne.paypay.model.QRCodeDetails) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 3 with MoneyAmount

use of jp.ne.paypay.model.MoneyAmount in project paypayopa-sdk-java by paypay.

the class PendingPaymentApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    paymentApi.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    payment = new Payment();
    payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
    MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
    merchantOrderItems.add(merchantOrderItem);
    payment.orderItems(merchantOrderItems);
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with MoneyAmount

use of jp.ne.paypay.model.MoneyAmount in project paypayopa-sdk-java by paypay.

the class PendingPaymentApiTest method refundPaymentTest.

/**
 * Refund a payment
 *
 * Refund a payment.  **Timeout: 30s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void refundPaymentTest() throws ApiException {
    Refund refund = new Refund();
    refund.setAmount(new MoneyAmount().amount(1).currency(MoneyAmount.CurrencyEnum.JPY));
    refund.setMerchantRefundId("refundId");
    refund.setPaymentId("paymentId");
    refund.setReason("Testing");
    refund.setRequestedAt(Instant.now().getEpochSecond());
    RefundDetails refundDetails = new RefundDetails();
    refundDetails.setResultInfo(resultInfo);
    refund.setStatus(RefundState.StatusEnum.CREATED);
    refundDetails.setData(refund);
    ApiResponse<RefundDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, refundDetails);
    Mockito.when(paymentApi.refundPaymentWithHttpInfo(refund)).thenReturn(paymentDetailsApiResponse);
    Assert.assertNotNull(refund.toString());
    RefundDetails response = api.refundPayment(refund);
    Assert.assertNotNull(response.toString());
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
Also used : Refund(jp.ne.paypay.model.Refund) RefundDetails(jp.ne.paypay.model.RefundDetails) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 5 with MoneyAmount

use of jp.ne.paypay.model.MoneyAmount in project paypayopa-sdk-java by paypay.

the class CashbackApiExample method getReverseCashbackObject.

private static ReverseCashback getReverseCashbackObject(String merchantCashbackReversalId, String merchantCashbackId, int amount) {
    ReverseCashback reverseCashback = new ReverseCashback();
    reverseCashback.setMerchantCashbackReversalId(merchantCashbackReversalId);
    reverseCashback.setMerchantCashbackId(merchantCashbackId);
    reverseCashback.setRequestedAt(Instant.now().getEpochSecond());
    reverseCashback.setAmount(new MoneyAmount().amount(amount).currency(MoneyAmount.CurrencyEnum.JPY));
    return reverseCashback;
}
Also used : ReverseCashback(jp.ne.paypay.model.ReverseCashback) MoneyAmount(jp.ne.paypay.model.MoneyAmount)

Aggregations

MoneyAmount (jp.ne.paypay.model.MoneyAmount)15 ArrayList (java.util.ArrayList)5 ApiResponse (jp.ne.paypay.ApiResponse)5 MerchantOrderItem (jp.ne.paypay.model.MerchantOrderItem)5 Payment (jp.ne.paypay.model.Payment)5 Test (org.junit.jupiter.api.Test)5 PaymentDetails (jp.ne.paypay.model.PaymentDetails)4 ApiClient (jp.ne.paypay.ApiClient)3 Refund (jp.ne.paypay.model.Refund)3 ResultInfo (jp.ne.paypay.model.ResultInfo)3 ReverseCashback (jp.ne.paypay.model.ReverseCashback)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ApiException (jp.ne.paypay.ApiException)2 AccountLinkQRCode (jp.ne.paypay.model.AccountLinkQRCode)2 CaptureObject (jp.ne.paypay.model.CaptureObject)2 Cashback (jp.ne.paypay.model.Cashback)2 QRCode (jp.ne.paypay.model.QRCode)2 QRCodeDetails (jp.ne.paypay.model.QRCodeDetails)2 RefundDetails (jp.ne.paypay.model.RefundDetails)2 Capture (jp.ne.paypay.model.Capture)1