Skip to content

Commit

Permalink
Merge branch 'master' into 662-backend-set-up-sse-server-sent-events-…
Browse files Browse the repository at this point in the history
…for-event-signup-counts
  • Loading branch information
jeffplays2005 authored Sep 15, 2024
2 parents 3f3771c + f0ebbe0 commit 8966a78
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions server/src/service-layer/controllers/PaymentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,37 +118,29 @@ export class PaymentController extends Controller {
const stripeService = new StripeService()
try {
const lodgeProducts = await stripeService.getActiveLodgeProducts()
// Maps the products to the required response type MembershipStripeProductResponse in PaymentResponse

// Maps the products to the required response type LodgeStripeProductResponse in PaymentResponse
const productsValues = lodgeProducts.map((product) => {
// Checks the membership type of the product
// Checks the lodge type of the product
const lodgeType = product.metadata[
LODGE_PRICING_TYPE_KEY
] as LodgePricingTypeValues

let name: LodgePricingTypeValues

switch (lodgeType) {
case LodgePricingTypeValues.SingleFridayOrSaturday: {
name = LodgePricingTypeValues.SingleFridayOrSaturday
break
}
case LodgePricingTypeValues.Normal: {
name = LodgePricingTypeValues.Normal
break
}
}

return {
// The stripe product id
productId: product.id,
name,
// The lodge booking type
name: lodgeType,
// The product description
description: product.description,
// A boolean value if there is a lodge booking discount
discount: product.metadata.discount === "true",
// The price of the lodge booking
displayPrice: (
Number(
(product.default_price as Stripe.Price).unit_amount_decimal
) / 100
).toString(),
// The original price of the lodge booking
originalPrice: product.metadata.original_price
}
})
Expand Down

0 comments on commit 8966a78

Please sign in to comment.