@commercelayer/react-components 4.3.5 → 4.4.0-beta.4

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.
Files changed (559) hide show
  1. package/lib/cjs/components/ExternalFunction.d.ts +1 -1
  2. package/lib/cjs/components/ExternalFunction.js +1 -1
  3. package/lib/cjs/components/MetadataInput.d.ts +1 -1
  4. package/lib/cjs/components/MetadataInput.js +1 -1
  5. package/lib/cjs/components/SubmitButton.d.ts +2 -2
  6. package/lib/cjs/components/SubmitButton.js +1 -1
  7. package/lib/cjs/components/addresses/Address.d.ts +1 -1
  8. package/lib/cjs/components/addresses/Address.js +1 -1
  9. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +2 -2
  10. package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -1
  11. package/lib/cjs/components/addresses/AddressField.d.ts +3 -3
  12. package/lib/cjs/components/addresses/AddressField.js +1 -1
  13. package/lib/cjs/components/addresses/AddressInput.d.ts +2 -2
  14. package/lib/cjs/components/addresses/AddressInput.js +1 -1
  15. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +1 -1
  16. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
  17. package/lib/cjs/components/addresses/AddressesContainer.d.ts +1 -1
  18. package/lib/cjs/components/addresses/AddressesContainer.js +1 -1
  19. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +1 -1
  20. package/lib/cjs/components/addresses/AddressesEmpty.js +1 -1
  21. package/lib/cjs/components/addresses/BillingAddressContainer.d.ts +1 -1
  22. package/lib/cjs/components/addresses/BillingAddressContainer.js +1 -1
  23. package/lib/cjs/components/addresses/BillingAddressForm.d.ts +1 -1
  24. package/lib/cjs/components/addresses/BillingAddressForm.js +1 -1
  25. package/lib/cjs/components/addresses/SaveAddressesButton.d.ts +2 -2
  26. package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -1
  27. package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -1
  28. package/lib/cjs/components/addresses/ShippingAddressForm.d.ts +1 -1
  29. package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -1
  30. package/lib/cjs/components/auth/CommerceLayer.js +1 -1
  31. package/lib/cjs/components/customers/CustomerAddressForm.d.ts +1 -1
  32. package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
  33. package/lib/cjs/components/customers/CustomerContainer.js +1 -1
  34. package/lib/cjs/components/customers/CustomerField.d.ts +2 -2
  35. package/lib/cjs/components/customers/CustomerField.js +1 -1
  36. package/lib/cjs/components/customers/CustomerInput.d.ts +1 -1
  37. package/lib/cjs/components/customers/CustomerInput.js +1 -1
  38. package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +1 -1
  39. package/lib/cjs/components/customers/CustomerPaymentSource.js +1 -1
  40. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -1
  41. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.js +1 -1
  42. package/lib/cjs/components/customers/SaveCustomerButton.d.ts +2 -2
  43. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
  44. package/lib/cjs/components/errors/Errors.d.ts +1 -1
  45. package/lib/cjs/components/errors/Errors.js +1 -1
  46. package/lib/cjs/components/gift_cards/GiftCard.d.ts +1 -1
  47. package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
  48. package/lib/cjs/components/gift_cards/GiftCardContainer.d.ts +1 -1
  49. package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -1
  50. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -1
  51. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -1
  52. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -1
  53. package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -1
  54. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -1
  55. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -1
  56. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -1
  57. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +2 -2
  58. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -1
  59. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +3 -3
  60. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  61. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.d.ts +2 -2
  62. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -1
  63. package/lib/cjs/components/line_items/LineItem.js +1 -1
  64. package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -1
  65. package/lib/cjs/components/line_items/LineItemAmount.js +1 -1
  66. package/lib/cjs/components/line_items/LineItemCode.d.ts +2 -2
  67. package/lib/cjs/components/line_items/LineItemCode.js +1 -1
  68. package/lib/cjs/components/line_items/LineItemField.d.ts +2 -2
  69. package/lib/cjs/components/line_items/LineItemField.js +1 -1
  70. package/lib/cjs/components/line_items/LineItemImage.d.ts +2 -2
  71. package/lib/cjs/components/line_items/LineItemImage.js +1 -1
  72. package/lib/cjs/components/line_items/LineItemName.d.ts +1 -1
  73. package/lib/cjs/components/line_items/LineItemName.js +1 -1
  74. package/lib/cjs/components/line_items/LineItemOption.d.ts +3 -3
  75. package/lib/cjs/components/line_items/LineItemOption.js +1 -1
  76. package/lib/cjs/components/line_items/LineItemOptions.d.ts +1 -1
  77. package/lib/cjs/components/line_items/LineItemOptions.js +1 -1
  78. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +1 -1
  79. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
  80. package/lib/cjs/components/line_items/LineItemRemoveLink.d.ts +2 -2
  81. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
  82. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
  83. package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -1
  84. package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
  85. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -1
  86. package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -1
  87. package/lib/cjs/components/orders/AddToCartButton.d.ts +3 -3
  88. package/lib/cjs/components/orders/AddToCartButton.js +1 -1
  89. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -1
  90. package/lib/cjs/components/orders/AdjustmentAmount.js +1 -1
  91. package/lib/cjs/components/orders/CartLink.d.ts +2 -2
  92. package/lib/cjs/components/orders/CartLink.js +1 -1
  93. package/lib/cjs/components/orders/CheckoutLink.d.ts +1 -1
  94. package/lib/cjs/components/orders/CheckoutLink.js +1 -1
  95. package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -1
  96. package/lib/cjs/components/orders/DiscountAmount.js +1 -1
  97. package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -1
  98. package/lib/cjs/components/orders/GiftCardAmount.js +1 -1
  99. package/lib/cjs/components/orders/OrderContainer.d.ts +1 -1
  100. package/lib/cjs/components/orders/OrderContainer.js +1 -1
  101. package/lib/cjs/components/orders/OrderList.d.ts +2 -2
  102. package/lib/cjs/components/orders/OrderList.js +1 -1
  103. package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -1
  104. package/lib/cjs/components/orders/OrderListEmpty.js +1 -1
  105. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -1
  106. package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -1
  107. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -1
  108. package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -1
  109. package/lib/cjs/components/orders/OrderListRow.js +1 -1
  110. package/lib/cjs/components/orders/OrderNumber.d.ts +1 -1
  111. package/lib/cjs/components/orders/OrderNumber.js +1 -1
  112. package/lib/cjs/components/orders/OrderStorage.d.ts +1 -1
  113. package/lib/cjs/components/orders/OrderStorage.js +1 -1
  114. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -1
  115. package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -1
  116. package/lib/cjs/components/orders/PlaceOrderButton.d.ts +2 -2
  117. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
  118. package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +2 -2
  119. package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -1
  120. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -1
  121. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -1
  122. package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -1
  123. package/lib/cjs/components/orders/ShippingAmount.js +1 -1
  124. package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -1
  125. package/lib/cjs/components/orders/SubTotalAmount.js +1 -1
  126. package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -1
  127. package/lib/cjs/components/orders/TaxesAmount.js +1 -1
  128. package/lib/cjs/components/orders/TotalAmount.d.ts +1 -1
  129. package/lib/cjs/components/orders/TotalAmount.js +1 -1
  130. package/lib/cjs/components/parcels/ParcelField.d.ts +2 -2
  131. package/lib/cjs/components/parcels/ParcelField.js +1 -1
  132. package/lib/cjs/components/parcels/ParcelLineItem.js +1 -1
  133. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +2 -2
  134. package/lib/cjs/components/parcels/ParcelLineItemField.js +1 -1
  135. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -1
  136. package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -1
  137. package/lib/cjs/components/parcels/Parcels.js +1 -1
  138. package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -1
  139. package/lib/cjs/components/parcels/ParcelsCount.js +1 -1
  140. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -1
  141. package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -1
  142. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -1
  143. package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -1
  144. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -1
  145. package/lib/cjs/components/payment_gateways/CheckoutComGateway.js +1 -1
  146. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -1
  147. package/lib/cjs/components/payment_gateways/ExternalGateway.js +1 -1
  148. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -1
  149. package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -1
  150. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +2 -2
  151. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
  152. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -1
  153. package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -1
  154. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -1
  155. package/lib/cjs/components/payment_gateways/StripeGateway.js +1 -1
  156. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -1
  157. package/lib/cjs/components/payment_gateways/WireTransferGateway.js +1 -1
  158. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +14 -1
  159. package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
  160. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -1
  161. package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -1
  162. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -1
  163. package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -1
  164. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.d.ts +2 -2
  165. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -1
  166. package/lib/cjs/components/payment_methods/PaymentMethodsContainer.d.ts +2 -2
  167. package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -1
  168. package/lib/cjs/components/payment_source/AdyenPayment.d.ts +2 -2
  169. package/lib/cjs/components/payment_source/AdyenPayment.js +1 -1
  170. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +3 -5
  171. package/lib/cjs/components/payment_source/BraintreePayment.js +1 -1
  172. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +3 -3
  173. package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -1
  174. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +2 -2
  175. package/lib/cjs/components/payment_source/ExternalPayment.js +1 -1
  176. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +2 -2
  177. package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -1
  178. package/lib/cjs/components/payment_source/PaymentSource.d.ts +2 -2
  179. package/lib/cjs/components/payment_source/PaymentSource.js +1 -1
  180. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +2 -2
  181. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -1
  182. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +2 -2
  183. package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -1
  184. package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -1
  185. package/lib/cjs/components/payment_source/PaymentSourceEditButton.d.ts +2 -2
  186. package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -1
  187. package/lib/cjs/components/payment_source/PaypalPayment.d.ts +1 -1
  188. package/lib/cjs/components/payment_source/PaypalPayment.js +1 -1
  189. package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +5 -0
  190. package/lib/cjs/components/payment_source/StripeExpressPayment.js +1 -0
  191. package/lib/cjs/components/payment_source/StripePayment.d.ts +8 -5
  192. package/lib/cjs/components/payment_source/StripePayment.js +1 -1
  193. package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -1
  194. package/lib/cjs/components/prices/Price.d.ts +2 -2
  195. package/lib/cjs/components/prices/Price.js +1 -1
  196. package/lib/cjs/components/prices/PricesContainer.d.ts +1 -1
  197. package/lib/cjs/components/prices/PricesContainer.js +1 -1
  198. package/lib/cjs/components/shipments/Shipment.d.ts +1 -1
  199. package/lib/cjs/components/shipments/Shipment.js +1 -1
  200. package/lib/cjs/components/shipments/ShipmentField.d.ts +1 -1
  201. package/lib/cjs/components/shipments/ShipmentField.js +1 -1
  202. package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +1 -1
  203. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -1
  204. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +1 -1
  205. package/lib/cjs/components/shipments/ShipmentsCount.js +1 -1
  206. package/lib/cjs/components/shipping_methods/ShippingMethod.d.ts +1 -1
  207. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -1
  208. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -1
  209. package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -1
  210. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -1
  211. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -1
  212. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
  213. package/lib/cjs/components/skus/AvailabilityContainer.d.ts +1 -1
  214. package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
  215. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +2 -2
  216. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
  217. package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -1
  218. package/lib/cjs/components/skus/SkuField.d.ts +2 -2
  219. package/lib/cjs/components/skus/SkuField.js +1 -1
  220. package/lib/cjs/components/skus/SkuList.d.ts +1 -1
  221. package/lib/cjs/components/skus/SkuListsContainer.d.ts +1 -1
  222. package/lib/cjs/components/skus/SkuListsContainer.js +1 -1
  223. package/lib/cjs/components/skus/Skus.d.ts +1 -1
  224. package/lib/cjs/components/skus/Skus.js +1 -1
  225. package/lib/cjs/components/skus/SkusContainer.d.ts +1 -1
  226. package/lib/cjs/components/skus/SkusContainer.js +1 -1
  227. package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -1
  228. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +2 -2
  229. package/lib/cjs/components/stock_transfers/StockTransferField.js +1 -1
  230. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -1
  231. package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -1
  232. package/lib/cjs/components/utils/BaseField.d.ts +1 -1
  233. package/lib/cjs/components/utils/BaseField.js +1 -1
  234. package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
  235. package/lib/cjs/components/utils/BaseInput.js +1 -1
  236. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +3 -3
  237. package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
  238. package/lib/cjs/components/utils/BaseSelect.d.ts +1 -1
  239. package/lib/cjs/components/utils/BaseSelect.js +1 -1
  240. package/lib/cjs/components/utils/ErrorBoundary.d.ts +1 -1
  241. package/lib/cjs/components/utils/ErrorBoundary.js +1 -1
  242. package/lib/cjs/components/utils/GenericFieldComponent.d.ts +7 -7
  243. package/lib/cjs/components/utils/GenericFieldComponent.js +1 -1
  244. package/lib/cjs/components/utils/Parent.d.ts +1 -1
  245. package/lib/cjs/components/utils/Parent.js +1 -1
  246. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +3 -3
  247. package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -1
  248. package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -1
  249. package/lib/cjs/components/utils/PriceTemplate.js +1 -1
  250. package/lib/cjs/components/utils/getAllErrors.d.ts +3 -3
  251. package/lib/cjs/components/utils/getAllErrors.js +1 -1
  252. package/lib/cjs/context/AddressChildrenContext.d.ts +1 -1
  253. package/lib/cjs/context/AddressContext.d.ts +2 -2
  254. package/lib/cjs/context/BillingAddressContext.d.ts +1 -1
  255. package/lib/cjs/context/BillingAddressFormContext.d.ts +5 -7
  256. package/lib/cjs/context/CouponAndGiftCardFormContext.d.ts +1 -1
  257. package/lib/cjs/context/CustomerAddressFormContext.d.ts +7 -9
  258. package/lib/cjs/context/CustomerContext.d.ts +1 -1
  259. package/lib/cjs/context/CustomerPaymentSourceContext.d.ts +1 -1
  260. package/lib/cjs/context/ExternalFunctionContext.js +1 -1
  261. package/lib/cjs/context/GiftCardContext.d.ts +2 -2
  262. package/lib/cjs/context/LineItemChildrenContext.d.ts +1 -1
  263. package/lib/cjs/context/LineItemContext.d.ts +2 -2
  264. package/lib/cjs/context/LineItemOptionChildrenContext.d.ts +5 -2
  265. package/lib/cjs/context/OrderContext.d.ts +3 -3
  266. package/lib/cjs/context/OrderContext.js +1 -1
  267. package/lib/cjs/context/OrderListChildrenContext.d.ts +1 -1
  268. package/lib/cjs/context/OrderListPaginationContext.d.ts +1 -1
  269. package/lib/cjs/context/PaymentMethodChildrenContext.d.ts +2 -1
  270. package/lib/cjs/context/PaymentMethodContext.d.ts +1 -1
  271. package/lib/cjs/context/PlaceOrderContext.d.ts +2 -2
  272. package/lib/cjs/context/PricesContext.d.ts +1 -1
  273. package/lib/cjs/context/ShipmentContext.d.ts +1 -1
  274. package/lib/cjs/context/ShippingAddressContext.d.ts +1 -1
  275. package/lib/cjs/context/ShippingAddressFormContext.d.ts +1 -1
  276. package/lib/cjs/context/ShippingMethodChildrenContext.d.ts +1 -1
  277. package/lib/cjs/context/SkuChildrenContext.d.ts +1 -1
  278. package/lib/cjs/context/SkuContext.d.ts +1 -1
  279. package/lib/cjs/context/StockTransferChildrenContext.d.ts +1 -1
  280. package/lib/cjs/hooks/useOrderContainer.js +1 -1
  281. package/lib/cjs/reducers/AddressReducer.d.ts +6 -6
  282. package/lib/cjs/reducers/AddressReducer.js +1 -1
  283. package/lib/cjs/reducers/AvailabilityReducer.d.ts +4 -4
  284. package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
  285. package/lib/cjs/reducers/BillingAddressReducer.d.ts +4 -4
  286. package/lib/cjs/reducers/BillingAddressReducer.js +1 -1
  287. package/lib/cjs/reducers/CustomerReducer.d.ts +4 -4
  288. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  289. package/lib/cjs/reducers/GiftCardReducer.d.ts +6 -6
  290. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  291. package/lib/cjs/reducers/LineItemReducer.d.ts +6 -6
  292. package/lib/cjs/reducers/LineItemReducer.js +1 -1
  293. package/lib/cjs/reducers/OrderReducer.d.ts +6 -6
  294. package/lib/cjs/reducers/OrderReducer.js +1 -1
  295. package/lib/cjs/reducers/PaymentMethodReducer.d.ts +16 -12
  296. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
  297. package/lib/cjs/reducers/PlaceOrderReducer.d.ts +4 -1
  298. package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
  299. package/lib/cjs/reducers/PriceReducer.d.ts +6 -8
  300. package/lib/cjs/reducers/PriceReducer.js +1 -1
  301. package/lib/cjs/reducers/ShipmentReducer.d.ts +5 -5
  302. package/lib/cjs/reducers/ShipmentReducer.js +1 -1
  303. package/lib/cjs/reducers/ShippingAddressReducer.d.ts +4 -4
  304. package/lib/cjs/reducers/ShippingAddressReducer.js +1 -1
  305. package/lib/cjs/reducers/SkuListsReducer.d.ts +2 -2
  306. package/lib/cjs/reducers/SkuListsReducer.js +1 -1
  307. package/lib/cjs/reducers/SkuReducer.d.ts +4 -4
  308. package/lib/cjs/reducers/SkuReducer.js +1 -1
  309. package/lib/cjs/typings/errors.d.ts +1 -1
  310. package/lib/cjs/typings/index.d.ts +7 -11
  311. package/lib/cjs/typings/index.js +1 -1
  312. package/lib/cjs/utils/PropsType.d.ts +2 -2
  313. package/lib/cjs/utils/addressesManager.d.ts +3 -3
  314. package/lib/cjs/utils/baseReducer.d.ts +1 -1
  315. package/lib/cjs/utils/baseReducer.js +1 -1
  316. package/lib/cjs/utils/checkIncludeResource.d.ts +1 -1
  317. package/lib/cjs/utils/customMessages.d.ts +1 -1
  318. package/lib/cjs/utils/expressPaymentHelper.d.ts +83 -0
  319. package/lib/cjs/utils/expressPaymentHelper.js +1 -0
  320. package/lib/cjs/utils/filterChildren.d.ts +1 -1
  321. package/lib/cjs/utils/getCardDetails.d.ts +3 -3
  322. package/lib/cjs/utils/getCardDetails.js +1 -1
  323. package/lib/cjs/utils/getErrors.d.ts +4 -3
  324. package/lib/cjs/utils/getErrors.js +1 -1
  325. package/lib/cjs/utils/getLoaderComponent.d.ts +1 -1
  326. package/lib/cjs/utils/getPaymentAttributes.d.ts +3 -3
  327. package/lib/cjs/utils/getPrices.d.ts +2 -2
  328. package/lib/cjs/utils/getPrices.js +1 -1
  329. package/lib/cjs/utils/getSdk.d.ts +1 -1
  330. package/lib/cjs/utils/getSdk.js +1 -1
  331. package/lib/cjs/utils/getSkus.d.ts +1 -1
  332. package/lib/cjs/utils/hooks/useCustomContext.d.ts +1 -1
  333. package/lib/cjs/utils/icons.js +1 -1
  334. package/lib/cjs/utils/isEmpty.d.ts +1 -0
  335. package/lib/cjs/utils/isEmpty.js +1 -0
  336. package/lib/cjs/utils/localStorage.js +1 -1
  337. package/lib/cjs/utils/promisify.js +1 -1
  338. package/lib/cjs/utils/shipments.d.ts +1 -1
  339. package/lib/cjs/utils/shipments.js +1 -1
  340. package/lib/cjs/utils/snakeToCamelCase.js +1 -1
  341. package/lib/cjs/utils/validateFormFields.d.ts +6 -6
  342. package/lib/cjs/utils/validateFormFields.js +1 -1
  343. package/lib/esm/components/ExternalFunction.d.ts +1 -1
  344. package/lib/esm/components/MetadataInput.d.ts +1 -1
  345. package/lib/esm/components/SubmitButton.d.ts +2 -2
  346. package/lib/esm/components/addresses/Address.d.ts +1 -1
  347. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +2 -2
  348. package/lib/esm/components/addresses/AddressField.d.ts +3 -3
  349. package/lib/esm/components/addresses/AddressInput.d.ts +2 -2
  350. package/lib/esm/components/addresses/AddressStateSelector.d.ts +1 -1
  351. package/lib/esm/components/addresses/AddressesContainer.d.ts +1 -1
  352. package/lib/esm/components/addresses/AddressesContainer.js +1 -1
  353. package/lib/esm/components/addresses/AddressesEmpty.d.ts +1 -1
  354. package/lib/esm/components/addresses/BillingAddressContainer.d.ts +1 -1
  355. package/lib/esm/components/addresses/BillingAddressForm.d.ts +1 -1
  356. package/lib/esm/components/addresses/BillingAddressForm.js +1 -1
  357. package/lib/esm/components/addresses/SaveAddressesButton.d.ts +2 -2
  358. package/lib/esm/components/addresses/ShippingAddressForm.d.ts +1 -1
  359. package/lib/esm/components/addresses/ShippingAddressForm.js +1 -1
  360. package/lib/esm/components/customers/CustomerAddressForm.d.ts +1 -1
  361. package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
  362. package/lib/esm/components/customers/CustomerContainer.js +1 -1
  363. package/lib/esm/components/customers/CustomerField.d.ts +2 -2
  364. package/lib/esm/components/customers/CustomerField.js +1 -1
  365. package/lib/esm/components/customers/CustomerInput.d.ts +1 -1
  366. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -1
  367. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -1
  368. package/lib/esm/components/customers/SaveCustomerButton.d.ts +2 -2
  369. package/lib/esm/components/errors/Errors.d.ts +1 -1
  370. package/lib/esm/components/gift_cards/GiftCard.d.ts +1 -1
  371. package/lib/esm/components/gift_cards/GiftCardContainer.d.ts +1 -1
  372. package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -1
  373. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -1
  374. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -1
  375. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -1
  376. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +2 -2
  377. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +3 -3
  378. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.d.ts +2 -2
  379. package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -1
  380. package/lib/esm/components/line_items/LineItemCode.d.ts +2 -2
  381. package/lib/esm/components/line_items/LineItemField.d.ts +2 -2
  382. package/lib/esm/components/line_items/LineItemField.js +1 -1
  383. package/lib/esm/components/line_items/LineItemImage.d.ts +2 -2
  384. package/lib/esm/components/line_items/LineItemName.d.ts +1 -1
  385. package/lib/esm/components/line_items/LineItemOption.d.ts +3 -3
  386. package/lib/esm/components/line_items/LineItemOption.js +1 -1
  387. package/lib/esm/components/line_items/LineItemOptions.d.ts +1 -1
  388. package/lib/esm/components/line_items/LineItemQuantity.d.ts +1 -1
  389. package/lib/esm/components/line_items/LineItemRemoveLink.d.ts +2 -2
  390. package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
  391. package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -1
  392. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -1
  393. package/lib/esm/components/orders/AddToCartButton.d.ts +3 -3
  394. package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -1
  395. package/lib/esm/components/orders/CartLink.d.ts +2 -2
  396. package/lib/esm/components/orders/CheckoutLink.d.ts +1 -1
  397. package/lib/esm/components/orders/DiscountAmount.d.ts +1 -1
  398. package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -1
  399. package/lib/esm/components/orders/OrderContainer.d.ts +1 -1
  400. package/lib/esm/components/orders/OrderContainer.js +1 -1
  401. package/lib/esm/components/orders/OrderList.d.ts +2 -2
  402. package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -1
  403. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -1
  404. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -1
  405. package/lib/esm/components/orders/OrderNumber.d.ts +1 -1
  406. package/lib/esm/components/orders/OrderStorage.d.ts +1 -1
  407. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -1
  408. package/lib/esm/components/orders/PlaceOrderButton.d.ts +2 -2
  409. package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
  410. package/lib/esm/components/orders/PlaceOrderContainer.d.ts +2 -2
  411. package/lib/esm/components/orders/PlaceOrderContainer.js +1 -1
  412. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -1
  413. package/lib/esm/components/orders/ShippingAmount.d.ts +1 -1
  414. package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -1
  415. package/lib/esm/components/orders/TaxesAmount.d.ts +1 -1
  416. package/lib/esm/components/orders/TotalAmount.d.ts +1 -1
  417. package/lib/esm/components/parcels/ParcelField.d.ts +2 -2
  418. package/lib/esm/components/parcels/ParcelField.js +1 -1
  419. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +2 -2
  420. package/lib/esm/components/parcels/ParcelLineItemField.js +1 -1
  421. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -1
  422. package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -1
  423. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -1
  424. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -1
  425. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -1
  426. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -1
  427. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -1
  428. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +2 -2
  429. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
  430. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -1
  431. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -1
  432. package/lib/esm/components/payment_gateways/StripeGateway.js +1 -1
  433. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -1
  434. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +14 -1
  435. package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
  436. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -1
  437. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -1
  438. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.d.ts +2 -2
  439. package/lib/esm/components/payment_methods/PaymentMethodsContainer.d.ts +2 -2
  440. package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -1
  441. package/lib/esm/components/payment_source/AdyenPayment.d.ts +2 -2
  442. package/lib/esm/components/payment_source/BraintreePayment.d.ts +3 -5
  443. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +3 -3
  444. package/lib/esm/components/payment_source/ExternalPayment.d.ts +2 -2
  445. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +2 -2
  446. package/lib/esm/components/payment_source/KlarnaPayment.js +1 -1
  447. package/lib/esm/components/payment_source/PaymentSource.d.ts +2 -2
  448. package/lib/esm/components/payment_source/PaymentSource.js +1 -1
  449. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +2 -2
  450. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +2 -2
  451. package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -1
  452. package/lib/esm/components/payment_source/PaymentSourceEditButton.d.ts +2 -2
  453. package/lib/esm/components/payment_source/PaypalPayment.d.ts +1 -1
  454. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +5 -0
  455. package/lib/esm/components/payment_source/StripeExpressPayment.js +1 -0
  456. package/lib/esm/components/payment_source/StripePayment.d.ts +8 -5
  457. package/lib/esm/components/payment_source/StripePayment.js +1 -1
  458. package/lib/esm/components/prices/Price.d.ts +2 -2
  459. package/lib/esm/components/prices/PricesContainer.d.ts +1 -1
  460. package/lib/esm/components/prices/PricesContainer.js +1 -1
  461. package/lib/esm/components/shipments/Shipment.d.ts +1 -1
  462. package/lib/esm/components/shipments/ShipmentField.d.ts +1 -1
  463. package/lib/esm/components/shipments/ShipmentsContainer.d.ts +1 -1
  464. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -1
  465. package/lib/esm/components/shipments/ShipmentsCount.d.ts +1 -1
  466. package/lib/esm/components/shipping_methods/ShippingMethod.d.ts +1 -1
  467. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -1
  468. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -1
  469. package/lib/esm/components/skus/AvailabilityContainer.d.ts +1 -1
  470. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +2 -2
  471. package/lib/esm/components/skus/SkuField.d.ts +2 -2
  472. package/lib/esm/components/skus/SkuField.js +1 -1
  473. package/lib/esm/components/skus/SkuList.d.ts +1 -1
  474. package/lib/esm/components/skus/SkuListsContainer.d.ts +1 -1
  475. package/lib/esm/components/skus/Skus.d.ts +1 -1
  476. package/lib/esm/components/skus/SkusContainer.d.ts +1 -1
  477. package/lib/esm/components/skus/SkusContainer.js +1 -1
  478. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +2 -2
  479. package/lib/esm/components/stock_transfers/StockTransferField.js +1 -1
  480. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -1
  481. package/lib/esm/components/utils/AddressCardsTemplate.js +1 -1
  482. package/lib/esm/components/utils/BaseField.d.ts +1 -1
  483. package/lib/esm/components/utils/BaseInput.d.ts +1 -1
  484. package/lib/esm/components/utils/BaseOrderPrice.d.ts +3 -3
  485. package/lib/esm/components/utils/BaseSelect.d.ts +1 -1
  486. package/lib/esm/components/utils/ErrorBoundary.d.ts +1 -1
  487. package/lib/esm/components/utils/GenericFieldComponent.d.ts +7 -7
  488. package/lib/esm/components/utils/Parent.d.ts +1 -1
  489. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +3 -3
  490. package/lib/esm/components/utils/PriceTemplate.d.ts +1 -1
  491. package/lib/esm/components/utils/getAllErrors.d.ts +3 -3
  492. package/lib/esm/context/AddressChildrenContext.d.ts +1 -1
  493. package/lib/esm/context/AddressContext.d.ts +2 -2
  494. package/lib/esm/context/BillingAddressContext.d.ts +1 -1
  495. package/lib/esm/context/BillingAddressFormContext.d.ts +5 -7
  496. package/lib/esm/context/CouponAndGiftCardFormContext.d.ts +1 -1
  497. package/lib/esm/context/CustomerAddressFormContext.d.ts +7 -9
  498. package/lib/esm/context/CustomerContext.d.ts +1 -1
  499. package/lib/esm/context/CustomerPaymentSourceContext.d.ts +1 -1
  500. package/lib/esm/context/GiftCardContext.d.ts +2 -2
  501. package/lib/esm/context/LineItemChildrenContext.d.ts +1 -1
  502. package/lib/esm/context/LineItemContext.d.ts +2 -2
  503. package/lib/esm/context/LineItemOptionChildrenContext.d.ts +5 -2
  504. package/lib/esm/context/OrderContext.d.ts +3 -3
  505. package/lib/esm/context/OrderListChildrenContext.d.ts +1 -1
  506. package/lib/esm/context/OrderListPaginationContext.d.ts +1 -1
  507. package/lib/esm/context/PaymentMethodChildrenContext.d.ts +2 -1
  508. package/lib/esm/context/PaymentMethodContext.d.ts +1 -1
  509. package/lib/esm/context/PlaceOrderContext.d.ts +2 -2
  510. package/lib/esm/context/PricesContext.d.ts +1 -1
  511. package/lib/esm/context/ShipmentContext.d.ts +1 -1
  512. package/lib/esm/context/ShippingAddressContext.d.ts +1 -1
  513. package/lib/esm/context/ShippingAddressFormContext.d.ts +1 -1
  514. package/lib/esm/context/ShippingMethodChildrenContext.d.ts +1 -1
  515. package/lib/esm/context/SkuChildrenContext.d.ts +1 -1
  516. package/lib/esm/context/SkuContext.d.ts +1 -1
  517. package/lib/esm/context/StockTransferChildrenContext.d.ts +1 -1
  518. package/lib/esm/reducers/AddressReducer.d.ts +6 -6
  519. package/lib/esm/reducers/AvailabilityReducer.d.ts +4 -4
  520. package/lib/esm/reducers/BillingAddressReducer.d.ts +4 -4
  521. package/lib/esm/reducers/CustomerReducer.d.ts +4 -4
  522. package/lib/esm/reducers/GiftCardReducer.d.ts +6 -6
  523. package/lib/esm/reducers/LineItemReducer.d.ts +6 -6
  524. package/lib/esm/reducers/OrderReducer.d.ts +6 -6
  525. package/lib/esm/reducers/PaymentMethodReducer.d.ts +16 -12
  526. package/lib/esm/reducers/PlaceOrderReducer.d.ts +4 -1
  527. package/lib/esm/reducers/PriceReducer.d.ts +6 -8
  528. package/lib/esm/reducers/ShipmentReducer.d.ts +5 -5
  529. package/lib/esm/reducers/ShippingAddressReducer.d.ts +4 -4
  530. package/lib/esm/reducers/SkuListsReducer.d.ts +2 -2
  531. package/lib/esm/reducers/SkuReducer.d.ts +4 -4
  532. package/lib/esm/typings/errors.d.ts +1 -1
  533. package/lib/esm/typings/index.d.ts +7 -11
  534. package/lib/esm/utils/PropsType.d.ts +2 -2
  535. package/lib/esm/utils/addressesManager.d.ts +3 -3
  536. package/lib/esm/utils/baseReducer.d.ts +1 -1
  537. package/lib/esm/utils/checkIncludeResource.d.ts +1 -1
  538. package/lib/esm/utils/customMessages.d.ts +1 -1
  539. package/lib/esm/utils/expressPaymentHelper.d.ts +83 -0
  540. package/lib/esm/utils/expressPaymentHelper.js +1 -0
  541. package/lib/esm/utils/filterChildren.d.ts +1 -1
  542. package/lib/esm/utils/getCardDetails.d.ts +3 -3
  543. package/lib/esm/utils/getCardDetails.js +1 -1
  544. package/lib/esm/utils/getErrors.d.ts +4 -3
  545. package/lib/esm/utils/getLoaderComponent.d.ts +1 -1
  546. package/lib/esm/utils/getPaymentAttributes.d.ts +3 -3
  547. package/lib/esm/utils/getPrices.d.ts +2 -2
  548. package/lib/esm/utils/getSdk.d.ts +1 -1
  549. package/lib/esm/utils/getSkus.d.ts +1 -1
  550. package/lib/esm/utils/hooks/useCustomContext.d.ts +1 -1
  551. package/lib/esm/utils/isEmpty.d.ts +1 -0
  552. package/lib/esm/utils/isEmpty.js +1 -0
  553. package/lib/esm/utils/localStorage.js +1 -1
  554. package/lib/esm/utils/shipments.d.ts +1 -1
  555. package/lib/esm/utils/validateFormFields.d.ts +6 -6
  556. package/lib/esm/utils/validateFormFields.js +1 -1
  557. package/package.json +19 -19
  558. package/lib/tsconfig.prod.esm.tsbuildinfo +0 -1
  559. package/lib/tsconfig.prod.tsbuildinfo +0 -1
