Search in sources :

Example 26 with PaymentDetails

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

the class PendingPaymentApi method createPendingPaymentWithHttpInfo.

/**
 * Create a pending payment
 * Sends a push notification to the user requesting payment.  **Timeout: 30s**
 *
 * @param payment Payment
 * @return ApiResponse<PaymentDetails>
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<PaymentDetails> createPendingPaymentWithHttpInfo(Payment payment) throws ApiException {
    Call call = createPendingPaymentCall(payment);
    Type localVarReturnType = new TypeToken<PaymentDetails>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.CREATE_REQUEST_ORDER);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) PaymentDetails(jp.ne.paypay.model.PaymentDetails)

Example 27 with PaymentDetails

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

the class PendingPaymentApiTest method createPendingPaymentTest.

/**
 * Create pending payment
 *
 * Sends a push notification to the user requesting payment.  **Timeout: 30s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void createPendingPaymentTest() 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.createPendingPaymentWithHttpInfo(payment)).thenReturn(paymentDetailsApiResponse);
    PaymentDetails response = api.createPendingPayment(payment);
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
    Assert.assertEquals(response.getData().getMerchantPaymentId(), "merchantPaymentId");
    Assert.assertEquals(response.getData().getUserAuthorizationId(), "userAuthorizationId");
    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 28 with PaymentDetails

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

the class PendingPaymentApiTest method getPaymentDetailsTest.

/**
 * Get payment details
 *
 * Get payment details.  **Timeout: 15s**
 *
 * @throws ApiException if the Api call fails
 */
@Test
public void getPaymentDetailsTest() 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.getPendingPaymentDetailsWithHttpInfo(merchantPaymentId)).thenReturn(paymentDetailsApiResponse);
    PaymentDetails response = api.getPaymentDetails(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 29 with PaymentDetails

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

the class PendingPaymentApiExample method createPendingPayment.

private static void createPendingPayment(final PendingPaymentApi apiInstance, Payment payment) {
    try {
        PaymentDetails result = apiInstance.createPendingPayment(payment);
        System.out.println("\nAPI RESPONSE\n------------------\n");
        System.out.println(result.getResultInfo().getCode());
        System.out.println(result);
    } catch (ApiException e) {
        System.err.println(e.getResponseBody());
    }
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiException(jp.ne.paypay.ApiException)

Aggregations

PaymentDetails (jp.ne.paypay.model.PaymentDetails)29 ApiResponse (jp.ne.paypay.ApiResponse)9 Test (org.junit.jupiter.api.Test)9 Call (com.squareup.okhttp.Call)8 Type (java.lang.reflect.Type)8 ApiException (jp.ne.paypay.ApiException)7 Payment (jp.ne.paypay.model.Payment)5 MoneyAmount (jp.ne.paypay.model.MoneyAmount)4 WalletBalance (jp.ne.paypay.model.WalletBalance)4 CaptureObject (jp.ne.paypay.model.CaptureObject)2 ArrayList (java.util.ArrayList)1 ApiClient (jp.ne.paypay.ApiClient)1 Configuration (jp.ne.paypay.Configuration)1 PaymentApi (jp.ne.paypay.api.PaymentApi)1 PendingPaymentApi (jp.ne.paypay.api.PendingPaymentApi)1 Capture (jp.ne.paypay.model.Capture)1 MerchantOrderItem (jp.ne.paypay.model.MerchantOrderItem)1 PaymentStateCaptures (jp.ne.paypay.model.PaymentStateCaptures)1 QRCodeDetails (jp.ne.paypay.model.QRCodeDetails)1 DisplayName (org.junit.jupiter.api.DisplayName)1