use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiExample method getPaymentDetails.
private static PaymentDetails getPaymentDetails(final PaymentApi apiInstance, final String merchantPaymentId) {
PaymentDetails result = null;
try {
result = apiInstance.getPaymentDetails(merchantPaymentId);
System.out.println("\nAPI RESPONSE\n------------------\n");
System.out.println(result);
} catch (ApiException e) {
System.err.println(e.getResponseBody());
}
return result;
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiExample method directDebitFlow.
private static void directDebitFlow(WalletApi walletApiInstance, PaymentApi paymentApi, String userAuthorizationId, boolean continuousPayment) {
String merchantPaymentId = UUID.randomUUID().toString();
WalletBalance walletBalance = getWalletBalance(walletApiInstance, userAuthorizationId);
if (walletBalance != null && walletBalance.getData().isHasEnoughBalance()) {
System.out.println("There is enough balance, now creating payment...");
PaymentDetails paymentDetails;
Payment payment = getPaymentObject(merchantPaymentId, userAuthorizationId, 1);
if (continuousPayment) {
payment.setAmount(new MoneyAmount().amount(2).currency(MoneyAmount.CurrencyEnum.JPY));
paymentDetails = createContinuousPayment(paymentApi, payment);
} else {
paymentDetails = createPayment(paymentApi, payment, false);
}
if (paymentDetails != null) {
System.out.println("Payment created successfully, Now calling the API to get payment details for payment " + "ID:" + merchantPaymentId);
String refundId = UUID.randomUUID().toString();
paymentDetails = getPaymentDetails(paymentApi, merchantPaymentId);
System.out.println("Creating Refund for the payment:" + paymentDetails.getData().getPaymentId());
createRefund(paymentApi, paymentDetails.getData().getPaymentId(), refundId);
System.out.println("Get refund details:" + refundId);
getRefundDetails(paymentApi, refundId);
System.out.println("Finally cancel the payment");
cancelPayment(paymentApi, merchantPaymentId);
}
}
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiExample method preAuthRevertAuthFlow.
private static void preAuthRevertAuthFlow(WalletApi walletApiInstance, PaymentApi paymentApi, String userAuthorizationId) {
String merchantPaymentId = UUID.randomUUID().toString();
System.out.println("Checking wallet balance...");
WalletBalance walletBalance = getWalletBalance(walletApiInstance, userAuthorizationId);
if (walletBalance != null && walletBalance.getData().isHasEnoughBalance()) {
System.out.println("There is enough balance, now creating payment...");
Payment payment = getPaymentObject(merchantPaymentId, userAuthorizationId, 1);
PaymentDetails paymentDetails = createPayment(paymentApi, payment, true);
if (paymentDetails != null) {
System.out.println("Payment Authorized successfully, Now calling the API to get payment details for payment " + "ID:" + merchantPaymentId);
paymentDetails = getPaymentDetails(paymentApi, merchantPaymentId);
if (paymentDetails != null) {
System.out.println("Reverting payment with Payment ID" + paymentDetails.getData().getPaymentId());
paymentRevertAuth(paymentApi, paymentDetails.getData().getPaymentId());
System.out.println("Check the payment details, the status should be CANCELED");
getPaymentDetails(paymentApi, merchantPaymentId);
}
}
}
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiExample method createPayment.
private static PaymentDetails createPayment(final PaymentApi apiInstance, Payment payment, boolean authorization) {
PaymentDetails result = null;
try {
if (authorization) {
result = apiInstance.createPaymentAuthorization(payment, "false");
} else {
result = apiInstance.createPayment(payment, "false");
}
System.out.println("\nAPI RESPONSE\n------------------\n");
System.out.println(result);
} catch (ApiException e) {
System.err.println(e.getResponseBody());
}
return result;
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiExample method preAuthCaptureFlow.
private static void preAuthCaptureFlow(WalletApi walletApiInstance, PaymentApi paymentApi, String userAuthorizationId) {
String merchantPaymentId = UUID.randomUUID().toString();
System.out.println("Checking wallet balance...");
int amount = 1;
WalletBalance walletBalance = getWalletBalance(walletApiInstance, userAuthorizationId);
if (walletBalance != null && walletBalance.getData().isHasEnoughBalance()) {
System.out.println("There is enough balance, now creating payment...");
Payment payment = getPaymentObject(merchantPaymentId, userAuthorizationId, amount);
PaymentDetails paymentDetails = createPayment(paymentApi, payment, true);
if (paymentDetails != null) {
System.out.println("Now capture the payment authorization for a payment, Don't capture if you need to check cancel payment");
capturePayment(paymentApi, merchantPaymentId, amount);
System.out.println("Payment created successfully, Now calling the API to get payment details for payment " + "ID:" + merchantPaymentId);
paymentDetails = getPaymentDetails(paymentApi, merchantPaymentId);
if (paymentDetails != null) {
if (paymentDetails.getData().getStatus() == PaymentState.StatusEnum.COMPLETED) {
String refundId = UUID.randomUUID().toString();
System.out.println("Creating Refund for the payment:" + paymentDetails.getData().getPaymentId());
createRefund(paymentApi, paymentDetails.getData().getPaymentId(), refundId);
System.out.println("Get refund details:" + refundId);
getRefundDetails(paymentApi, refundId);
} else {
System.out.println("Finally cancel the payment");
cancelPayment(paymentApi, merchantPaymentId);
}
}
}
}
}
Aggregations