Initial commit

This commit is contained in:
2025-10-02 08:54:03 +02:00
commit ea54638227
1642 changed files with 53677 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
const { getCart, getRedirectUrl } = require("../lib/bigcommerceRestAPI")
const { bigcommerceStoreHash, bigcommerceBaseURL, bigCommerceCliendId, bigCommerceClientSecret } = require("../config")
const { getCustomerById, getLoginUrl } = require("../lib/bigcommerceRestAPI")
const { withAccount } = require("../lib/utils")
const { mapRestApiCartToGraphQL } = require("./helper")
;(function () {
if (context.user.auth()) return {}
const checkout = context.request().query("checkout")
const loggedInCheckout = context.request().query("loggedInCheckout")
if (checkout) {
if (loggedInCheckout) {
withAccount((loginClaims) => {
const cartId = context.request().param("id")
const cart = getCart(cartId)
const { checkoutURL } = getRedirectUrl(cartId)
const loginUrl = getLoginUrl(
loginClaims.bigCommerceId,
bigcommerceStoreHash,
bigcommerceBaseURL,
bigCommerceCliendId,
bigCommerceClientSecret,
checkoutURL.split(bigcommerceBaseURL).pop()
)
throw {
status: 200,
data: cart && {
cart: mapRestApiCartToGraphQL(cart),
checkoutURL: loginUrl,
},
}
})
}
}
const cartId = context.request().param("id")
const cart = getCart(cartId)
const { checkoutURL, embeddedCheckoutURL } = getRedirectUrl(cartId)
throw {
status: 200,
data: cart && {
cart: mapRestApiCartToGraphQL(cart),
checkoutURL: checkoutURL,
embeddedCheckoutURL: embeddedCheckoutURL,
},
}
})()