@@ -1,4 +1,4 @@
1
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ChildrenFunction } from '../../typings/index';
2
2
  interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
3
3
  /**
4
4
  * Function allow you to customize the component
@@ -1,5 +1,5 @@
1
1
  import { type OrderListPaginationContext as TOrderListPaginationContext } from '../../context/OrderListPaginationContext';
2
- import { ChildrenFunction } from '../../typings/index';
2
+ import { type ChildrenFunction } from '../../typings/index';
3
3
  interface PaginationButton extends Omit<JSX.IntrinsicElements['button'], 'children' | 'disabled'> {
4
4
  /**
5
5
  * Show or hide the pagination button. Default is true.
@@ -1,4 +1,4 @@
1
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ChildrenFunction } from '../../typings/index';
2
2
  type TAsComponent = keyof Pick<JSX.IntrinsicElements, 'p' | 'span' | 'div'>;
3
3
  type ChildrenProps<A extends TAsComponent> = Omit<Props<A>, 'children'> & {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { BaseFieldProps } from '../utils/BaseField';
1
+ import { type BaseFieldProps } from '../utils/BaseField';
2
2
  type Props = Omit<BaseFieldProps, 'attribute'>;
3
3
  export declare function OrderNumber(props: Props): JSX.Element;
4
4
  export default OrderNumber;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  interface Props {
3
3
  children: ReactNode;
4
4
  persistKey: string;
@@ -1,3 +1,3 @@
1
- import { BaseAmountComponent } from '../../typings/index';
1
+ import { type BaseAmountComponent } from '../../typings/index';
2
2
  export declare function PaymentMethodAmount(props: BaseAmountComponent): JSX.Element;
3
3
  export default PaymentMethodAmount;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ReactNode } from 'react';
2
+ import { type ChildrenFunction } from '../../typings/index';
3
3
  import type { BaseError } from '../../typings/errors';
4
4
  import type { Order } from '@commercelayer/sdk';
5
5
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import PlaceOrderContext from"../../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import getCardDetails from"../../utils/getCardDetails";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,currentPaymentMethodRef?.current?.onsubmit,loading,currentPaymentMethodType,order,paymentSource]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.paypalPayerId,paymentType]),useEffect(()=>{if(order?.status!=null&&["draft","pending"].includes(order?.status))if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&paymentSource!=null){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else(paymentType==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes||paymentType==="adyen_payments"&&order?.payment_source?.payment_response?.resultCode==="Authorised"&&ref?.current?.disabled===!1)&&handleClick()},[options?.adyen,paymentType,order?.payment_source?.payment_response?.resultCode]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref]);const handleClick=async e=>{e?.preventDefault(),e?.stopPropagation();let isValid=!0;setForceDisable(!0);const checkPaymentSource=await setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}),card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:checkPaymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit(checkPaymentSource),!isValid&&checkPaymentSource.payment_response?.resultCode==="Authorised"&&(isValid=!0)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&await setPlaceOrder({paymentSource:checkPaymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps={...p,label,disabled:disabledButton,handleClick,ref};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)},...p,children:isFunction(label)?label():label})}export default PlaceOrderButton;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import PlaceOrderContext from"../../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import getCardDetails from"../../utils/getCardDetails";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,currentPaymentMethodRef?.current?.onsubmit,loading,currentPaymentMethodType,order,paymentSource]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.paypalPayerId,paymentType]),useEffect(()=>{paymentType==="stripe_payments"&&options?.stripe?.redirectStatus==="succeeded"&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.stripe?.redirectStatus,paymentType]),useEffect(()=>{if(order?.status!=null&&["draft","pending"].includes(order?.status))if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&paymentSource!=null){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else(paymentType==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes||paymentType==="adyen_payments"&&order?.payment_source?.payment_response?.resultCode==="Authorised"&&ref?.current?.disabled===!1)&&handleClick()},[options?.adyen,paymentType,order?.payment_source?.payment_response?.resultCode]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref]);const handleClick=async e=>{e?.preventDefault(),e?.stopPropagation();let isValid=!0;setForceDisable(!0);const checkPaymentSource=await setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}),card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:checkPaymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit(checkPaymentSource),!isValid&&checkPaymentSource.payment_response?.resultCode==="Authorised"&&(isValid=!0)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&await setPlaceOrder({paymentSource:checkPaymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps={...p,label,disabled:disabledButton,handleClick,ref};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)},...p,children:isFunction(label)?label():label})}export default PlaceOrderButton;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { PlaceOrderOptions } from '../../reducers/PlaceOrderReducer';
1
+ import { type ReactNode } from 'react';
2
+ import { type PlaceOrderOptions } from '../../reducers/PlaceOrderReducer';
3
3
  interface Props {
4
4
  children: ReactNode;
5
5
  options?: PlaceOrderOptions;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import PlaceOrderContext from"../../context/PlaceOrderContext";import{useContext,useEffect,useReducer}from"react";import placeOrderReducer,{placeOrderInitialState,placeOrderPermitted,setButtonRef}from"../../reducers/PlaceOrderReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import{setPlaceOrder}from"../../reducers/PlaceOrderReducer";import useCustomContext from"../../utils/hooks/useCustomContext";export function PlaceOrderContainer(props){const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrder,setOrderErrors,include,addResourceToInclude,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PlaceOrderContainer",key:"order"}),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.stock_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.stock_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address",resourcesIncluded:include}),order&&placeOrderPermitted({config,dispatch,order,options:{...options}})},[order,include,includeLoaded]);const contextValue={...state,setPlaceOrder:async({paymentSource})=>await setPlaceOrder({config,order,state,setOrderErrors,paymentSource,include,setOrder}),placeOrderPermitted:()=>placeOrderPermitted({config,dispatch,order,options:{...options}}),setButtonRef:ref=>setButtonRef(ref,dispatch)};return _jsx(PlaceOrderContext.Provider,{value:contextValue,children})}export default PlaceOrderContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import PlaceOrderContext from"../../context/PlaceOrderContext";import{useContext,useEffect,useReducer}from"react";import placeOrderReducer,{placeOrderInitialState,placeOrderPermitted,setButtonRef}from"../../reducers/PlaceOrderReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import{setPlaceOrder}from"../../reducers/PlaceOrderReducer";import useCustomContext from"../../utils/hooks/useCustomContext";export function PlaceOrderContainer(props){const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrder,setOrderErrors,include,addResourceToInclude,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PlaceOrderContainer",key:"order"}),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.stock_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.stock_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address",resourcesIncluded:include}),order&&placeOrderPermitted({config,dispatch,order,options:{...options}})},[order,include,includeLoaded]);const contextValue={...state,setPlaceOrder:async({paymentSource})=>await setPlaceOrder({config,order,state,setOrderErrors,paymentSource,include,setOrder}),placeOrderPermitted:()=>{placeOrderPermitted({config,dispatch,order,options:{...options}})},setButtonRef:ref=>{setButtonRef(ref,dispatch)}};return _jsx(PlaceOrderContext.Provider,{value:contextValue,children})}export default PlaceOrderContainer;
@@ -1,3 +1,3 @@
1
- import { BaseInputProps } from '../utils/BaseInput';
1
+ import { type BaseInputProps } from '../utils/BaseInput';
2
2
  export declare function PrivacyAndTermsCheckbox(props: Partial<BaseInputProps>): JSX.Element;
3
3
  export default PrivacyAndTermsCheckbox;
@@ -1,3 +1,3 @@
1
- import { BaseAmountComponent } from '../../typings/index';
1
+ import { type BaseAmountComponent } from '../../typings/index';
2
2
  export declare function ShippingAmount(props: BaseAmountComponent): JSX.Element;
3
3
  export default ShippingAmount;
@@ -1,3 +1,3 @@
1
- import { BaseAmountComponent } from '../../typings/index';
1
+ import { type BaseAmountComponent } from '../../typings/index';
2
2
  export declare function SubTotalAmount(props: BaseAmountComponent): JSX.Element;
3
3
  export default SubTotalAmount;
@@ -1,3 +1,3 @@
1
- import { BaseAmountComponent } from '../../typings/index';
1
+ import { type BaseAmountComponent } from '../../typings/index';
2
2
  export declare function TaxesAmount(props: BaseAmountComponent): JSX.Element;
3
3
  export default TaxesAmount;
@@ -1,3 +1,3 @@
1
- import { BaseAmountComponent } from '../../typings/index';
1
+ import { type BaseAmountComponent } from '../../typings/index';
2
2
  export declare function TotalAmount(props: BaseAmountComponent): JSX.Element;
3
3
  export default TotalAmount;
@@ -1,5 +1,5 @@
1
- import { ConditionalElement } from '../../typings/index';
2
- import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
1
+ import { type ConditionalElement } from '../../typings/index';
2
+ import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
3
  type ParcelFieldChildrenProps = TGenericChildrenProps<TResources['Parcel']>;
4
4
  type TCondition = ConditionalElement<Exclude<TResources['Parcel'], 'resource'>>;
5
5
  type Props = {
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelChildrenContext from"../../context/ParcelChildrenContext";export function ParcelField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcel",attribute,tagElement,context:ParcelChildrenContext,...p,children})}export default ParcelField;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelChildrenContext from"../../context/ParcelChildrenContext";export function ParcelField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcel",attribute,tagElement,context:ParcelChildrenContext,...p,children})}export default ParcelField;
@@ -1,5 +1,5 @@
1
- import { ConditionalElement } from '../../typings/index';
2
- import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
1
+ import { type ConditionalElement } from '../../typings/index';
2
+ import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
3
  type ParcelLineItemFieldChildrenProps = TGenericChildrenProps<TResources['ParcelLineItem']>;
4
4
  type TCondition = ConditionalElement<Exclude<TResources['ParcelLineItem'], 'resource'>>;
5
5
  type Props = {
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelLineItemChildrenContext from"../../context/ParcelLineItemChildrenContext";export function ParcelLineItemField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcelLineItem",attribute,tagElement,context:ParcelLineItemChildrenContext,...p,children})}export default ParcelLineItemField;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelLineItemChildrenContext from"../../context/ParcelLineItemChildrenContext";export function ParcelLineItemField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcelLineItem",attribute,tagElement,context:ParcelLineItemChildrenContext,...p,children})}export default ParcelLineItemField;
@@ -1,4 +1,4 @@
1
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ChildrenFunction } from '../../typings/index';
2
2
  import type { Parcel } from '@commercelayer/sdk';
3
3
  interface ChildrenProps extends Omit<Props, 'children'> {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ChildrenFunction } from '../../typings/index';
2
2
  import type { Parcel } from '@commercelayer/sdk';
3
3
  interface ChildrenProps extends Omit<Props, 'children'> {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function AdyenGateway(props: Props): JSX.Element | null;
4
4
  export default AdyenGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function BraintreeGateway(props: Props): JSX.Element | null;
4
4
  export default BraintreeGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function CheckoutComGateway(props: Props): JSX.Element | null;
4
4
  export default CheckoutComGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function ExternalGateway(props: Props): JSX.Element | null;
4
4
  export default ExternalGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function KlarnaGateway(props: Props): JSX.Element | null;
4
4
  export default KlarnaGateway;
@@ -1,5 +1,5 @@
1
- import { LoaderType } from '../../typings/index';
2
- import { PaymentSourceProps } from '../payment_source/PaymentSource';
1
+ import { type LoaderType } from '../../typings/index';
2
+ import { type PaymentSourceProps } from '../payment_source/PaymentSource';
3
3
  export type GatewayBaseType = Props & {
4
4
  show: boolean;
5
5
  loading: boolean;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||(!paymentSource||paymentSource.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource&&!expressPayments){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show&&!expressPayments||(!paymentSource&&!expressPayments||paymentSource?.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return expressPayments&&setLoading(!1),()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = Partial<GatewayBaseType>;
3
3
  export declare function PaypalGateway(props: Props): JSX.Element | null;
4
4
  export default PaypalGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function StripeGateway(props: Props): JSX.Element | null;
4
4
  export default StripeGateway;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../payment_source/StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,paymentSourceId=order?.payment_source?.id||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(StripePayment,{show,templateCustomerSaveToWallet,publishableKey,locale,...stripeConfig})]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,{show,publishableKey,locale,...stripeConfig}):loaderComponent}export default StripeGateway;
1
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../payment_source/StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment,expressPayments}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,clientSecret=paymentSource?.client_secret,paymentSourceId=order?.payment_source?.id||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(StripePayment,{show,templateCustomerSaveToWallet,publishableKey,clientSecret,expressPayments,locale,...stripeConfig})]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,{show,publishableKey,clientSecret,locale,expressPayments,...stripeConfig}):loaderComponent}export default StripeGateway;
@@ -1,4 +1,4 @@
1
- import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
1
+ import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
2
  type Props = GatewayBaseType;
3
3
  export declare function WireTransferGateway(props: Props): JSX.Element | null;
4
4
  export default WireTransferGateway;
@@ -12,9 +12,22 @@ type Props = {
12
12
  */
