Search in sources :

Example 1 with RefundDetails

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

the class PendingPaymentApiTest method getRefundDetailsTest.

/**
 * Get refund details
 *
 * Get refund details.  **Timeout: 15s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void getRefundDetailsTest() throws ApiException {
    String merchantRefundId = "refundId";
    RefundDetails refundDetails = new RefundDetails();
    refundDetails.setResultInfo(resultInfo);
    ApiResponse<RefundDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, refundDetails);
    Mockito.when(apiClient.escapeString(merchantRefundId)).thenReturn(merchantRefundId);
    Mockito.when(paymentApi.getRefundDetailsWithHttpInfo(merchantRefundId)).thenReturn(paymentDetailsApiResponse);
    RefundDetails response = api.getRefundDetails(merchantRefundId);
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
Also used : RefundDetails(jp.ne.paypay.model.RefundDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 2 with RefundDetails

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

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

the class PaymentApiTest method getRefundDetailsTest.

/**
 * Get refund details
 *
 * Get refund details.  **Timeout: 15s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void getRefundDetailsTest() throws ApiException {
    String merchantRefundId = "refundId";
    RefundDetails refundDetails = new RefundDetails();
    refundDetails.setResultInfo(resultInfo);
    ApiResponse<RefundDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, refundDetails);
    Mockito.when(apiClient.escapeString(merchantRefundId)).thenReturn(merchantRefundId);
    Mockito.when(api.getRefundDetailsWithHttpInfo(merchantRefundId)).thenReturn(paymentDetailsApiResponse);
    RefundDetails response = api.getRefundDetails(merchantRefundId);
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
Also used : RefundDetails(jp.ne.paypay.model.RefundDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 4 with RefundDetails

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

the class PaymentApi method getRefundDetailsWithHttpInfo.

/**
 * Get refund details
 * Get refund details.  **Timeout: 15s**
 *
 * @param merchantRefundId (required)
 * @return ApiResponse&lt;RefundDetails&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<RefundDetails> getRefundDetailsWithHttpInfo(String merchantRefundId) throws ApiException {
    Call call = getRefundDetailsValidateBeforeCall(merchantRefundId);
    Type localVarReturnType = new TypeToken<RefundDetails>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.GET_REFUND);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) RefundDetails(jp.ne.paypay.model.RefundDetails)

Example 5 with RefundDetails

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

the class PaymentApiExample method createRefund.

private static void createRefund(final PaymentApi apiInstance, String paymentId, String refundId) {
    try {
        Refund refund = getRefundObject(paymentId, refundId);
        RefundDetails result = apiInstance.refundPayment(refund);
        System.out.println("\nAPI RESPONSE\n------------------\n");
        System.out.println(result);
    } catch (ApiException e) {
        System.err.println(e.getResponseBody());
    }
}
Also used : Refund(jp.ne.paypay.model.Refund) RefundDetails(jp.ne.paypay.model.RefundDetails) ApiException(jp.ne.paypay.ApiException)

Aggregations

RefundDetails (jp.ne.paypay.model.RefundDetails)9 ApiResponse (jp.ne.paypay.ApiResponse)4 Refund (jp.ne.paypay.model.Refund)4 Test (org.junit.jupiter.api.Test)4 ApiException (jp.ne.paypay.ApiException)3 Call (com.squareup.okhttp.Call)2 Type (java.lang.reflect.Type)2 MoneyAmount (jp.ne.paypay.model.MoneyAmount)2