Merged in feat/sw-3642-inject-sas-eb-payment (pull request #3243)

feat(SW-3642): Enable SAS EB payments

* Wip add SAS eb payment

* Add validate payment call

* Check booking status payment method to determine validation

* Clean up getPaymentData

* Fix PartnerPoints casing

* Add comment for validatePartnerPayment error handling

* Remove comment


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-12-11 13:23:12 +00:00
parent eb90c382b8
commit 7faa9933a2
19 changed files with 489 additions and 110 deletions

View File

@@ -1,5 +1,6 @@
import "server-only"
import { PaymentMethodEnum } from "@scandic-hotels/common/constants/paymentMethod"
import { createCounter } from "@scandic-hotels/common/telemetry"
import * as api from "../../../../api"
@@ -38,6 +39,23 @@ export const create = safeProtectedServiceProcedure
Authorization: `Bearer ${ctx.token ?? ctx.serviceToken}`,
}
const includePartnerSpecific =
inputWithoutLang.payment?.paymentMethod ===
PaymentMethodEnum.PartnerPoints
if (includePartnerSpecific) {
const session = await ctx.auth()
const token = session?.token.access_token
if (!token) {
throw new Error(
"Cannot create booking with partner points without partner token"
)
}
inputWithoutLang.partnerSpecific = {
eurobonusAccessToken: session?.token.access_token,
}
}
const apiResponse = await api.post(
api.endpoints.v1.Booking.bookings,
{
@@ -60,7 +78,6 @@ export const create = safeProtectedServiceProcedure
}
const apiJson = await apiResponse.json()
const verifiedData = createBookingSchema.safeParse(apiJson)
if (!verifiedData.success) {
metricsCreateBooking.validationError(verifiedData.error)