use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.
the class PaymentApiTest method setUp.
@BeforeEach
public void setUp() {
apiClient = Mockito.mock(ApiClient.class);
api.setApiClient(apiClient);
resultInfo = new ResultInfo();
resultInfo.setMessage("SUCCESS");
payment = new Payment();
payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
merchantOrderItems.add(merchantOrderItem);
payment.orderItems(merchantOrderItems);
}
use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.
the class PendingPaymentApiTest method setUp.
@BeforeEach
public void setUp() {
apiClient = Mockito.mock(ApiClient.class);
api.setApiClient(apiClient);
paymentApi.setApiClient(apiClient);
resultInfo = new ResultInfo();
resultInfo.setMessage("SUCCESS");
payment = new Payment();
payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
merchantOrderItems.add(merchantOrderItem);
payment.orderItems(merchantOrderItems);
}
use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.
the class PaymentApiTest method createPaymentTest.
/**
* Create a payment
*
* Create a direct debit payment and start the money transfer. **Timeout: 30s**
*
* @throws ApiException if the Api call fails
*/
@Test
public void createPaymentTest() throws ApiException {
Payment payment = new Payment();
payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
payment.setMerchantPaymentId("merchantPaymentId");
payment.setUserAuthorizationId("userAuthorizationId");
payment.setRequestedAt(Instant.now().getEpochSecond());
payment.setStoreId(RandomStringUtils.randomAlphabetic(8));
payment.setTerminalId(RandomStringUtils.randomAlphanumeric(8));
payment.setOrderReceiptNumber(RandomStringUtils.randomAlphanumeric(8));
payment.setOrderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
merchantOrderItems.add(merchantOrderItem);
payment.setOrderItems(new ArrayList<MerchantOrderItem>(merchantOrderItems));
PaymentDetails paymentDetails = new PaymentDetails();
paymentDetails.setResultInfo(resultInfo);
String agreeSimilarTransaction = "True";
ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, paymentDetails);
Mockito.when(api.createPaymentWithHttpInfo(payment, agreeSimilarTransaction)).thenReturn(paymentDetailsApiResponse);
PaymentDetails response = api.createPayment(payment, agreeSimilarTransaction);
Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
use of jp.ne.paypay.model.Payment 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.Payment 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);
}
}
}
}
Aggregations