Search in sources :

Example 1 with ApiResponse

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

the class PaymentApiTest method createContinuousPaymentTest.

/**
 * Create continuous payment
 *
 * Create a continuous payment and start the money transfer.  **Timeout: 30s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void createContinuousPaymentTest() throws ApiException {
    PaymentDetails paymentDetails = new PaymentDetails();
    paymentDetails.resultInfo(resultInfo);
    payment.status(PaymentState.StatusEnum.COMPLETED).authorizedAt(Instant.now().getNano()).paymentId("paymentId");
    paymentDetails.data(payment);
    Assert.assertNotNull(payment.toString());
    ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(90001, null, paymentDetails);
    Mockito.when(api.createContinuousPaymentWithHttpInfo(payment)).thenReturn(paymentDetailsApiResponse);
    PaymentDetails response = api.createContinuousPayment(payment);
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
    Assert.assertEquals(response.getData().getMerchantPaymentId(), "merchantPaymentId");
    Assert.assertEquals(response.getData().getUserAuthorizationId(), "userAuthorizationId");
    Assert.assertEquals(response.getData().getPaymentId(), "paymentId");
    Assert.assertEquals(response.getData().getStatus(), PaymentState.StatusEnum.COMPLETED);
    Assert.assertNotNull(response.getData());
    Assert.assertNotNull(response.getData().getTerminalId());
    Assert.assertNotNull(response.getData().getOrderReceiptNumber());
    Assert.assertNotNull(response.getData().getAmount());
    Assert.assertNotNull(response.getData().getRequestedAt());
    Assert.assertNotNull(response.getData().getOrderItems());
    Assert.assertNotNull(response.getData().getAuthorizedAt());
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ApiResponse

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

the class PaymentApiTest method getCodePaymentDetailsTest.

/**
 * Get payment details
 *
 * Get payment details.  **Timeout: 15s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void getCodePaymentDetailsTest() throws ApiException {
    String merchantPaymentId = "merchantPaymentId";
    PaymentDetails paymentDetails = new PaymentDetails();
    paymentDetails.setResultInfo(resultInfo);
    ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, paymentDetails);
    Mockito.when(apiClient.escapeString(merchantPaymentId)).thenReturn(merchantPaymentId);
    Mockito.when(api.getCodesPaymentDetailsWithHttpInfo(merchantPaymentId)).thenReturn(paymentDetailsApiResponse);
    PaymentDetails response = api.getCodesPaymentDetails(merchantPaymentId);
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 3 with ApiResponse

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

the class PaymentApiTest method createPaymentAuthorizationTest.

/**
 * Create a payment Authorization
 *
 * Create a direct debit payment and start the money transfer.  **Timeout: 30s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void createPaymentAuthorizationTest() throws ApiException {
    PaymentDetails paymentDetails = new PaymentDetails();
    paymentDetails.setResultInfo(resultInfo);
    payment.setStatus(PaymentState.StatusEnum.AUTHORIZED);
    payment.setAuthorizedAt(Instant.now().getNano());
    payment.setPaymentId("paymentId");
    paymentDetails.setData(payment);
    String agreeSimilarTransaction = "True";
    ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, paymentDetails);
    Mockito.when(api.createPaymentAuthorizationWithHttpInfo(payment, agreeSimilarTransaction)).thenReturn(paymentDetailsApiResponse);
    PaymentDetails response = api.createPaymentAuthorization(payment, agreeSimilarTransaction);
    Assert.assertNotNull(response.toString());
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
    Assert.assertEquals(response.getData().getMerchantPaymentId(), "merchantPaymentId");
    Assert.assertEquals(response.getData().getUserAuthorizationId(), "userAuthorizationId");
    Assert.assertEquals(response.getData().getPaymentId(), "paymentId");
    Assert.assertEquals(response.getData().getStatus(), PaymentState.StatusEnum.AUTHORIZED);
    Assert.assertNotNull(response.getData());
    Assert.assertNotNull(response.getData().getTerminalId());
    Assert.assertNotNull(response.getData().getOrderReceiptNumber());
    Assert.assertNotNull(response.getData().getAmount());
    Assert.assertNotNull(response.getData().getRequestedAt());
    Assert.assertNotNull(response.getData().getOrderItems());
    Assert.assertNotNull(response.getData().getAuthorizedAt());
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 4 with ApiResponse

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

the class PaymentApiTest method revertAuthTest.

/**
 * Revert a payment authorization
 *
 * Revert a payment authorization.  **Timeout: 30s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void revertAuthTest() throws ApiException {
    PaymentStateRevert paymentStateRevert = new PaymentStateRevert();
    paymentStateRevert.setPaymentId(UUID.randomUUID().toString());
    paymentStateRevert.setMerchantRevertId(UUID.randomUUID().toString());
    paymentStateRevert.setRequestedAt(Instant.now().getEpochSecond());
    RevertAuthResponse revertAuthResponse = new RevertAuthResponse();
    revertAuthResponse.setResultInfo(resultInfo);
    RevertAuthResponseData revertAuthResponseData = new RevertAuthResponseData();
    revertAuthResponseData.setPaymentId(paymentStateRevert.getPaymentId());
    revertAuthResponseData.setAcceptedAt(Instant.now().getNano());
    revertAuthResponseData.setRequestedAt(Instant.now().getEpochSecond());
    revertAuthResponseData.setReason("Order Cancelled");
    revertAuthResponseData.setStatus(RevertAuthResponseData.StatusEnum.CANCELED);
    revertAuthResponse.setData(revertAuthResponseData);
    ApiResponse<RevertAuthResponse> revertAuthResponseApiResponse = new ApiResponse<>(00001, null, revertAuthResponse);
    Mockito.when(api.revertAuthWithHttpInfo(paymentStateRevert)).thenReturn(revertAuthResponseApiResponse);
    Assert.assertNotNull(paymentStateRevert.toString());
    RevertAuthResponse response = api.revertAuth(paymentStateRevert);
    Assert.assertNotNull(response.toString());
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
    Assert.assertNotNull(response.getData());
    Assert.assertNotNull(response.getData().getAcceptedAt());
    Assert.assertNotNull(response.getData().getRequestedAt());
    Assert.assertEquals(response.getData().getReason(), "Order Cancelled");
    Assert.assertEquals(response.getData().getStatus(), RevertAuthResponseData.StatusEnum.CANCELED);
}
Also used : RevertAuthResponseData(jp.ne.paypay.model.RevertAuthResponseData) PaymentStateRevert(jp.ne.paypay.model.PaymentStateRevert) RevertAuthResponse(jp.ne.paypay.model.RevertAuthResponse) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 5 with ApiResponse

use of jp.ne.paypay.ApiResponse 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)

Aggregations

ApiResponse (jp.ne.paypay.ApiResponse)29 Test (org.junit.jupiter.api.Test)29 PaymentDetails (jp.ne.paypay.model.PaymentDetails)9 MoneyAmount (jp.ne.paypay.model.MoneyAmount)5 NotDataResponse (jp.ne.paypay.model.NotDataResponse)5 ArrayList (java.util.ArrayList)4 RefundDetails (jp.ne.paypay.model.RefundDetails)4 ReverseCashbackDetails (jp.ne.paypay.model.ReverseCashbackDetails)4 AccountLinkQRCode (jp.ne.paypay.model.AccountLinkQRCode)3 LinkQRCodeResponse (jp.ne.paypay.model.LinkQRCodeResponse)3 AuthorizationScope (jp.ne.paypay.model.AuthorizationScope)2 CashbackDetails (jp.ne.paypay.model.CashbackDetails)2 MerchantOrderItem (jp.ne.paypay.model.MerchantOrderItem)2 QRCodeDetails (jp.ne.paypay.model.QRCodeDetails)2 Refund (jp.ne.paypay.model.Refund)2 TypeToken (com.google.gson.reflect.TypeToken)1 MediaType (com.squareup.okhttp.MediaType)1 Request (com.squareup.okhttp.Request)1 RequestBody (com.squareup.okhttp.RequestBody)1 Response (com.squareup.okhttp.Response)1