@misiki/gocommerce-connector 0.31.1 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutQuote, v as CheckoutResult, w as CheckoutService, x as CmsPage, y as Collection, z as CollectionService, D as Company, E as CompanyOrder, F as ContactService, G as CountryService, H as CouponService, I as Credentials, J as Credit, K as CurrencyService, L as Customer, M as CustomizerDesign, N as CustomizerDocument, O as CustomizerEditor, P as CustomizerFile, Q as CustomizerLayer, R as CustomizerSavedDesign, S as CustomizerService, T as CustomizerSetup, U as CustomizerUpload, V as DealService, W as DemoRequestService, X as EngineRequest, Y as EnquiryService, Z as Envelope, _ as FacetValue, $ as Faq, a0 as FaqService, a1 as FeedbackService, a2 as FooterSettings, a3 as FreeShipping, a4 as Fulfillment, a5 as GalleryService, a6 as GooglePlace, a7 as GoogleReview, a8 as GoogleReviewService, a9 as GoogleReviews, aa as GoogleSurvey, ab as HeaderSettings, ac as HomeLayout, ad as HomeLayoutSection, ae as HomeService, af as IdentityAddress, ag as InitService, ah as Invitation, ai as LayoutCollection, aj as LayoutPage, ak as LayoutService, al as Lead, am as ListMeta, an as MeilisearchService, ao as Member, ap as Menu, aq as MenuItem, ar as MenuService, as as MenuSummary, at as Money, au as NewsletterService, av as Offer, aw as OpeningHours, ax as Order, ay as OrderLine, az as OrderService, aA as PageLayout, aB as PageService, aC as PaymentIntent, aD as PaymentMethodService, aE as Plugin, aF as PluginService, aF as PluginsService, aG as PopularSearchService, aH as PopularityService, aI as Postcode, aJ as Product, aK as ProductFacets, aL as ProductOption, aM as ProductService, aN as ProfileService, aO as Quote, aP as REDIRECT_GATEWAYS, aQ as ReelsService, aR as RegionService, aS as RejectedLine, aT as Review, aU as ReviewPage, aV as ReviewService, aW as SearchDoc, aX as SearchResult, aY as SearchService, aZ as SettingService, aZ as SettingsService, a_ as ShippingRate, a$ as SiteChrome, b0 as SiteFooter, b1 as SiteHeader, b2 as SocialLink, b3 as StateService, b4 as StoreClosed, b5 as StorePass, b6 as StorePassAnswer, b7 as StoreProfile, b8 as StoreService, b9 as StoreUnlock, ba as StorefrontCategory, bb as StorefrontMenu, bc as StorefrontOrder, bd as StorefrontProduct, be as ThemeSettings, bf as ThemeSettingsResult, bg as UploadService, bh as UserService, bi as Variant, bj as VariantImage, bk as VariantService, bl as VarniCustomDesignService, bm as VarniCustomProductService, bn as Vendor, bo as VendorService, bp as WarrantyService, bq as WhatsappConsent, br as WhatsappConsentOffer, bs as WhatsappService, bt as Wishlist, bu as WishlistItem, bv as WishlistService, bw as addressService, bx as authService, by as autocompleteService, bz as b2bService, bA as bannerService, bB as blogService, bC as cartService, bD as categoryService, bE as chatService, bF as checkoutService, bG as collectionService, bH as contactService, bI as countryService, bJ as couponService, bK as currencyExponent, bL as currencyService, bM as customizerService, bN as dealService, bO as demoRequestService, bP as emptyCart, bQ as emptyPage, bR as enquiryService, bS as faqService, bT as feedbackService, bU as fromEngineAddress, bV as fromIdentityAddress, bW as fromSearchDoc, bX as galleryService, bY as googleReviewService, bZ as homeService, b_ as initService, b$ as layoutService, c0 as mediaUrl, c1 as meilisearchService, c2 as menuService, c3 as minorToMajor, c4 as newsletterService, c5 as orderService, c6 as ownDomain, c7 as pageService, c8 as paymentMethodService, c9 as pluginService, ca as pluginsService, cb as popularSearchService, cc as popularityService, cd as priceOf, ce as productImages, cf as productService, cg as productVideos, ch as profileService, ci as qs, cj as reelsService, ck as regionService, cl as reviewService, cm as searchService, cn as setRequestHost, co as settingService, cp as settingsService, cq as stateService, cr as staticStore, cs as storeForHost, ct as storeService, cu as toAddOn, cv as toCart, cw as toCartLine, cx as toCartOffer, cy as toCategory, cz as toCheckoutQuote, cA as toCmsPage, cB as toCollection, cC as toEngineAddress, cD as toFreeShipping, cE as toIdentityAddress, cF as toMajor, cG as toMinor, cH as toOrder, cI as toPage, cJ as toProduct, cK as toRating, cL as toStorefrontFacets, cM as toUser, cN as toVariant, cO as toVendor, cP as uploadService, cQ as userService, cR as variantService, cS as varniCustomDesignService, cT as varniCustomProductService, cU as vendorService, cV as warrantyService, cW as whatsappService, cX as wishlistService } from './index-sPZh8NN4.cjs';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutQuote, v as CheckoutResult, w as CheckoutService, x as CmsPage, y as Collection, z as CollectionService, D as Company, E as CompanyOrder, F as ContactService, G as CountryService, H as CouponService, I as Credentials, J as Credit, K as CurrencyService, L as Customer, M as CustomizerDesign, N as CustomizerDocument, O as CustomizerEditor, P as CustomizerFile, Q as CustomizerLayer, R as CustomizerSavedDesign, S as CustomizerService, T as CustomizerSetup, U as CustomizerUpload, V as DealService, W as DemoRequestService, X as EngineRequest, Y as EnquiryService, Z as Envelope, _ as FacetValue, $ as Faq, a0 as FaqService, a1 as FeedbackService, a2 as FooterSettings, a3 as FreeShipping, a4 as Fulfillment, a5 as GalleryService, a6 as GooglePlace, a7 as GoogleReview, a8 as GoogleReviewService, a9 as GoogleReviews, aa as GoogleSurvey, ab as HeaderSettings, ac as HomeLayout, ad as HomeLayoutSection, ae as HomeService, af as IdentityAddress, ag as InitService, ah as Invitation, ai as LayoutCollection, aj as LayoutPage, ak as LayoutService, al as Lead, am as ListMeta, an as MeilisearchService, ao as Member, ap as Menu, aq as MenuItem, ar as MenuService, as as MenuSummary, at as Money, au as NewsletterService, av as Offer, aw as OpeningHours, ax as Order, ay as OrderLine, az as OrderService, aA as PageLayout, aB as PageService, aC as PaymentIntent, aD as PaymentMethodService, aE as Plugin, aF as PluginService, aF as PluginsService, aG as PopularSearchService, aH as PopularityService, aI as Postcode, aJ as Product, aK as ProductFacets, aL as ProductOption, aM as ProductService, aN as ProfileService, aO as Quote, aP as REDIRECT_GATEWAYS, aQ as ReelsService, aR as RegionService, aS as RejectedLine, aT as Review, aU as ReviewPage, aV as ReviewService, aW as SearchDoc, aX as SearchResult, aY as SearchService, aZ as SettingService, aZ as SettingsService, a_ as ShippingRate, a$ as SiteChrome, b0 as SiteFooter, b1 as SiteHeader, b2 as SocialLink, b3 as StateService, b4 as StoreClosed, b5 as StorePass, b6 as StorePassAnswer, b7 as StoreProfile, b8 as StoreService, b9 as StoreUnlock, ba as StorefrontCategory, bb as StorefrontMenu, bc as StorefrontOrder, bd as StorefrontProduct, be as ThemeSettings, bf as ThemeSettingsResult, bg as UploadService, bh as UserService, bi as Variant, bj as VariantImage, bk as VariantService, bl as VarniCustomDesignService, bm as VarniCustomProductService, bn as Vendor, bo as VendorService, bp as WarrantyService, bq as WhatsappConsent, br as WhatsappConsentOffer, bs as WhatsappService, bt as Wishlist, bu as WishlistItem, bv as WishlistService, bw as addressService, bx as authService, by as autocompleteService, bz as b2bService, bA as bannerService, bB as blogService, bC as cartService, bD as cashfreeIsTest, bE as categoryService, bF as chatService, bG as checkoutService, bH as collectionService, bI as contactService, bJ as countryService, bK as couponService, bL as currencyExponent, bM as currencyService, bN as customizerService, bO as dealService, bP as demoRequestService, bQ as emptyCart, bR as emptyPage, bS as enquiryService, bT as faqService, bU as feedbackService, bV as fromEngineAddress, bW as fromIdentityAddress, bX as fromSearchDoc, bY as galleryService, bZ as googleReviewService, b_ as homeService, b$ as initService, c0 as layoutService, c1 as mediaUrl, c2 as meilisearchService, c3 as menuService, c4 as minorToMajor, c5 as newsletterService, c6 as orderService, c7 as ownDomain, c8 as pageService, c9 as paymentMethodService, ca as pluginService, cb as pluginsService, cc as popularSearchService, cd as popularityService, ce as priceOf, cf as productImages, cg as productService, ch as productVideos, ci as profileService, cj as qs, ck as reelsService, cl as regionService, cm as reviewService, cn as searchService, co as setRequestHost, cp as settingService, cq as settingsService, cr as stateService, cs as staticStore, ct as storeForHost, cu as storeService, cv as toAddOn, cw as toCart, cx as toCartLine, cy as toCartOffer, cz as toCategory, cA as toCheckoutQuote, cB as toCmsPage, cC as toCollection, cD as toEngineAddress, cE as toFreeShipping, cF as toIdentityAddress, cG as toMajor, cH as toMinor, cI as toOrder, cJ as toPage, cK as toProduct, cL as toRating, cM as toStorefrontFacets, cN as toUser, cO as toVariant, cP as toVendor, cQ as uploadService, cR as userService, cS as variantService, cT as varniCustomDesignService, cU as varniCustomProductService, cV as vendorService, cW as warrantyService, cX as whatsappService, cY as wishlistService } from './index-BAmkQfij.cjs';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutQuote, v as CheckoutResult, w as CheckoutService, x as CmsPage, y as Collection, z as CollectionService, D as Company, E as CompanyOrder, F as ContactService, G as CountryService, H as CouponService, I as Credentials, J as Credit, K as CurrencyService, L as Customer, M as CustomizerDesign, N as CustomizerDocument, O as CustomizerEditor, P as CustomizerFile, Q as CustomizerLayer, R as CustomizerSavedDesign, S as CustomizerService, T as CustomizerSetup, U as CustomizerUpload, V as DealService, W as DemoRequestService, X as EngineRequest, Y as EnquiryService, Z as Envelope, _ as FacetValue, $ as Faq, a0 as FaqService, a1 as FeedbackService, a2 as FooterSettings, a3 as FreeShipping, a4 as Fulfillment, a5 as GalleryService, a6 as GooglePlace, a7 as GoogleReview, a8 as GoogleReviewService, a9 as GoogleReviews, aa as GoogleSurvey, ab as HeaderSettings, ac as HomeLayout, ad as HomeLayoutSection, ae as HomeService, af as IdentityAddress, ag as InitService, ah as Invitation, ai as LayoutCollection, aj as LayoutPage, ak as LayoutService, al as Lead, am as ListMeta, an as MeilisearchService, ao as Member, ap as Menu, aq as MenuItem, ar as MenuService, as as MenuSummary, at as Money, au as NewsletterService, av as Offer, aw as OpeningHours, ax as Order, ay as OrderLine, az as OrderService, aA as PageLayout, aB as PageService, aC as PaymentIntent, aD as PaymentMethodService, aE as Plugin, aF as PluginService, aF as PluginsService, aG as PopularSearchService, aH as PopularityService, aI as Postcode, aJ as Product, aK as ProductFacets, aL as ProductOption, aM as ProductService, aN as ProfileService, aO as Quote, aP as REDIRECT_GATEWAYS, aQ as ReelsService, aR as RegionService, aS as RejectedLine, aT as Review, aU as ReviewPage, aV as ReviewService, aW as SearchDoc, aX as SearchResult, aY as SearchService, aZ as SettingService, aZ as SettingsService, a_ as ShippingRate, a$ as SiteChrome, b0 as SiteFooter, b1 as SiteHeader, b2 as SocialLink, b3 as StateService, b4 as StoreClosed, b5 as StorePass, b6 as StorePassAnswer, b7 as StoreProfile, b8 as StoreService, b9 as StoreUnlock, ba as StorefrontCategory, bb as StorefrontMenu, bc as StorefrontOrder, bd as StorefrontProduct, be as ThemeSettings, bf as ThemeSettingsResult, bg as UploadService, bh as UserService, bi as Variant, bj as VariantImage, bk as VariantService, bl as VarniCustomDesignService, bm as VarniCustomProductService, bn as Vendor, bo as VendorService, bp as WarrantyService, bq as WhatsappConsent, br as WhatsappConsentOffer, bs as WhatsappService, bt as Wishlist, bu as WishlistItem, bv as WishlistService, bw as addressService, bx as authService, by as autocompleteService, bz as b2bService, bA as bannerService, bB as blogService, bC as cartService, bD as categoryService, bE as chatService, bF as checkoutService, bG as collectionService, bH as contactService, bI as countryService, bJ as couponService, bK as currencyExponent, bL as currencyService, bM as customizerService, bN as dealService, bO as demoRequestService, bP as emptyCart, bQ as emptyPage, bR as enquiryService, bS as faqService, bT as feedbackService, bU as fromEngineAddress, bV as fromIdentityAddress, bW as fromSearchDoc, bX as galleryService, bY as googleReviewService, bZ as homeService, b_ as initService, b$ as layoutService, c0 as mediaUrl, c1 as meilisearchService, c2 as menuService, c3 as minorToMajor, c4 as newsletterService, c5 as orderService, c6 as ownDomain, c7 as pageService, c8 as paymentMethodService, c9 as pluginService, ca as pluginsService, cb as popularSearchService, cc as popularityService, cd as priceOf, ce as productImages, cf as productService, cg as productVideos, ch as profileService, ci as qs, cj as reelsService, ck as regionService, cl as reviewService, cm as searchService, cn as setRequestHost, co as settingService, cp as settingsService, cq as stateService, cr as staticStore, cs as storeForHost, ct as storeService, cu as toAddOn, cv as toCart, cw as toCartLine, cx as toCartOffer, cy as toCategory, cz as toCheckoutQuote, cA as toCmsPage, cB as toCollection, cC as toEngineAddress, cD as toFreeShipping, cE as toIdentityAddress, cF as toMajor, cG as toMinor, cH as toOrder, cI as toPage, cJ as toProduct, cK as toRating, cL as toStorefrontFacets, cM as toUser, cN as toVariant, cO as toVendor, cP as uploadService, cQ as userService, cR as variantService, cS as varniCustomDesignService, cT as varniCustomProductService, cU as vendorService, cV as warrantyService, cW as whatsappService, cX as wishlistService } from './index-sPZh8NN4.js';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutQuote, v as CheckoutResult, w as CheckoutService, x as CmsPage, y as Collection, z as CollectionService, D as Company, E as CompanyOrder, F as ContactService, G as CountryService, H as CouponService, I as Credentials, J as Credit, K as CurrencyService, L as Customer, M as CustomizerDesign, N as CustomizerDocument, O as CustomizerEditor, P as CustomizerFile, Q as CustomizerLayer, R as CustomizerSavedDesign, S as CustomizerService, T as CustomizerSetup, U as CustomizerUpload, V as DealService, W as DemoRequestService, X as EngineRequest, Y as EnquiryService, Z as Envelope, _ as FacetValue, $ as Faq, a0 as FaqService, a1 as FeedbackService, a2 as FooterSettings, a3 as FreeShipping, a4 as Fulfillment, a5 as GalleryService, a6 as GooglePlace, a7 as GoogleReview, a8 as GoogleReviewService, a9 as GoogleReviews, aa as GoogleSurvey, ab as HeaderSettings, ac as HomeLayout, ad as HomeLayoutSection, ae as HomeService, af as IdentityAddress, ag as InitService, ah as Invitation, ai as LayoutCollection, aj as LayoutPage, ak as LayoutService, al as Lead, am as ListMeta, an as MeilisearchService, ao as Member, ap as Menu, aq as MenuItem, ar as MenuService, as as MenuSummary, at as Money, au as NewsletterService, av as Offer, aw as OpeningHours, ax as Order, ay as OrderLine, az as OrderService, aA as PageLayout, aB as PageService, aC as PaymentIntent, aD as PaymentMethodService, aE as Plugin, aF as PluginService, aF as PluginsService, aG as PopularSearchService, aH as PopularityService, aI as Postcode, aJ as Product, aK as ProductFacets, aL as ProductOption, aM as ProductService, aN as ProfileService, aO as Quote, aP as REDIRECT_GATEWAYS, aQ as ReelsService, aR as RegionService, aS as RejectedLine, aT as Review, aU as ReviewPage, aV as ReviewService, aW as SearchDoc, aX as SearchResult, aY as SearchService, aZ as SettingService, aZ as SettingsService, a_ as ShippingRate, a$ as SiteChrome, b0 as SiteFooter, b1 as SiteHeader, b2 as SocialLink, b3 as StateService, b4 as StoreClosed, b5 as StorePass, b6 as StorePassAnswer, b7 as StoreProfile, b8 as StoreService, b9 as StoreUnlock, ba as StorefrontCategory, bb as StorefrontMenu, bc as StorefrontOrder, bd as StorefrontProduct, be as ThemeSettings, bf as ThemeSettingsResult, bg as UploadService, bh as UserService, bi as Variant, bj as VariantImage, bk as VariantService, bl as VarniCustomDesignService, bm as VarniCustomProductService, bn as Vendor, bo as VendorService, bp as WarrantyService, bq as WhatsappConsent, br as WhatsappConsentOffer, bs as WhatsappService, bt as Wishlist, bu as WishlistItem, bv as WishlistService, bw as addressService, bx as authService, by as autocompleteService, bz as b2bService, bA as bannerService, bB as blogService, bC as cartService, bD as cashfreeIsTest, bE as categoryService, bF as chatService, bG as checkoutService, bH as collectionService, bI as contactService, bJ as countryService, bK as couponService, bL as currencyExponent, bM as currencyService, bN as customizerService, bO as dealService, bP as demoRequestService, bQ as emptyCart, bR as emptyPage, bS as enquiryService, bT as faqService, bU as feedbackService, bV as fromEngineAddress, bW as fromIdentityAddress, bX as fromSearchDoc, bY as galleryService, bZ as googleReviewService, b_ as homeService, b$ as initService, c0 as layoutService, c1 as mediaUrl, c2 as meilisearchService, c3 as menuService, c4 as minorToMajor, c5 as newsletterService, c6 as orderService, c7 as ownDomain, c8 as pageService, c9 as paymentMethodService, ca as pluginService, cb as pluginsService, cc as popularSearchService, cd as popularityService, ce as priceOf, cf as productImages, cg as productService, ch as productVideos, ci as profileService, cj as qs, ck as reelsService, cl as regionService, cm as reviewService, cn as searchService, co as setRequestHost, cp as settingService, cq as settingsService, cr as stateService, cs as staticStore, ct as storeForHost, cu as storeService, cv as toAddOn, cw as toCart, cx as toCartLine, cy as toCartOffer, cz as toCategory, cA as toCheckoutQuote, cB as toCmsPage, cC as toCollection, cD as toEngineAddress, cE as toFreeShipping, cF as toIdentityAddress, cG as toMajor, cH as toMinor, cI as toOrder, cJ as toPage, cK as toProduct, cL as toRating, cM as toStorefrontFacets, cN as toUser, cO as toVariant, cP as toVendor, cQ as uploadService, cR as userService, cS as variantService, cT as varniCustomDesignService, cU as varniCustomProductService, cV as vendorService, cW as warrantyService, cX as whatsappService, cY as wishlistService } from './index-BAmkQfij.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -2214,9 +2214,9 @@ var CheckoutService = class extends BaseService {
2214
2214
  }
