use of jp.ne.paypay.model.MerchantOrderItemResponse in project paypayopa-sdk-java by paypay.
the class PaymentApiTest method createQRCodeTest.
/**
* Create a Code
*
* Create a Code to receive payments. **Timeout: 30s**
*
* @throws ApiException if the Api call fails
*/
@Test
public void createQRCodeTest() throws ApiException {
QRCode qrCode = new QRCode();
qrCode.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
qrCode.setMerchantPaymentId(UUID.randomUUID().toString());
qrCode.setCodeType("ORDER_QR");
qrCode.setStoreId(RandomStringUtils.randomAlphabetic(8));
qrCode.setStoreInfo("Just Bake");
qrCode.setTerminalId(RandomStringUtils.randomAlphanumeric(8));
qrCode.requestedAt(Instant.now().getEpochSecond());
qrCode.redirectUrl("https://www.justbake.in/payment");
// For Deep Link, RedirectTypeEnum.APP_DEEP_LINK
qrCode.redirectType(QRCode.RedirectTypeEnum.WEB_LINK);
qrCode.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);
qrCode.setOrderItems(merchantOrderItems);
String storeInfo = "Just Bake";
String codeType = "ORDER_QR";
String redirectUrl = "https://www.justbake.in/payment";
QRCodeDetails qrCodeDetails = new QRCodeDetails();
qrCodeDetails.setResultInfo(resultInfo);
QRCodeResponse qrCodeResponse = new QRCodeResponse();
qrCodeResponse.amount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
qrCodeResponse.setMerchantPaymentId(UUID.randomUUID().toString());
qrCodeResponse.setCodeType(codeType);
qrCodeResponse.setStoreId(RandomStringUtils.randomAlphabetic(8));
qrCodeResponse.setStoreInfo(storeInfo);
qrCodeResponse.setTerminalId(RandomStringUtils.randomAlphanumeric(8));
qrCodeResponse.requestedAt(Instant.now().getEpochSecond());
qrCodeResponse.redirectUrl(redirectUrl);
// For Deep Link, RedirectTypeEnum.APP_DEEP_LINK
qrCodeResponse.redirectType(QRCodeResponse.RedirectTypeEnum.WEB_LINK);
qrCodeResponse.setOrderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
MerchantOrderItemResponse merchantOrderItemResponse = new MerchantOrderItemResponse().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
List<MerchantOrderItemResponse> merchantOrderItemsList = new ArrayList<>();
merchantOrderItemsList.add(merchantOrderItemResponse);
qrCodeResponse.setOrderItems(merchantOrderItemsList);
qrCodeDetails.setData(qrCodeResponse);
ApiResponse<QRCodeDetails> qrCodeDetailsApiResponse = new ApiResponse<>(00001, null, qrCodeDetails);
Mockito.when(api.createQRCodeWithHttpInfo(qrCode)).thenReturn(qrCodeDetailsApiResponse);
QRCodeDetails response = api.createQRCode(qrCode);
Assert.assertNotNull(response.toString());
Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
Assert.assertEquals(response.getData().getStoreInfo(), storeInfo);
Assert.assertEquals(response.getData().getCodeType(), codeType);
Assert.assertEquals(response.getData().getRedirectUrl(), redirectUrl);
Assert.assertEquals(response.getData().getRedirectType(), QRCodeResponse.RedirectTypeEnum.WEB_LINK);
Assert.assertNotNull(response.getData());
Assert.assertNotNull(response.getData().getMerchantPaymentId());
Assert.assertNotNull(response.getData().getOrderItems());
Assert.assertNotNull(response.getData().getRequestedAt());
Assert.assertNotNull(response.getData().getTerminalId());
Assert.assertNotNull(response.getData().getOrderDescription());
}
Aggregations