Search in sources :

Example 1 with RevertAuthResponse

use of jp.ne.paypay.model.RevertAuthResponse 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 2 with RevertAuthResponse

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

the class PaymentApi method revertAuthWithHttpInfo.

/**
 * Revert a payment authorization
 * This api is used in case, the merchant wants to cancel the payment authorization because of cancellation of the order by the user.  **Timeout: 30s**
 *
 * @param body Revert Authorized Order Request (optional)
 * @return ApiResponse&lt;RevertAuthResponse&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<RevertAuthResponse> revertAuthWithHttpInfo(Object body) throws ApiException {
    Call call = revertAuthValidateBeforeCall(body);
    Type localVarReturnType = new TypeToken<RevertAuthResponse>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.REVERT_AUTHORIZE);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) RevertAuthResponse(jp.ne.paypay.model.RevertAuthResponse)

Example 3 with RevertAuthResponse

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

the class PaymentApiExample method paymentRevertAuth.

private static void paymentRevertAuth(final PaymentApi apiInstance, String paymentId) {
    try {
        PaymentStateRevert payment = new PaymentStateRevert();
        payment.setPaymentId(paymentId);
        payment.setMerchantRevertId(UUID.randomUUID().toString());
        RevertAuthResponse result = apiInstance.revertAuth(payment);
        System.out.println("\nAPI RESPONSE\n------------------\n");
        System.out.println(result);
    } catch (ApiException e) {
        System.err.println(e.getResponseBody());
    }
}
Also used : PaymentStateRevert(jp.ne.paypay.model.PaymentStateRevert) RevertAuthResponse(jp.ne.paypay.model.RevertAuthResponse) ApiException(jp.ne.paypay.ApiException)

Aggregations

RevertAuthResponse (jp.ne.paypay.model.RevertAuthResponse)3 PaymentStateRevert (jp.ne.paypay.model.PaymentStateRevert)2 Call (com.squareup.okhttp.Call)1 Type (java.lang.reflect.Type)1 ApiException (jp.ne.paypay.ApiException)1 ApiResponse (jp.ne.paypay.ApiResponse)1 RevertAuthResponseData (jp.ne.paypay.model.RevertAuthResponseData)1 Test (org.junit.jupiter.api.Test)1