2215
2215
  // The family's other gateway flows. GoCommerce's Stripe is a Payment
2216
2216
  // Element (a client secret, not a hosted page) — `checkout('stripe')` returns
2217
- // that secret for a storefront that mounts the element. Cashfree, PhonePe and
2218
- // Affirm are not engine gateways at all. paymentMethodService never offers
2219
- // these codes, so they are reached only by a storefront that hard-codes one.
2217
+ // that secret for a storefront that mounts the element. PhonePe and Affirm are
2218
+ // not engine gateways at all. paymentMethodService never offers these codes,
2219
+ // so they are reached only by a storefront that hard-codes one.
2220
2220
  async checkoutStripe() {
2221
2221
  throw unsupported(
2222
2222
  "checkoutStripe",
@@ -2239,7 +2239,7 @@ var CheckoutService = class extends BaseService {
2239
2239
  const gateway = await this.redirectGateway();
2240
2240
  if (!gateway) throw unsupported("checkoutPaypal", "this store has no hosted-page payment gateway switched on");
2241
2241
  const id2 = cartId || storedCartId() || "";
2242
- const back = origin ? `${origin.replace(/\/+$/, "")}/checkout/success?cart_id=${encodeURIComponent(id2)}` : void 0;
2242
+ const back = origin ? successUrl(origin, id2) : void 0;
2243
2243
  const result = await this.place(gateway, id2, back ? { return_url: back } : {});
2244
2244
  const url = result.payment.client_data?.url;
2245
2245
  if (!url) throw new GoCommerceError("The payment page did not open. Please try again.", 502);
@@ -2255,11 +2255,40 @@ var CheckoutService = class extends BaseService {
2255
2255
  } = {}) {
2256
2256
  return { order_no: order_no ?? null, status: "processing" };
2257
2257
  }
2258
- async checkoutCashfree() {
2259
- throw unsupported("checkoutCashfree", "the engine has no Cashfree gateway");
2258
+ /**
2259
+ * Cashfree's JavaScript checkout. The engine has already created the Cashfree
2260
+ * order; this hands the storefront the session its modal opens. `order_no` is
2261
+ * the store's number, which the storefront prefers over `order_id`, Cashfree's.
2262
+ *
2263
+ * The return URL is for the one case the modal cannot open, an in-app browser,
2264
+ * when Cashfree sends the shopper back to it instead. Only https is sent: every
2265
+ * Cashfree example is, and a plain-http dev origin should not risk the order.
2266
+ */
2267
+ async checkoutCashfree({ cartId, origin } = {}) {
2268
+ const { id: id2, extras, address } = await this.storedCheckout(cartId);
2269
+ if (!extras.phone && !address.phone) throw new GoCommerceError("Add a phone number to pay with Cashfree.", 400);
2270
+ const result = await this.place("cashfree", id2, origin?.startsWith("https:") ? { return_url: successUrl(origin, id2) } : {});
2271
+ const data = result.payment.client_data ?? {};
2272
+ if (result.payment.kind !== "client_action" || !data.payment_session_id) {
2273
+ throw new GoCommerceError("The payment page did not open. Please try again.", 502);
2274
+ }
2275
+ cashfreeEnvironment = data.environment;
2276
+ return {
2277
+ order_no: result.order.number,
2278
+ payment_session_id: data.payment_session_id,
2279
+ order_id: data.order_id,
2280
+ environment: data.environment
2281
+ };
2260
2282
  }
2261
- async captureCashfreePayment() {
2262
- throw unsupported("captureCashfreePayment", "the engine has no Cashfree gateway");
2283
+ /**
2284
+ * Nothing to capture: the signed webhook tells the engine the order is paid.
2285
+ * The storefront calls this on the server, after Cashfree's modal resolves
2286
+ * with any outcome, so it can neither claim the payment nor, without the
2287
+ * browser's order token, check it. Answering sends the shopper to the success
2288
+ * page; throwing would call a payment that may have gone through failed.
2289
+ */
2290
+ async captureCashfreePayment({ order_no } = {}) {
2291
+ return { order_no: order_no ?? null, status: "processing" };
2263
2292
  }
2264
2293
  async checkoutPhonepe() {
2265
2294
  throw unsupported("checkoutPhonepe", "the engine has no PhonePe gateway");
@@ -2325,7 +2354,7 @@ var CheckoutService = class extends BaseService {
2325
2354
  }
2326
2355
  /**
2327
2356
  * What checkout would charge for the cart now, by the storefront's method
2328
- * code (`COD`, `RAZORPAY`, `PAYPAL`) or none yet (D185). Null until the
2357
+ * code (`COD`, `RAZORPAY`, `CASHFREE`, `PAYPAL`) or none yet (D185). Null until the
2329
2358
  * address step has stored an address, and null from an engine before D185.
2330
2359
  *
2331
2360
  * A refusal is checkout's own: the same GoCommerceError, with the same
@@ -2333,7 +2362,7 @@ var CheckoutService = class extends BaseService {
2333
2362
  */
2334
2363
  async getQuote({ cartId, method = "" } = {}) {
2335
2364
  const id2 = cartId || storedCartId();
2336
- if (!id2 || !cartExtras(id2).shippingAddress) return null;
2365
+ if (!id2 || !cartExtras(id2).shippingAddress || cartExtras(id2).attempt?.placed) return null;
2337
2366
  const { extras, email, address } = await this.storedCheckout(id2);
2338
2367
  const code = method.toLowerCase() === "paypal" ? await this.redirectGateway() : method.toLowerCase();
2339
2368
  try {
@@ -2394,6 +2423,11 @@ var CheckoutService = class extends BaseService {
2394
2423
  * key resumes that order, and without one the shopper is stuck. A changed
2395
2424
  * request — a different address, a different method — gets a new key, since
2396
2425
  * the engine refuses a key replayed with a different body.
2426
+ *
2427
+ * A gateway's modal keeps the key after the order is placed, along with exactly
2428
+ * what placed it. The cart is converted by then, so a shopper who closes the
2429
+ * window can pay again only under this key, and the engine then reopens the same
2430
+ * gateway order rather than risk a second charge on a new one (D232).
2397
2431
  */
2398
2432
  async place(code, cartId, extra = {}) {
2399
2433
  const { id: id2, extras, email, address, currency } = await this.storedCheckout(cartId);
@@ -2410,23 +2444,27 @@ var CheckoutService = class extends BaseService {
2410
2444
  const serialised = JSON.stringify(body);
2411
2445
  const retry = extras.attempt?.body === `${code}:${serialised}`;
2412
2446
  const key = retry ? extras.attempt.key : newKey();
2447
+ const placed = retry ? extras.attempt?.placed : void 0;
2413
2448
  const meta = retry ? extras.attempt?.meta : metaBrowser();
2414
2449
  const attribution = retry ? extras.attempt?.attribution : landingAttribution();
2415
- saveCartExtras(id2, {
2416
- attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {}, ...attribution ? { attribution } : {} }
2417
- });
2450
+ if (!placed) {
2451
+ saveCartExtras(id2, {
2452
+ attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {}, ...attribution ? { attribution } : {} }
2453
+ });
2454
+ }
2418
2455
  const metadata = {
2419
2456
  ...extra.metadata,
2420
2457
  ...meta ? { meta_capi: meta } : {},
2421
2458
  ...attribution ? { attribution } : {}
2422
2459
  };
2423
2460
  const expected = this.expected.get(id2);
2461
+ const sent = placed ?? {
2462
+ ...Object.keys(metadata).length ? { ...body, metadata } : body,
2463
+ ...expected ? { quoted_total_minor: toMinor(expected.total, currency) } : {}
2464
+ };
2424
2465
  const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
2425
2466
  method: "POST",
2426
- body: {
2427
- ...Object.keys(metadata).length ? { ...body, metadata } : body,
2428
- ...expected ? { quoted_total_minor: toMinor(expected.total, currency) } : {}
2429
- },
2467
+ body: sent,
2430
2468
  headers: { "Idempotency-Key": key }
2431
2469
  }).catch((err) => {
2432
2470
  if (keyAlreadyUsed(err)) {
@@ -2453,11 +2491,18 @@ var CheckoutService = class extends BaseService {
2453
2491
  }).catch(() => void 0);
2454
2492
  }
2455
2493
  }
2456
- saveCartExtras(id2, { attempt: null });
2494
+ const reopenable = result.payment.kind === "client_action";
2495
+ saveCartExtras(id2, { attempt: reopenable ? { key, body: `${code}:${serialised}`, placed: sent } : null });
2496
+ if (reopenable && result.order.payment_status === "paid") {
2497
+ throw new GoCommerceError(`Order ${result.order.number} is already paid, so there is nothing more to pay.`, 409, "already_paid");
2498
+ }
2457
2499
  return result;
2458
2500
  }
2459
2501
  };
2460
2502
  var REDIRECT_GATEWAYS = /* @__PURE__ */ new Set(["paypal", "adyen", "paddle", "lemonsqueezy", "creem", "hyperswitch", "revenuecat"]);
2503
+ var cashfreeEnvironment;
2504
+ var cashfreeIsTest = () => cashfreeEnvironment === "sandbox";
2505
+ var successUrl = (origin, cartId) => `${origin.replace(/\/+$/, "")}/checkout/success?cart_id=${encodeURIComponent(cartId)}`;
2461
2506
  var unsupported = (method, why) => new NotSupportedError("CheckoutService", method, why);
2462
2507
  function keyAlreadyUsed(err) {
2463
2508
  return err instanceof GoCommerceError && err.status === 400 && err.message.includes("Idempotency-Key was already used");
@@ -2484,7 +2529,8 @@ var checkoutService = new CheckoutService();
2484
2529
  // src/services/payment-method-service.ts
2485
2530
  var DRIVABLE = {
2486
2531
  cod: { code: "COD", img: "/payment/cod.svg" },
2487
- razorpay: { code: "RAZORPAY" }
2532
+ razorpay: { code: "RAZORPAY" },
2533
+ cashfree: { code: "CASHFREE", img: "/payment/card.svg" }
2488
2534
  };
2489
2535
  var reported2 = /* @__PURE__ */ new Set();
2490
2536
  var PaymentMethodService = class extends BaseService {
@@ -2493,7 +2539,12 @@ var PaymentMethodService = class extends BaseService {
2493
2539
  const options = await this.facts.checkoutOptions();
2494
2540
  const methods = options.methods ?? [];
2495
2541
  const redirect = methods.find((m) => REDIRECT_GATEWAYS.has(m.code))?.code;
2496
- const drive = (code) => DRIVABLE[code] ?? (code === redirect ? { code: "PAYPAL", img: "/payment/card.svg" } : void 0);
2542
+ const drive = (code) => {
2543
+ if (code === "cashfree" && options.currency !== "INR") return void 0;
2544
+ if (DRIVABLE[code]) return DRIVABLE[code];
2545
+ if (code === redirect) return { code: "PAYPAL", img: "/payment/card.svg" };
2546
+ return REDIRECT_GATEWAYS.has(code) ? { code: code.toUpperCase(), img: "/payment/card.svg" } : void 0;
2547
+ };
2497
2548
  const data = methods.filter((m) => {
2498
2549
  if (drive(m.code)) return true;
2499
2550
  if (!reported2.has(m.code)) {
@@ -2503,19 +2554,24 @@ var PaymentMethodService = class extends BaseService {
2503
2554
  );
2504
2555
  }
2505
2556
  return false;
2506
- }).map((m, i) => ({
2507
- id: m.code,
2508
- code: drive(m.code).code,
2509
- engineCode: m.code,
2510
- name: m.name,
2511
- title: m.name,
2512
- description: "",
2513
- img: drive(m.code).img ?? null,
2514
- fee: toMajor(m.fee),
2515
- rank: i,
2516
- active: true,
2517
- isActive: true
2518
- }));
2557
+ }).map((m, i) => {
2558
+ const method = {
2559
+ id: m.code,
2560
+ code: drive(m.code).code,
2561
+ engineCode: m.code,
2562
+ name: m.name,
2563
+ title: m.name,
2564
+ description: "",
2565
+ img: drive(m.code).img ?? null,
2566
+ fee: toMajor(m.fee),
2567
+ rank: i,
2568
+ active: true,
2569
+ isActive: true
2570
+ };
2571
+ if (REDIRECT_GATEWAYS.has(m.code) && m.code !== redirect) Object.assign(method, { redirects: true });
2572
+ if (m.code === "cashfree") Object.defineProperty(method, "isTest", { get: cashfreeIsTest, enumerable: true });
2573
+ return method;
2574
+ });
2519
2575
  return { data, count: data.length, pageSize: data.length, noOfPage: 1, page: 1 };
2520
2576
  }
2521
2577
  };
@@ -4276,6 +4332,6 @@ function attemptKey(request) {
4276
4332
  }
4277
4333
  var b2bService = new B2bService();
4278
4334
 
4279
- export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, CustomizerService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoCommerceError, GoogleReviewService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, NotSupportedError, OrderService, PageService, PaymentMethodService, PluginService, PluginService as PluginsService, PopularSearchService, PopularityService, ProductService, ProfileService, REDIRECT_GATEWAYS, ReelsService, RegionService, ReviewService, SearchService, SettingService, SettingService as SettingsService, StateService, StoreService, UploadService, UserService, VariantService, VarniCustomDesignService, VarniCustomProductService, VendorService, WarrantyService, WhatsappService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, categoryService, chatService, checkoutService, forgetAll as clearStoreCache, collectionService, connectorName, contactService, countryService, couponService, currencyExponent, currencyService, customizerService, dealService, demoRequestService, emptyCart, emptyPage, enquiryService, faqService, feedbackService, fromEngineAddress, fromIdentityAddress, fromSearchDoc, galleryService, googleReviewService, hasStaticStore, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, productVideos, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toAddOn, toCart, toCartLine, toCartOffer, toCategory, toCheckoutQuote, toCmsPage, toCollection, toEngineAddress, toFreeShipping, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, whatsappService, wishlistService };
4335
+ export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, CustomizerService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoCommerceError, GoogleReviewService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, NotSupportedError, OrderService, PageService, PaymentMethodService, PluginService, PluginService as PluginsService, PopularSearchService, PopularityService, ProductService, ProfileService, REDIRECT_GATEWAYS, ReelsService, RegionService, ReviewService, SearchService, SettingService, SettingService as SettingsService, StateService, StoreService, UploadService, UserService, VariantService, VarniCustomDesignService, VarniCustomProductService, VendorService, WarrantyService, WhatsappService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, cashfreeIsTest, categoryService, chatService, checkoutService, forgetAll as clearStoreCache, collectionService, connectorName, contactService, countryService, couponService, currencyExponent, currencyService, customizerService, dealService, demoRequestService, emptyCart, emptyPage, enquiryService, faqService, feedbackService, fromEngineAddress, fromIdentityAddress, fromSearchDoc, galleryService, googleReviewService, hasStaticStore, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, productVideos, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toAddOn, toCart, toCartLine, toCartOffer, toCategory, toCheckoutQuote, toCmsPage, toCollection, toEngineAddress, toFreeShipping, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, whatsappService, wishlistService };
4280
4336
  //# sourceMappingURL=index.js.map
4281
4337
  //# sourceMappingURL=index.js.map