Search in sources :

Example 1 with RevertAuthResponseData

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

Aggregations

ApiResponse (jp.ne.paypay.ApiResponse)1 PaymentStateRevert (jp.ne.paypay.model.PaymentStateRevert)1 RevertAuthResponse (jp.ne.paypay.model.RevertAuthResponse)1 RevertAuthResponseData (jp.ne.paypay.model.RevertAuthResponseData)1 Test (org.junit.jupiter.api.Test)1