13
13
  hide?: PaymentResource[] | ((payment: PaymentMethodType) => boolean);
14
14
  children: DefaultChildrenType;
15
+ /**
16
+ * Set CSS classes when the payment method is selected
17
+ */
15
18
  activeClass?: string;
19
+ /**
20
+ * Customize the loader component
21
+ */
16
22
  loader?: LoaderType;
23
+ /**
24
+ * Auto select the payment method when there is only one available
25
+ */
17
26
  autoSelectSinglePaymentMethod?: boolean | (() => void);
27
+ /**
28
+ * Enable express payment. Other payment methods will be disabled.
29
+ */
30
+ expressPayments?: boolean;
18
31
  } & Omit<JSX.IntrinsicElements['div'], 'onClick' | 'children'> & ({
19
32
  clickableContainer: true;
20
33
  onClick?: (params?: TOnClickParams) => void;
@@ -22,5 +35,5 @@ type Props = {
22
35
  clickableContainer?: never;
23
36
  onClick?: never;
24
37
  });
25
- export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, autoSelectSinglePaymentMethod, hide, onClick, ...p }: Props): JSX.Element;
38
+ export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, autoSelectSinglePaymentMethod, expressPayments, hide, onClick, ...p }: Props): JSX.Element;
26
39
  export default PaymentMethod;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";import OrderContext from"../../context/OrderContext";import CustomerContext from"../../context/CustomerContext";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,autoSelectSinglePaymentMethod,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder,paymentSource,setPaymentSource,config}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"}),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext);useEffect(()=>{paymentMethods!=null&&autoSelectSinglePaymentMethod!=null&&(async()=>{if(paymentMethods.length===1){const[paymentMethod]=paymentMethods??[];if(paymentMethod&&!paymentSource){setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId});let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),await setPaymentSource({paymentResource,order,attributes})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),getCustomerPaymentSources&&await getCustomerPaymentSources(),setLoadingPlaceOrder({loading:!1})}typeof autoSelectSinglePaymentMethod=="function"&&autoSelectSinglePaymentMethod()}else setTimeout(()=>{setLoading(!1)},200)})()},[paymentMethods]),useEffect(()=>(paymentMethods&&(paymentMethods.length===1&&autoSelectSinglePaymentMethod?paymentSource&&setTimeout(()=>{setLoading(!1)},200):setLoading(!1)),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id,{order:order2}=await setPaymentMethod({paymentResource,paymentMethodId});onClick&&onClick({payment,order:order2}),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-testid":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";import OrderContext from"../../context/OrderContext";import CustomerContext from"../../context/CustomerContext";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import{isEmpty}from"../../utils/isEmpty";import{getAvailableExpressPayments}from"../../utils/expressPaymentHelper";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,autoSelectSinglePaymentMethod,expressPayments,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder,paymentSource,setPaymentSource,config}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"}),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext);useEffect(()=>{if(paymentMethods!=null&&!isEmpty(paymentMethods)&&expressPayments){const[paymentMethod]=getAvailableExpressPayments(paymentMethods);!paymentSource&&paymentMethod!=null&&(async()=>{setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId}),await setPaymentSource({paymentResource,order})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),setLoadingPlaceOrder({loading:!1})})()}},[!isEmpty(paymentMethods),expressPayments]),useEffect(()=>{paymentMethods!=null&&autoSelectSinglePaymentMethod!=null&&!expressPayments&&(async()=>{if(paymentMethods.length===1){const[paymentMethod]=paymentMethods??[];if(paymentMethod&&!paymentSource){setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId});let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),await setPaymentSource({paymentResource,order,attributes})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),getCustomerPaymentSources&&getCustomerPaymentSources(),setLoadingPlaceOrder({loading:!1})}typeof autoSelectSinglePaymentMethod=="function"&&autoSelectSinglePaymentMethod()}else setTimeout(()=>{setLoading(!1)},200)})()},[paymentMethods,expressPayments]),useEffect(()=>(paymentMethods&&(paymentMethods.length===1&&autoSelectSinglePaymentMethod?paymentSource&&setTimeout(()=>{setLoading(!1)},200):setLoading(!1)),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected,expressPayments},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id,{order:order2}=await setPaymentMethod({paymentResource,paymentMethodId});onClick&&onClick({payment,order:order2}),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-testid":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
@@ -1,4 +1,4 @@
1
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ChildrenFunction } from '../../typings/index';
2
2
  interface ChildrenProps extends Omit<Props, 'children'> {
3
3
  labelName: string;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { BaseAmountComponent } from '../../typings/index';
1
+ import { type BaseAmountComponent } from '../../typings/index';
2
2
  interface Props extends BaseAmountComponent {
3
3
  type?: 'amount';
4
4
  labelFree?: string;
@@ -1,6 +1,6 @@
1
- import { ChangeEvent } from 'react';
1
+ import { type ChangeEvent } from 'react';
2
2
  import type { Order, PaymentMethod } from '@commercelayer/sdk';
3
- import { ChildrenFunction } from '../../typings/index';
3
+ import { type ChildrenFunction } from '../../typings/index';
4
4
  interface ChildrenProps extends Omit<Props, 'children'> {
5
5
  checked: boolean;
6
6
  handleOnChange: (event: ChangeEvent<HTMLInputElement>) => Promise<void>;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
1
+ import { type ReactNode } from 'react';
2
+ import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
3
  interface Props {
4
4
  children: ReactNode;
5
5
  config?: PaymentMethodConfig;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import isEmpty from"lodash/isEmpty";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PaymentMethodsContainer",key:"order"}),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPayMethods(),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include?.length,Object.keys(includeLoaded??[]).length]);const contextValue=useMemo(()=>({...state,setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod({...args,config:credentials,updateOrder,order,dispatch,setOrderErrors}),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource({...state,...args,config:credentials,dispatch,getOrder,updateOrder,order}),updatePaymentSource:async args=>await defaultPaymentMethodContext.updatePaymentSource({...args,config:credentials,dispatch}),destroyPaymentSource:async args=>await defaultPaymentMethodContext.destroyPaymentSource({...args,dispatch,config:credentials,updateOrder,orderId:order?.id})}),[state]);return _jsx(PaymentMethodContext.Provider,{value:contextValue,children})}export default PaymentMethodsContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import useCustomContext from"../../utils/hooks/useCustomContext";import{isEmpty}from"../../utils/isEmpty";export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PaymentMethodsContainer",key:"order"}),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPayMethods(),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include?.length,Object.keys(includeLoaded??[]).length]);const contextValue=useMemo(()=>({...state,setLoading:({loading})=>{defaultPaymentMethodContext.setLoading({loading,dispatch})},setPaymentRef:({ref})=>{setPaymentRef({ref,dispatch})},setPaymentMethodErrors:errors=>{defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch)},setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod({...args,config:credentials,updateOrder,order,dispatch,setOrderErrors}),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource({...state,...args,config:credentials,dispatch,getOrder,updateOrder,order}),updatePaymentSource:async args=>{await defaultPaymentMethodContext.updatePaymentSource({...args,config:credentials,dispatch})},destroyPaymentSource:async args=>{await defaultPaymentMethodContext.destroyPaymentSource({...args,dispatch,config:credentials,updateOrder,orderId:order?.id})}}),[state]);return _jsx(PaymentMethodContext.Provider,{value:contextValue,children})}export default PaymentMethodsContainer;
