欧州 PSD2 規制の遵守
SDK を使用すると、PSD2 EEA 規制への準拠が容易になります。
決済サービス指令 2 (PSD2) は EEA の規制であり、EEA 加盟国で発行されたクレジットカードが含まれるすべての取引について、支払いと予約のプロセスの変更が求められます。PSD2 の詳細についてはこちらを参照してください。
1. ショップ
空室状況を取得する
GetAvailabilityOperationParams getAvailabilityOperationParams = GetAvailabilityOperationParams.builder()
.checkin("YYYY-MM-DD")
.checkout("YYYY-MM-DD")
.currency("USD")
.language("en_US")
.countryCode("US")
.occupancy(List.of("OCCUPANCY"))
.propertyId(List.of("PROPERTY ID"))
.customerIp("127.0.0.1")
.ratePlanCount(BigDecimal.ONE)
.salesChannel("SALES CHANNEL")
.salesEnvironment("SALES ENVIRONMENT")
.build();
GetAvailabilityOperation getAvailabilityOperation = new GetAvailabilityOperation(getAvailabilityOperationParams);
Response<List<Property>> propertiesResponse = rapidClient.execute(getAvailabilityOperation);
客室料金を確認する
Property property = propertiesResponse.getData().get(0);
if (!(property instanceof PropertyAvailability)) {
return;
}
PropertyAvailability propertyAvailability = (PropertyAvailability) property;
Link propertyAvailabilityLink = propertyAvailability.getRooms().get(0).getRates().get(0).getBedGroups().entrySet().stream().findFirst().get().getValue().getLinks().getPriceCheck(); // selecting the first rate for the first room
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(propertyAvailabilityLink);
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
RoomPriceCheck roomPriceCheck = response.getData();
2. 予約
支払いセッションを作成する
Link paymentSessionLink = roomPriceCheck.getLinks().getPaymentSession();
PostPaymentSessionsOperationContext postPaymentSessionsOperationContext = PostPaymentSessionsOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PostPaymentSessionsOperation paymentSessionsOperation = new PostPaymentSessionsOperation(paymentSessionLink, postPaymentSessionsOperationContext, createPaymentSessionRequest());
Response<PaymentSessions> paymentSessionsResponse = rapidClient.execute(paymentSessionsOperation);
PaymentSessions paymentSessions = paymentSessionsResponse.getData();
JavaScript チャレンジを渡す
2FA が必要な場合は、レスポンスには encodedChallengeConfig
も含まれます。返された encodedChallengeConfig
と paymentSessionId
を、JavaScript の challenge メソッドにパラメータとして渡す必要があります。
旅程を作成する
Link postItineraryLink = roomPriceCheck.getLinks().getBook(); // from the first step
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryLink, postItineraryOperationContext, createItineraryRequest(true));
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
ItineraryCreation itineraryCreation = response.getData();
支払いセッションを完了する
Link completePaymentSessionLink = itineraryCreation.getLinks().getCompletePaymentSession();
PutCompletePaymentSessionOperationContext putCompletePaymentSessionOperationContext = PutCompletePaymentSessionOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PutCompletePaymentSessionOperation completePaymentSessionOperation = new PutCompletePaymentSessionOperation(completePaymentSessionLink, putCompletePaymentSessionOperationContext);
Response<CompletePaymentSession> completePaymentSessionResponse = rapidClient.execute(completePaymentSessionOperation);
CompletePaymentSession completePaymentSession = completePaymentSessionResponse.getData();
保留予約を再開する
Link resumeLink = itineraryCreation.getLinks().getResume();
PutResumeBookingOperationContext putResumeBookingOperationContext = PutResumeBookingOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PutResumeBookingOperation putResumeBookingOperation = new PutResumeBookingOperation(resumeLink, putResumeBookingOperationContext);
rapidClient.execute(putResumeBookingOperation);