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);
}
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<RevertAuthResponse>
* @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);
}
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());
}
}
Aggregations