@@ -1,5 +1,5 @@
1
- import { CSSProperties } from 'react';
2
- import { PaymentSourceProps } from './PaymentSource';
1
+ import { type CSSProperties } from 'react';
2
+ import { type PaymentSourceProps } from './PaymentSource';
3
3
  type Styles = Partial<{
4
4
  base: CSSProperties;
5
5
  error: CSSProperties;
@@ -1,5 +1,5 @@
1
- import { HostedFieldFieldOptions } from 'braintree-web/modules/hosted-fields';
2
- import { PaymentSourceProps } from './PaymentSource';
1
+ import { type HostedFieldFieldOptions } from 'braintree-web/modules/hosted-fields';
2
+ import { type PaymentSourceProps } from './PaymentSource';
3
3
  type BraintreeHostedFields<Type> = {
4
4
  [Property in keyof Type]: {
5
5
  label?: string;
@@ -15,9 +15,7 @@ export interface BraintreeConfig {
15
15
  fieldLabelClassName?: string;
16
16
  inputWrapperClassName?: string;
17
17
  fields?: BraintreeHostedFields<HostedFieldFieldOptions>;
18
- styles?: {
19
- [key: string]: Record<string, string>;
20
- };
18
+ styles?: Record<string, Record<string, string>>;
21
19
  }
22
20
  interface Props {
23
21
  authorization: string;
@@ -1,6 +1,6 @@
1
- import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
2
- import { PaymentSourceProps } from './PaymentSource';
3
- import { FramesStyle } from 'frames-react';
1
+ import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
2
+ import { type PaymentSourceProps } from './PaymentSource';
3
+ import { type FramesStyle } from 'frames-react';
4
4
  export interface CheckoutComConfig {
5
5
  containerClassName?: string;
6
6
  hintLabel?: string;
@@ -1,6 +1,6 @@
1
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ChildrenFunction } from '../../typings/index';
2
2
  import type { StripeElementLocale } from '@stripe/stripe-js';
3
- import { PaymentSourceProps } from './PaymentSource';
3
+ import { type PaymentSourceProps } from './PaymentSource';
4
4
  export interface ExternalPaymentConfig {
5
5
  /**
6
6
  * Show the component. Default is false
@@ -1,5 +1,5 @@
1
- import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
2
- import { PaymentSourceProps } from './PaymentSource';
1
+ import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
2
+ import { type PaymentSourceProps } from './PaymentSource';
3
3
  type KlarnaPaymentProps = PaymentMethodConfig['klarnaPayment'] & JSX.IntrinsicElements['div'] & Partial<PaymentSourceProps['templateCustomerSaveToWallet']> & {
4
4
  show?: boolean;
5
5
  clientToken: string;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";import PlaceOrderContext from"../../context/PlaceOrderContext";function typeOfLine(lineItemType){switch(lineItemType){case"percentage_discount_promotions":return"discount";case"shipments":return"shipping_fee";case"skus":return"physical";case"payment_methods":default:return null}}function klarnaOrderLines(lineItems){return lineItems?lineItems.map(item=>{const type=item.item_type?typeOfLine(item.item_type):null;return{name:item.name,quantity:item.quantity,total_amount:item.total_amount_cents,unit_price:item.unit_amount_cents,type}}):[]}export default function KlarnaPayment({clientToken,placeOrderCallback,locale="EN",...p}){const ref=useRef(null),{paymentSource,currentPaymentMethodType,setPaymentRef,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{setPlaceOrder}=useContext(PlaceOrderContext),loaded=useExternalScript("https://x.klarnacdn.net/kp/lib/v1/api.js"),[klarna,setKlarna]=useState(),{containerClassName,...divProps}=p;useEffect(()=>{loaded&&window?.Klarna!==void 0&&setKlarna(window.Klarna)},[loaded,window.Klarna]),useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&loaded&&klarna&&(ref.current.onsubmit=async()=>await handleClick(klarna),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType,loaded,klarna]);const handleClick=async kl=>{const[first]=paymentSource?.payment_methods||void 0,paymentMethodCategory=first?.identifier,billingAddress={given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:null,organization_name:null,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shippingAddress={given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,email:order?.customer_email,street_address:order?.shipping_address?.line_1,street_address2:null,postal_code:order?.shipping_address?.zip_code,organization_name:null,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code},klarnaData={merchant_data:order?.id,purchase_country:order?.country_code,purchase_currency:order?.currency_code,locale,shipping_address:shippingAddress,billing_address:billingAddress,order_amount:order?.total_amount_cents,order_lines:klarnaOrderLines(order?.line_items)};try{kl.Payments.load({container:"#klarna-payments-container",payment_method_category:paymentMethodCategory},{billing_address:billingAddress,shipping_address:shippingAddress},async function({show_form}){if(show_form)try{await kl.Payments.authorize({payment_method_category:paymentMethodCategory},klarnaData,async function(res){if(res.approved&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{auth_token:res.authorization_token}}),{placed}=setPlaceOrder&&ps&&await setPlaceOrder({paymentSource:ps})||{placed:!1};placed&&placeOrderCallback&&placeOrderCallback({placed})}})}catch(e){console.error("e",e),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:"Authorization error"}])}})}catch(e){console.error("Load Klarna libray",e)}};if(klarna&&clientToken){const[first]=paymentSource?.payment_methods||void 0;klarna.Payments.init({client_token:clientToken}),klarna.Payments.load({container:"#klarna-payments-container",payment_method_category:first?.identifier},{billing_address:{given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:order?.billing_address?.line_2,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shipping_address:{given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,street_address:order?.shipping_address?.line_1,street_address2:order?.shipping_address?.line_2,postal_code:order?.shipping_address?.zip_code,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code}})}return _jsx("form",{ref,children:_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"klarna-payments-container"})})})}
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";import PlaceOrderContext from"../../context/PlaceOrderContext";function typeOfLine(lineItemType){switch(lineItemType){case"percentage_discount_promotions":return"discount";case"shipments":return"shipping_fee";case"skus":return"physical";case"payment_methods":default:return null}}function klarnaOrderLines(lineItems){return lineItems?lineItems.map(item=>{const type=item.item_type?typeOfLine(item.item_type):null;return{name:item.name,quantity:item.quantity,total_amount:item.total_amount_cents,unit_price:item.unit_amount_cents,type}}):[]}export default function KlarnaPayment({clientToken,placeOrderCallback,locale="EN",...p}){const ref=useRef(null),{paymentSource,currentPaymentMethodType,setPaymentRef,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{setPlaceOrder}=useContext(PlaceOrderContext),loaded=useExternalScript("https://x.klarnacdn.net/kp/lib/v1/api.js"),[klarna,setKlarna]=useState(),{containerClassName,...divProps}=p;useEffect(()=>{loaded&&window?.Klarna!==void 0&&setKlarna(window.Klarna)},[loaded,window.Klarna]),useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&loaded&&klarna&&(ref.current.onsubmit=async()=>{await handleClick(klarna)},setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType,loaded,klarna]);const handleClick=async kl=>{const[first]=paymentSource?.payment_methods||void 0,paymentMethodCategory=first?.identifier,billingAddress={given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:null,organization_name:null,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shippingAddress={given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,email:order?.customer_email,street_address:order?.shipping_address?.line_1,street_address2:null,postal_code:order?.shipping_address?.zip_code,organization_name:null,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code},klarnaData={merchant_data:order?.id,purchase_country:order?.country_code,purchase_currency:order?.currency_code,locale,shipping_address:shippingAddress,billing_address:billingAddress,order_amount:order?.total_amount_cents,order_lines:klarnaOrderLines(order?.line_items)};try{kl.Payments.load({container:"#klarna-payments-container",payment_method_category:paymentMethodCategory},{billing_address:billingAddress,shipping_address:shippingAddress},async function({show_form}){if(show_form)try{await kl.Payments.authorize({payment_method_category:paymentMethodCategory},klarnaData,async function(res){if(res.approved&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{auth_token:res.authorization_token}}),{placed}=setPlaceOrder&&ps&&await setPlaceOrder({paymentSource:ps})||{placed:!1};placed&&placeOrderCallback&&placeOrderCallback({placed})}})}catch(e){console.error("e",e),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:"Authorization error"}])}})}catch(e){console.error("Load Klarna libray",e)}};if(klarna&&clientToken){const[first]=paymentSource?.payment_methods||void 0;klarna.Payments.init({client_token:clientToken}),klarna.Payments.load({container:"#klarna-payments-container",payment_method_category:first?.identifier},{billing_address:{given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:order?.billing_address?.line_2,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shipping_address:{given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,street_address:order?.shipping_address?.line_1,street_address2:order?.shipping_address?.line_2,postal_code:order?.shipping_address?.zip_code,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code}})}return _jsx("form",{ref,children:_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"klarna-payments-container"})})})}
@@ -1,5 +1,5 @@
1
- import { LoaderType } from '../../typings/index';
2
- import { CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
1
+ import { type LoaderType } from '../../typings/index';
2
+ import { type CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
3
3
  export interface CustomerCardsProps {
4
4
  handleClick: () => void;
5
5
  }
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!1),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!!expressPayments),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
@@ -1,5 +1,5 @@
1
- import { IconBrand } from '../../context/PaymentSourceContext';
2
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type IconBrand } from '../../context/PaymentSourceContext';
2
+ import { type ChildrenFunction } from '../../typings/index';
3
3
  interface ChildrenProps extends Omit<Props, 'children'> {
4
4
  brand: IconBrand;
5
5
  defaultSrc: string;
@@ -1,5 +1,5 @@
1
- import { IconBrand } from '../../context/PaymentSourceContext';
2
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type IconBrand } from '../../context/PaymentSourceContext';
2
+ import { type ChildrenFunction } from '../../typings/index';
3
3
  interface CustomComponent extends Omit<Props, 'children'> {
4
4
  brand: IconBrand;
5
5
  }
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.replaceAll(/_|-/gm," ")),parentProps={brand:brandName,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...props,children:label||capitalize(brandName)})}export default PaymentSourceBrandName;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.replace(/_|-/gm," ")),parentProps={brand:brandName,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...props,children:label||capitalize(brandName)})}export default PaymentSourceBrandName;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { ChildrenFunction } from '../../typings/index';
1
+ import { type ReactNode } from 'react';
2
+ import { type ChildrenFunction } from '../../typings/index';
3
3
  interface CustomComponent extends Omit<Props, 'children'> {
4
4
  }
5
5
  type Props = {
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  export interface PaypalConfig {
3
3
  return_url: string;
4
4
  cancel_url: string;
@@ -0,0 +1,5 @@
1
+ interface Props {
2
+ clientSecret: string;
3
+ }
4
+ export declare function StripeExpressPayment({ clientSecret }: Props): JSX.Element | null;
5
+ export {};
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{getAvailableExpressPayments,getExpressShippingMethods,setExpressFakeAddress,setExpressPlaceOrder,setExpressShippingMethod,expressRedirectUrl}from"../../utils/expressPaymentHelper";import{isEmpty}from"../../utils/isEmpty";import{PaymentRequestButtonElement,useStripe}from"@stripe/react-stripe-js";import{useContext,useEffect,useState}from"react";export function StripeExpressPayment({clientSecret}){const stripe=useStripe(),[paymentRequest,setPaymentRequest]=useState(null),{accessToken,endpoint}=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{paymentMethods,paymentSource}=useContext(PaymentMethodContext);return useEffect(()=>{if(stripe==null||order==null)return;const pr=stripe.paymentRequest({country:order.country_code??"",currency:order?.currency_code?.toLowerCase()??"",total:{label:`#${order?.number??""}`,amount:order?.total_amount_with_taxes_cents??0},requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:!0});pr.canMakePayment().then(result=>{console.log("available payment:",result),result&&setPaymentRequest(pr)}).catch(err=>{console.error("Can make payment:",err)})},[isEmpty(stripe),isEmpty(order)]),paymentRequest!=null&&stripe!=null?(paymentRequest.on("shippingaddresschange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const requiresBillingInfo=order?.requires_billing_info??!1,orderWithShipments=await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:"Fake name",last_name:"Fake lastname",country_code:ev.shippingAddress.country??"",line_1:"Fake street 123",city:ev.shippingAddress.city??"Fake city",zip_code:ev.shippingAddress.postalCode??"12345",state_code:ev.shippingAddress.region??"Fake state",phone:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),shippingOptions=getExpressShippingMethods(orderWithShipments);shippingOptions!=null&&!isEmpty(shippingOptions)?ev.updateWith({status:"success",shippingOptions,total:{label:`#${orderWithShipments?.number??""}`,amount:orderWithShipments?.total_amount_with_taxes_cents??0}}):ev.updateWith({status:"invalid_shipping_address"})}else ev.updateWith({status:"fail"})}),paymentRequest.on("shippingoptionchange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const updatedOrder=await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev.shippingOption.id,params:{include:["shipments.available_shipping_methods"]}});ev.updateWith({status:"success",total:{label:`#${updatedOrder?.number??""}`,amount:updatedOrder?.total_amount_with_taxes_cents??0}})}else ev.updateWith({status:"fail"})}),paymentRequest.on("paymentmethod",async ev=>{if(console.log("ev",ev),order?.id==null)throw new Error("Order is null");if(paymentMethods==null)throw new Error("Payment methods are null");const[paymentMethod]=getAvailableExpressPayments(paymentMethods);if(paymentMethod==null)throw new Error("Payment method is null");if(paymentSource==null)throw new Error("Payment source is null");const requiresBillingInfo=order?.requires_billing_info??!1,paymentResource=paymentMethod?.payment_source_type;if(accessToken!=null&&endpoint!=null){const[firstName,lastName]=ev.payerName?.split(" ")??[],[line]=ev.shippingAddress?.addressLine??"";await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:firstName??"Fake name",last_name:lastName??"Fake lastname",country_code:ev?.shippingAddress?.country??"",line_1:line??"Fake street 123",city:ev?.shippingAddress?.city??"Fake city",zip_code:ev?.shippingAddress?.postalCode??"12345",state_code:ev?.shippingAddress?.region??"Fake state",phone:ev?.payerPhone??"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev?.shippingOption?.id,params:{include:["shipments.available_shipping_methods"]}});const{paymentIntent,error:confirmError}=await stripe.confirmCardPayment(clientSecret,{payment_method:ev.paymentMethod.id},{handleActions:!1});if(confirmError)ev.complete("fail"),console.error("Confirm card payment:",confirmError);else if(ev.complete("success"),paymentIntent.status==="requires_action"){const{error}=await stripe.confirmCardPayment(clientSecret);if(error)console.error("Confirm card payment:",error);else{const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};try{const order2=await setExpressPlaceOrder(placeOrderParams);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}else{const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};try{const order2=await setExpressPlaceOrder(placeOrderParams);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}}),_jsx(PaymentRequestButtonElement,{className:"",options:{paymentRequest}})):null}