@commercelayer/react-components 4.0.0-alpha.2 → 4.0.0-alpha.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.
- package/lib/cjs/components/Errors.js +1 -1
- package/lib/cjs/components/ExternalFunction.d.ts +1 -1
- package/lib/cjs/components/MetadataInput.d.ts +1 -1
- package/lib/cjs/components/SubmitButton.d.ts +1 -1
- package/lib/cjs/components/addresses/Address.d.ts +1 -1
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +2 -2
- package/lib/cjs/components/addresses/AddressField.d.ts +4 -4
- package/lib/cjs/components/addresses/AddressField.js +1 -1
- package/lib/cjs/components/addresses/AddressInput.d.ts +2 -2
- package/lib/cjs/components/addresses/AddressStateSelector.d.ts +2 -2
- package/lib/cjs/components/addresses/AddressesContainer.d.ts +1 -1
- package/lib/cjs/components/addresses/BillingAddressContainer.d.ts +6 -0
- package/lib/cjs/components/addresses/BillingAddressContainer.js +1 -0
- package/lib/{esm/components → cjs/components/addresses}/BillingAddressForm.d.ts +1 -1
- package/lib/cjs/components/addresses/BillingAddressForm.js +1 -0
- package/lib/cjs/components/addresses/SaveAddressesButton.d.ts +11 -0
- package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -0
- package/lib/{esm/components → cjs/components/addresses}/ShippingAddressContainer.d.ts +1 -1
- package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -0
- package/lib/cjs/components/{ShippingAddressForm.d.ts → addresses/ShippingAddressForm.d.ts} +1 -1
- package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -0
- package/lib/cjs/components/auth/CommerceLayer.d.ts +1 -1
- package/lib/cjs/components/customers/CustomerAddressForm.d.ts +1 -1
- package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
- package/lib/cjs/components/customers/SaveCustomerButton.d.ts +13 -0
- package/lib/cjs/components/{SaveCustomerButton.js → customers/SaveCustomerButton.js} +1 -1
- package/lib/cjs/components/{GiftCard.d.ts → gift_cards/GiftCard.d.ts} +2 -2
- package/lib/cjs/components/gift_cards/GiftCard.js +1 -0
- package/lib/{esm/components → cjs/components/gift_cards}/GiftCardContainer.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -0
- package/lib/cjs/components/{GiftCardCurrencySelector.d.ts → gift_cards/GiftCardCurrencySelector.d.ts} +2 -2
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -0
- package/lib/{esm/components → cjs/components/gift_cards}/GiftCardInput.d.ts +3 -3
- package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -0
- package/lib/cjs/components/{GiftCardOrCouponCode.d.ts → gift_cards/GiftCardOrCouponCode.d.ts} +2 -2
- package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -0
- package/lib/{esm/components → cjs/components/gift_cards}/GiftCardOrCouponForm.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -0
- package/lib/cjs/components/{GiftCardOrCouponInput.d.ts → gift_cards/GiftCardOrCouponInput.d.ts} +2 -2
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -0
- package/lib/cjs/components/{GiftCardOrCouponRemoveButton.d.ts → gift_cards/GiftCardOrCouponRemoveButton.d.ts} +3 -3
- package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
- package/lib/cjs/components/{GiftCardOrCouponSubmit.d.ts → gift_cards/GiftCardOrCouponSubmit.d.ts} +2 -2
- package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
- package/lib/cjs/components/{GiftCardRecipient.d.ts → gift_cards/GiftCardRecipient.d.ts} +0 -0
- package/lib/cjs/components/{GiftCardRecipient.js → gift_cards/GiftCardRecipient.js} +0 -0
- package/lib/cjs/components/{GiftCardRecipientInput.d.ts → gift_cards/GiftCardRecipientInput.d.ts} +0 -0
- package/lib/cjs/components/{GiftCardRecipientInput.js → gift_cards/GiftCardRecipientInput.js} +0 -0
- package/lib/{esm/components → cjs/components/line_items}/LineItem.d.ts +2 -2
- package/lib/cjs/components/line_items/LineItem.js +1 -0
- package/lib/{esm/components → cjs/components/line_items}/LineItemAmount.d.ts +2 -2
- package/lib/cjs/components/line_items/LineItemAmount.js +1 -0
- package/lib/cjs/components/{LineItemCode.d.ts → line_items/LineItemCode.d.ts} +2 -2
- package/lib/cjs/components/line_items/LineItemCode.js +1 -0
- package/lib/cjs/components/{LineItemImage.d.ts → line_items/LineItemImage.d.ts} +3 -3
- package/lib/cjs/components/line_items/LineItemImage.js +1 -0
- package/lib/cjs/components/{LineItemName.d.ts → line_items/LineItemName.d.ts} +2 -2
- package/lib/cjs/components/line_items/LineItemName.js +1 -0
- package/lib/cjs/components/{LineItemOption.d.ts → line_items/LineItemOption.d.ts} +1 -1
- package/lib/cjs/components/line_items/LineItemOption.js +1 -0
- package/lib/cjs/components/{LineItemOptions.d.ts → line_items/LineItemOptions.d.ts} +0 -0
- package/lib/cjs/components/line_items/LineItemOptions.js +1 -0
- package/lib/{esm/components → cjs/components/line_items}/LineItemQuantity.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemQuantity.js +1 -0
- package/lib/cjs/components/{LineItemRemoveLink.d.ts → line_items/LineItemRemoveLink.d.ts} +1 -1
- package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -0
- package/lib/{esm/components → cjs/components/line_items}/LineItemsContainer.d.ts +2 -2
- package/lib/cjs/components/line_items/LineItemsContainer.js +1 -0
- package/lib/{esm/components → cjs/components/line_items}/LineItemsCount.d.ts +2 -2
- package/lib/cjs/components/line_items/LineItemsCount.js +1 -0
- package/lib/cjs/components/{LineItemsEmpty.d.ts → line_items/LineItemsEmpty.d.ts} +1 -1
- package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -0
- package/lib/cjs/components/orders/AddToCartButton.d.ts +3 -3
- package/lib/cjs/components/orders/AddToCartButton.js +1 -1
- package/lib/cjs/components/orders/AdjustmentAmount.d.ts +2 -16
- package/lib/cjs/components/orders/AdjustmentAmount.js +1 -1
- package/lib/cjs/components/orders/CartLink.js +1 -1
- package/lib/cjs/components/{CheckoutLink.d.ts → orders/CheckoutLink.d.ts} +1 -11
- package/lib/cjs/components/orders/CheckoutLink.js +1 -0
- package/lib/cjs/components/{DiscountAmount.d.ts → orders/DiscountAmount.d.ts} +3 -3
- package/lib/cjs/components/orders/DiscountAmount.js +1 -0
- package/lib/{esm/components → cjs/components/orders}/ItemContainer.d.ts +1 -1
- package/lib/cjs/components/orders/ItemContainer.js +1 -0
- package/lib/cjs/components/orders/OrderContainer.d.ts +1 -1
- package/lib/cjs/components/orders/OrderList.d.ts +1 -1
- package/lib/cjs/components/orders/OrderListRow.d.ts +2 -2
- package/lib/cjs/components/orders/OrderStorage.d.ts +1 -1
- package/lib/cjs/components/orders/PlaceOrderButton.d.ts +1 -1
- package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
- package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +1 -1
- package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -1
- package/lib/{esm/components → cjs/components/orders}/ShippingAmount.d.ts +2 -2
- package/lib/cjs/components/orders/ShippingAmount.js +1 -0
- package/lib/cjs/components/{gateways → payment_gateways}/AdyenGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -0
- package/lib/{esm/components/gateways → cjs/components/payment_gateways}/BraintreeGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -0
- package/lib/cjs/components/{gateways → payment_gateways}/CheckoutComGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.js +1 -0
- package/lib/{esm/components/gateways → cjs/components/payment_gateways}/KlarnaGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -0
- package/lib/cjs/components/{PaymentGateway.d.ts → payment_gateways/PaymentGateway.d.ts} +2 -2
- package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -0
- package/lib/cjs/components/{gateways → payment_gateways}/PaypalGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -0
- package/lib/cjs/components/{gateways → payment_gateways}/StripeGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/StripeGateway.js +1 -0
- package/lib/cjs/components/{gateways → payment_gateways}/WireTransferGateway.d.ts +1 -1
- package/lib/cjs/components/payment_gateways/WireTransferGateway.js +1 -0
- package/lib/cjs/components/{PaymentMethod.d.ts → payment_methods/PaymentMethod.d.ts} +8 -3
- package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -0
- package/lib/cjs/components/{PaymentMethodAmount.d.ts → payment_methods/PaymentMethodAmount.d.ts} +3 -3
- package/lib/cjs/components/payment_methods/PaymentMethodAmount.js +1 -0
- package/lib/{esm/components → cjs/components/payment_methods}/PaymentMethodName.d.ts +2 -2
- package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -0
- package/lib/cjs/components/{PaymentMethodPrice.d.ts → payment_methods/PaymentMethodPrice.d.ts} +2 -2
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -0
- package/lib/cjs/components/{PaymentMethodRadioButton.d.ts → payment_methods/PaymentMethodRadioButton.d.ts} +2 -2
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -0
- package/lib/{esm/components → cjs/components/payment_methods}/PaymentMethodsContainer.d.ts +2 -2
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -0
- package/lib/cjs/components/payment_source/AdyenPayment.d.ts +55 -0
- package/lib/cjs/components/payment_source/AdyenPayment.js +1 -0
- package/lib/cjs/components/{BraintreePayment.d.ts → payment_source/BraintreePayment.d.ts} +0 -0
- package/lib/cjs/components/payment_source/BraintreePayment.js +1 -0
- package/lib/{esm/components → cjs/components/payment_source}/CheckoutComPayment.d.ts +1 -1
- package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -0
- package/lib/cjs/components/{KlarnaPayment.d.ts → payment_source/KlarnaPayment.d.ts} +1 -1
- package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -0
- package/lib/cjs/components/{PaymentSource.d.ts → payment_source/PaymentSource.d.ts} +4 -4
- package/lib/cjs/components/payment_source/PaymentSource.js +1 -0
- package/lib/{esm/components → cjs/components/payment_source}/PaymentSourceBrandIcon.d.ts +2 -2
- package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -0
- package/lib/{esm/components → cjs/components/payment_source}/PaymentSourceBrandName.d.ts +2 -2
- package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -0
- package/lib/{esm/components → cjs/components/payment_source}/PaymentSourceDetail.d.ts +2 -2
- package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -0
- package/lib/cjs/components/{PaymentSourceEditButton.d.ts → payment_source/PaymentSourceEditButton.d.ts} +2 -2
- package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -0
- package/lib/cjs/components/{PaypalPayment.d.ts → payment_source/PaypalPayment.d.ts} +0 -0
- package/lib/cjs/components/payment_source/PaypalPayment.js +1 -0
- package/lib/cjs/components/{StripePayment.d.ts → payment_source/StripePayment.d.ts} +1 -1
- package/lib/cjs/components/payment_source/StripePayment.js +1 -0
- package/lib/cjs/components/{WireTransferPayment.d.ts → payment_source/WireTransferPayment.d.ts} +3 -1
- package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -0
- package/lib/cjs/components/{Price.d.ts → prices/Price.d.ts} +1 -1
- package/lib/cjs/components/prices/Price.js +1 -0
- package/lib/{esm/components → cjs/components/prices}/PricesContainer.d.ts +3 -3
- package/lib/cjs/components/prices/PricesContainer.js +1 -0
- package/lib/cjs/components/shipments/Shipment.d.ts +1 -1
- package/lib/cjs/components/shipments/ShipmentField.d.ts +3 -3
- package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethod.d.ts +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +2 -2
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +2 -2
- package/lib/cjs/components/{AvailabilityContainer.d.ts → skus/AvailabilityContainer.d.ts} +1 -1
- package/lib/cjs/components/skus/AvailabilityContainer.js +1 -0
- package/lib/{esm/components → cjs/components/skus}/AvailabilityTemplate.d.ts +2 -2
- package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -0
- package/lib/{esm/components → cjs/components/skus}/DeliveryLeadTime.d.ts +3 -3
- package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -0
- package/lib/cjs/components/{QuantitySelector.d.ts → skus/QuantitySelector.d.ts} +1 -1
- package/lib/cjs/components/skus/QuantitySelector.js +1 -0
- package/lib/cjs/components/skus/SkuList.d.ts +1 -1
- package/lib/cjs/components/skus/SkuListsContainer.d.ts +1 -1
- package/lib/cjs/components/skus/SkuOption.d.ts +1 -1
- package/lib/cjs/components/skus/SkuOptionInput.d.ts +1 -1
- package/lib/cjs/components/skus/SkuOptionsContainer.d.ts +1 -1
- package/lib/cjs/components/skus/Skus.d.ts +1 -1
- package/lib/cjs/components/skus/SkusContainer.d.ts +0 -5
- package/lib/cjs/components/skus/SkusContainer.js +1 -1
- package/lib/cjs/components/{VariantSelector.d.ts → skus/VariantSelector.d.ts} +6 -6
- package/lib/cjs/components/skus/VariantSelector.js +1 -0
- package/lib/cjs/components/{VariantsContainer.d.ts → skus/VariantsContainer.d.ts} +1 -1
- package/lib/cjs/components/skus/VariantsContainer.js +1 -0
- package/lib/{esm/components → cjs/components/stock_transfers}/StockTransfer.d.ts +1 -1
- package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -0
- package/lib/{esm/components → cjs/components/stock_transfers}/StockTransferField.d.ts +2 -2
- package/lib/cjs/components/stock_transfers/StockTransferField.js +1 -0
- package/lib/cjs/components/utils/BaseField.d.ts +2 -2
- package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
- package/lib/cjs/components/utils/Parent.d.ts +5 -5
- package/lib/cjs/components/utils/Parent.js +1 -1
- package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -1
- package/lib/cjs/components/utils/VariantTemplate.d.ts +3 -3
- package/lib/cjs/components/utils/VariantTemplate.js +1 -1
- package/lib/cjs/components/utils/getAllErrors.d.ts +2 -2
- package/lib/cjs/config/components.d.ts +66 -66
- package/lib/cjs/context/OrderListChildrenContext.d.ts +3 -3
- package/lib/cjs/context/PlaceOrderContext.d.ts +2 -1
- package/lib/cjs/index.d.ts +55 -55
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/reducers/AddressReducer.d.ts +1 -0
- package/lib/cjs/reducers/PaymentMethodReducer.d.ts +7 -6
- package/lib/cjs/reducers/PlaceOrderReducer.d.ts +7 -4
- package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
- package/lib/cjs/reducers/VariantReducer.d.ts +1 -1
- package/lib/cjs/typings/errors.d.ts +2 -2
- package/lib/cjs/typings/index.d.ts +10 -10
- package/lib/cjs/utils/childrenTypes.d.ts +1 -1
- package/lib/cjs/utils/getCardDetails.js +1 -1
- package/lib/cjs/utils/getLoaderComponent.js +1 -1
- package/lib/cjs/utils/paypalPayment.d.ts +1 -1
- package/lib/esm/components/Errors.js +1 -1
- package/lib/esm/components/ExternalFunction.d.ts +1 -1
- package/lib/esm/components/MetadataInput.d.ts +1 -1
- package/lib/esm/components/SubmitButton.d.ts +1 -1
- package/lib/esm/components/addresses/Address.d.ts +1 -1
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +2 -2
- package/lib/esm/components/addresses/AddressField.d.ts +4 -4
- package/lib/esm/components/addresses/AddressField.js +1 -1
- package/lib/esm/components/addresses/AddressInput.d.ts +2 -2
- package/lib/esm/components/addresses/AddressStateSelector.d.ts +2 -2
- package/lib/esm/components/addresses/AddressesContainer.d.ts +1 -1
- package/lib/esm/components/addresses/BillingAddressContainer.d.ts +6 -0
- package/lib/esm/components/addresses/BillingAddressContainer.js +1 -0
- package/lib/{cjs/components → esm/components/addresses}/BillingAddressForm.d.ts +1 -1
- package/lib/esm/components/addresses/BillingAddressForm.js +1 -0
- package/lib/esm/components/addresses/SaveAddressesButton.d.ts +11 -0
- package/lib/esm/components/addresses/SaveAddressesButton.js +1 -0
- package/lib/{cjs/components → esm/components/addresses}/ShippingAddressContainer.d.ts +1 -1
- package/lib/esm/components/addresses/ShippingAddressContainer.js +1 -0
- package/lib/esm/components/{ShippingAddressForm.d.ts → addresses/ShippingAddressForm.d.ts} +1 -1
- package/lib/esm/components/addresses/ShippingAddressForm.js +1 -0
- package/lib/esm/components/auth/CommerceLayer.d.ts +1 -1
- package/lib/esm/components/customers/CustomerAddressForm.d.ts +1 -1
- package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
- package/lib/esm/components/customers/SaveCustomerButton.d.ts +13 -0
- package/lib/esm/components/customers/SaveCustomerButton.js +1 -0
- package/lib/esm/components/{GiftCard.d.ts → gift_cards/GiftCard.d.ts} +2 -2
- package/lib/esm/components/gift_cards/GiftCard.js +1 -0
- package/lib/{cjs/components → esm/components/gift_cards}/GiftCardContainer.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -0
- package/lib/esm/components/{GiftCardCurrencySelector.d.ts → gift_cards/GiftCardCurrencySelector.d.ts} +2 -2
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.js +1 -0
- package/lib/{cjs/components → esm/components/gift_cards}/GiftCardInput.d.ts +3 -3
- package/lib/esm/components/gift_cards/GiftCardInput.js +1 -0
- package/lib/esm/components/{GiftCardOrCouponCode.d.ts → gift_cards/GiftCardOrCouponCode.d.ts} +2 -2
- package/lib/esm/components/gift_cards/GiftCardOrCouponCode.js +1 -0
- package/lib/{cjs/components → esm/components/gift_cards}/GiftCardOrCouponForm.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.js +1 -0
- package/lib/esm/components/{GiftCardOrCouponInput.d.ts → gift_cards/GiftCardOrCouponInput.d.ts} +2 -2
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.js +1 -0
- package/lib/esm/components/{GiftCardOrCouponRemoveButton.d.ts → gift_cards/GiftCardOrCouponRemoveButton.d.ts} +3 -3
- package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
- package/lib/esm/components/{GiftCardOrCouponSubmit.d.ts → gift_cards/GiftCardOrCouponSubmit.d.ts} +2 -2
- package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
- package/lib/esm/components/{GiftCardRecipient.d.ts → gift_cards/GiftCardRecipient.d.ts} +0 -0
- package/lib/esm/components/{GiftCardRecipient.js → gift_cards/GiftCardRecipient.js} +0 -0
- package/lib/esm/components/{GiftCardRecipientInput.d.ts → gift_cards/GiftCardRecipientInput.d.ts} +0 -0
- package/lib/esm/components/{GiftCardRecipientInput.js → gift_cards/GiftCardRecipientInput.js} +0 -0
- package/lib/{cjs/components → esm/components/line_items}/LineItem.d.ts +2 -2
- package/lib/esm/components/line_items/LineItem.js +1 -0
- package/lib/{cjs/components → esm/components/line_items}/LineItemAmount.d.ts +2 -2
- package/lib/esm/components/line_items/LineItemAmount.js +1 -0
- package/lib/esm/components/{LineItemCode.d.ts → line_items/LineItemCode.d.ts} +2 -2
- package/lib/esm/components/line_items/LineItemCode.js +1 -0
- package/lib/esm/components/{LineItemImage.d.ts → line_items/LineItemImage.d.ts} +3 -3
- package/lib/esm/components/line_items/LineItemImage.js +1 -0
- package/lib/esm/components/{LineItemName.d.ts → line_items/LineItemName.d.ts} +2 -2
- package/lib/esm/components/line_items/LineItemName.js +1 -0
- package/lib/esm/components/{LineItemOption.d.ts → line_items/LineItemOption.d.ts} +1 -1
- package/lib/esm/components/line_items/LineItemOption.js +1 -0
- package/lib/esm/components/{LineItemOptions.d.ts → line_items/LineItemOptions.d.ts} +0 -0
- package/lib/esm/components/line_items/LineItemOptions.js +1 -0
- package/lib/{cjs/components → esm/components/line_items}/LineItemQuantity.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemQuantity.js +1 -0
- package/lib/esm/components/{LineItemRemoveLink.d.ts → line_items/LineItemRemoveLink.d.ts} +1 -1
- package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -0
- package/lib/{cjs/components → esm/components/line_items}/LineItemsContainer.d.ts +2 -2
- package/lib/esm/components/line_items/LineItemsContainer.js +1 -0
- package/lib/{cjs/components → esm/components/line_items}/LineItemsCount.d.ts +2 -2
- package/lib/esm/components/line_items/LineItemsCount.js +1 -0
- package/lib/esm/components/{LineItemsEmpty.d.ts → line_items/LineItemsEmpty.d.ts} +1 -1
- package/lib/esm/components/line_items/LineItemsEmpty.js +1 -0
- package/lib/esm/components/orders/AddToCartButton.d.ts +3 -3
- package/lib/esm/components/orders/AddToCartButton.js +1 -1
- package/lib/esm/components/orders/AdjustmentAmount.d.ts +2 -16
- package/lib/esm/components/orders/AdjustmentAmount.js +1 -1
- package/lib/esm/components/orders/CartLink.js +1 -1
- package/lib/esm/components/{CheckoutLink.d.ts → orders/CheckoutLink.d.ts} +1 -11
- package/lib/esm/components/orders/CheckoutLink.js +1 -0
- package/lib/esm/components/{DiscountAmount.d.ts → orders/DiscountAmount.d.ts} +3 -3
- package/lib/esm/components/orders/DiscountAmount.js +1 -0
- package/lib/{cjs/components → esm/components/orders}/ItemContainer.d.ts +1 -1
- package/lib/esm/components/orders/ItemContainer.js +1 -0
- package/lib/esm/components/orders/OrderContainer.d.ts +1 -1
- package/lib/esm/components/orders/OrderList.d.ts +1 -1
- package/lib/esm/components/orders/OrderListRow.d.ts +2 -2
- package/lib/esm/components/orders/OrderStorage.d.ts +1 -1
- package/lib/esm/components/orders/PlaceOrderButton.d.ts +1 -1
- package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
- package/lib/esm/components/orders/PlaceOrderContainer.d.ts +1 -1
- package/lib/esm/components/orders/PlaceOrderContainer.js +1 -1
- package/lib/{cjs/components → esm/components/orders}/ShippingAmount.d.ts +2 -2
- package/lib/esm/components/orders/ShippingAmount.js +1 -0
- package/lib/esm/components/{gateways → payment_gateways}/AdyenGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -0
- package/lib/{cjs/components/gateways → esm/components/payment_gateways}/BraintreeGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/BraintreeGateway.js +1 -0
- package/lib/esm/components/{gateways → payment_gateways}/CheckoutComGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/CheckoutComGateway.js +1 -0
- package/lib/{cjs/components/gateways → esm/components/payment_gateways}/KlarnaGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/KlarnaGateway.js +1 -0
- package/lib/esm/components/{PaymentGateway.d.ts → payment_gateways/PaymentGateway.d.ts} +2 -2
- package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -0
- package/lib/esm/components/{gateways → payment_gateways}/PaypalGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/PaypalGateway.js +1 -0
- package/lib/esm/components/{gateways → payment_gateways}/StripeGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/StripeGateway.js +1 -0
- package/lib/esm/components/{gateways → payment_gateways}/WireTransferGateway.d.ts +1 -1
- package/lib/esm/components/payment_gateways/WireTransferGateway.js +1 -0
- package/lib/esm/components/{PaymentMethod.d.ts → payment_methods/PaymentMethod.d.ts} +8 -3
- package/lib/esm/components/payment_methods/PaymentMethod.js +1 -0
- package/lib/esm/components/{PaymentMethodAmount.d.ts → payment_methods/PaymentMethodAmount.d.ts} +3 -3
- package/lib/esm/components/payment_methods/PaymentMethodAmount.js +1 -0
- package/lib/{cjs/components → esm/components/payment_methods}/PaymentMethodName.d.ts +2 -2
- package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -0
- package/lib/esm/components/{PaymentMethodPrice.d.ts → payment_methods/PaymentMethodPrice.d.ts} +2 -2
- package/lib/esm/components/payment_methods/PaymentMethodPrice.js +1 -0
- package/lib/esm/components/{PaymentMethodRadioButton.d.ts → payment_methods/PaymentMethodRadioButton.d.ts} +2 -2
- package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -0
- package/lib/{cjs/components → esm/components/payment_methods}/PaymentMethodsContainer.d.ts +2 -2
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -0
- package/lib/esm/components/payment_source/AdyenPayment.d.ts +55 -0
- package/lib/esm/components/payment_source/AdyenPayment.js +1 -0
- package/lib/esm/components/{BraintreePayment.d.ts → payment_source/BraintreePayment.d.ts} +0 -0
- package/lib/esm/components/payment_source/BraintreePayment.js +1 -0
- package/lib/{cjs/components → esm/components/payment_source}/CheckoutComPayment.d.ts +1 -1
- package/lib/esm/components/payment_source/CheckoutComPayment.js +1 -0
- package/lib/esm/components/{KlarnaPayment.d.ts → payment_source/KlarnaPayment.d.ts} +1 -1
- package/lib/esm/components/payment_source/KlarnaPayment.js +1 -0
- package/lib/esm/components/{PaymentSource.d.ts → payment_source/PaymentSource.d.ts} +4 -4
- package/lib/esm/components/payment_source/PaymentSource.js +1 -0
- package/lib/{cjs/components → esm/components/payment_source}/PaymentSourceBrandIcon.d.ts +2 -2
- package/lib/esm/components/payment_source/PaymentSourceBrandIcon.js +1 -0
- package/lib/{cjs/components → esm/components/payment_source}/PaymentSourceBrandName.d.ts +2 -2
- package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -0
- package/lib/{cjs/components → esm/components/payment_source}/PaymentSourceDetail.d.ts +2 -2
- package/lib/esm/components/payment_source/PaymentSourceDetail.js +1 -0
- package/lib/esm/components/{PaymentSourceEditButton.d.ts → payment_source/PaymentSourceEditButton.d.ts} +2 -2
- package/lib/esm/components/payment_source/PaymentSourceEditButton.js +1 -0
- package/lib/esm/components/{PaypalPayment.d.ts → payment_source/PaypalPayment.d.ts} +0 -0
- package/lib/esm/components/payment_source/PaypalPayment.js +1 -0
- package/lib/esm/components/{StripePayment.d.ts → payment_source/StripePayment.d.ts} +1 -1
- package/lib/esm/components/payment_source/StripePayment.js +1 -0
- package/lib/esm/components/{WireTransferPayment.d.ts → payment_source/WireTransferPayment.d.ts} +3 -1
- package/lib/esm/components/payment_source/WireTransferPayment.js +1 -0
- package/lib/esm/components/{Price.d.ts → prices/Price.d.ts} +1 -1
- package/lib/esm/components/prices/Price.js +1 -0
- package/lib/{cjs/components → esm/components/prices}/PricesContainer.d.ts +3 -3
- package/lib/esm/components/prices/PricesContainer.js +1 -0
- package/lib/esm/components/shipments/Shipment.d.ts +1 -1
- package/lib/esm/components/shipments/ShipmentField.d.ts +3 -3
- package/lib/esm/components/shipments/ShipmentsContainer.d.ts +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethod.d.ts +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +2 -2
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +2 -2
- package/lib/esm/components/{AvailabilityContainer.d.ts → skus/AvailabilityContainer.d.ts} +1 -1
- package/lib/esm/components/skus/AvailabilityContainer.js +1 -0
- package/lib/{cjs/components → esm/components/skus}/AvailabilityTemplate.d.ts +2 -2
- package/lib/esm/components/skus/AvailabilityTemplate.js +1 -0
- package/lib/{cjs/components → esm/components/skus}/DeliveryLeadTime.d.ts +3 -3
- package/lib/esm/components/skus/DeliveryLeadTime.js +1 -0
- package/lib/esm/components/{QuantitySelector.d.ts → skus/QuantitySelector.d.ts} +1 -1
- package/lib/esm/components/skus/QuantitySelector.js +1 -0
- package/lib/esm/components/skus/SkuList.d.ts +1 -1
- package/lib/esm/components/skus/SkuListsContainer.d.ts +1 -1
- package/lib/esm/components/skus/SkuOption.d.ts +1 -1
- package/lib/esm/components/skus/SkuOptionInput.d.ts +1 -1
- package/lib/esm/components/skus/SkuOptionsContainer.d.ts +1 -1
- package/lib/esm/components/skus/Skus.d.ts +1 -1
- package/lib/esm/components/skus/SkusContainer.d.ts +0 -5
- package/lib/esm/components/skus/SkusContainer.js +1 -1
- package/lib/esm/components/{VariantSelector.d.ts → skus/VariantSelector.d.ts} +6 -6
- package/lib/esm/components/skus/VariantSelector.js +1 -0
- package/lib/esm/components/{VariantsContainer.d.ts → skus/VariantsContainer.d.ts} +1 -1
- package/lib/esm/components/skus/VariantsContainer.js +1 -0
- package/lib/{cjs/components → esm/components/stock_transfers}/StockTransfer.d.ts +1 -1
- package/lib/esm/components/stock_transfers/StockTransfer.js +1 -0
- package/lib/{cjs/components → esm/components/stock_transfers}/StockTransferField.d.ts +2 -2
- package/lib/esm/components/stock_transfers/StockTransferField.js +1 -0
- package/lib/esm/components/utils/BaseField.d.ts +2 -2
- package/lib/esm/components/utils/BaseOrderPrice.js +1 -1
- package/lib/esm/components/utils/Parent.d.ts +5 -5
- package/lib/esm/components/utils/Parent.js +1 -1
- package/lib/esm/components/utils/PriceTemplate.d.ts +1 -1
- package/lib/esm/components/utils/VariantTemplate.d.ts +3 -3
- package/lib/esm/components/utils/VariantTemplate.js +1 -1
- package/lib/esm/components/utils/getAllErrors.d.ts +2 -2
- package/lib/esm/config/components.d.ts +66 -66
- package/lib/esm/context/OrderListChildrenContext.d.ts +3 -3
- package/lib/esm/context/PlaceOrderContext.d.ts +2 -1
- package/lib/esm/index.d.ts +55 -55
- package/lib/esm/index.js +1 -1
- package/lib/esm/reducers/AddressReducer.d.ts +1 -0
- package/lib/esm/reducers/PaymentMethodReducer.d.ts +7 -6
- package/lib/esm/reducers/PlaceOrderReducer.d.ts +7 -4
- package/lib/esm/reducers/PlaceOrderReducer.js +1 -1
- package/lib/esm/reducers/VariantReducer.d.ts +1 -1
- package/lib/esm/typings/errors.d.ts +2 -2
- package/lib/esm/typings/index.d.ts +10 -10
- package/lib/esm/utils/childrenTypes.d.ts +1 -1
- package/lib/esm/utils/getCardDetails.js +1 -1
- package/lib/esm/utils/getLoaderComponent.js +1 -1
- package/lib/esm/utils/paypalPayment.d.ts +1 -1
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +76 -20
- package/lib/cjs/components/AdjustmentAmount.d.ts +0 -4
- package/lib/cjs/components/AdjustmentAmount.js +0 -1
- package/lib/cjs/components/AdyenPayment.d.ts +0 -25
- package/lib/cjs/components/AdyenPayment.js +0 -1
- package/lib/cjs/components/AvailabilityContainer.js +0 -1
- package/lib/cjs/components/AvailabilityTemplate.js +0 -1
- package/lib/cjs/components/BillingAddressContainer.d.ts +0 -11
- package/lib/cjs/components/BillingAddressContainer.js +0 -1
- package/lib/cjs/components/BillingAddressForm.js +0 -1
- package/lib/cjs/components/BraintreePayment.js +0 -1
- package/lib/cjs/components/CartLink.d.ts +0 -12
- package/lib/cjs/components/CartLink.js +0 -1
- package/lib/cjs/components/CheckoutComPayment.js +0 -1
- package/lib/cjs/components/CheckoutLink.js +0 -1
- package/lib/cjs/components/DeliveryLeadTime.js +0 -1
- package/lib/cjs/components/DiscountAmount.js +0 -1
- package/lib/cjs/components/GiftCard.js +0 -1
- package/lib/cjs/components/GiftCardContainer.js +0 -1
- package/lib/cjs/components/GiftCardCurrencySelector.js +0 -1
- package/lib/cjs/components/GiftCardInput.js +0 -1
- package/lib/cjs/components/GiftCardOrCouponCode.js +0 -1
- package/lib/cjs/components/GiftCardOrCouponForm.js +0 -1
- package/lib/cjs/components/GiftCardOrCouponInput.js +0 -1
- package/lib/cjs/components/GiftCardOrCouponRemoveButton.js +0 -1
- package/lib/cjs/components/GiftCardOrCouponSubmit.js +0 -1
- package/lib/cjs/components/ItemContainer.js +0 -1
- package/lib/cjs/components/KlarnaPayment.js +0 -1
- package/lib/cjs/components/LineItem.js +0 -1
- package/lib/cjs/components/LineItemAmount.js +0 -1
- package/lib/cjs/components/LineItemCode.js +0 -1
- package/lib/cjs/components/LineItemImage.js +0 -1
- package/lib/cjs/components/LineItemName.js +0 -1
- package/lib/cjs/components/LineItemOption.js +0 -1
- package/lib/cjs/components/LineItemOptions.js +0 -1
- package/lib/cjs/components/LineItemQuantity.js +0 -1
- package/lib/cjs/components/LineItemRemoveLink.js +0 -1
- package/lib/cjs/components/LineItemsContainer.js +0 -1
- package/lib/cjs/components/LineItemsCount.js +0 -1
- package/lib/cjs/components/LineItemsEmpty.js +0 -1
- package/lib/cjs/components/PaymentGateway.js +0 -1
- package/lib/cjs/components/PaymentMethod.js +0 -1
- package/lib/cjs/components/PaymentMethodAmount.js +0 -1
- package/lib/cjs/components/PaymentMethodName.js +0 -1
- package/lib/cjs/components/PaymentMethodPrice.js +0 -1
- package/lib/cjs/components/PaymentMethodRadioButton.js +0 -1
- package/lib/cjs/components/PaymentMethodsContainer.js +0 -1
- package/lib/cjs/components/PaymentSource.js +0 -1
- package/lib/cjs/components/PaymentSourceBrandIcon.js +0 -1
- package/lib/cjs/components/PaymentSourceBrandName.js +0 -1
- package/lib/cjs/components/PaymentSourceDetail.js +0 -1
- package/lib/cjs/components/PaymentSourceEditButton.js +0 -1
- package/lib/cjs/components/PaypalPayment.js +0 -1
- package/lib/cjs/components/Price.js +0 -1
- package/lib/cjs/components/PricesContainer.js +0 -1
- package/lib/cjs/components/QuantitySelector.js +0 -1
- package/lib/cjs/components/SaveAddressesButton.d.ts +0 -23
- package/lib/cjs/components/SaveAddressesButton.js +0 -1
- package/lib/cjs/components/SaveCustomerButton.d.ts +0 -24
- package/lib/cjs/components/ShippingAddressContainer.js +0 -1
- package/lib/cjs/components/ShippingAddressForm.js +0 -1
- package/lib/cjs/components/ShippingAmount.js +0 -1
- package/lib/cjs/components/SkuField.d.ts +0 -10
- package/lib/cjs/components/SkuField.js +0 -1
- package/lib/cjs/components/Skus.d.ts +0 -11
- package/lib/cjs/components/Skus.js +0 -1
- package/lib/cjs/components/SkusContainer.d.ts +0 -14
- package/lib/cjs/components/SkusContainer.js +0 -1
- package/lib/cjs/components/StockTransfer.js +0 -1
- package/lib/cjs/components/StockTransferField.js +0 -1
- package/lib/cjs/components/StripePayment.js +0 -1
- package/lib/cjs/components/VariantSelector.js +0 -1
- package/lib/cjs/components/VariantsContainer.js +0 -1
- package/lib/cjs/components/WireTransferPayment.js +0 -1
- package/lib/cjs/components/gateways/AdyenGateway.js +0 -1
- package/lib/cjs/components/gateways/BraintreeGateway.js +0 -1
- package/lib/cjs/components/gateways/CheckoutComGateway.js +0 -1
- package/lib/cjs/components/gateways/KlarnaGateway.js +0 -1
- package/lib/cjs/components/gateways/PaypalGateway.js +0 -1
- package/lib/cjs/components/gateways/StripeGateway.js +0 -1
- package/lib/cjs/components/gateways/WireTransferGateway.js +0 -1
- package/lib/esm/components/AdjustmentAmount.d.ts +0 -4
- package/lib/esm/components/AdjustmentAmount.js +0 -1
- package/lib/esm/components/AdyenPayment.d.ts +0 -25
- package/lib/esm/components/AdyenPayment.js +0 -1
- package/lib/esm/components/AvailabilityContainer.js +0 -1
- package/lib/esm/components/AvailabilityTemplate.js +0 -1
- package/lib/esm/components/BillingAddressContainer.d.ts +0 -11
- package/lib/esm/components/BillingAddressContainer.js +0 -1
- package/lib/esm/components/BillingAddressForm.js +0 -1
- package/lib/esm/components/BraintreePayment.js +0 -1
- package/lib/esm/components/CartLink.d.ts +0 -12
- package/lib/esm/components/CartLink.js +0 -1
- package/lib/esm/components/CheckoutComPayment.js +0 -1
- package/lib/esm/components/CheckoutLink.js +0 -1
- package/lib/esm/components/DeliveryLeadTime.js +0 -1
- package/lib/esm/components/DiscountAmount.js +0 -1
- package/lib/esm/components/GiftCard.js +0 -1
- package/lib/esm/components/GiftCardContainer.js +0 -1
- package/lib/esm/components/GiftCardCurrencySelector.js +0 -1
- package/lib/esm/components/GiftCardInput.js +0 -1
- package/lib/esm/components/GiftCardOrCouponCode.js +0 -1
- package/lib/esm/components/GiftCardOrCouponForm.js +0 -1
- package/lib/esm/components/GiftCardOrCouponInput.js +0 -1
- package/lib/esm/components/GiftCardOrCouponRemoveButton.js +0 -1
- package/lib/esm/components/GiftCardOrCouponSubmit.js +0 -1
- package/lib/esm/components/ItemContainer.js +0 -1
- package/lib/esm/components/KlarnaPayment.js +0 -1
- package/lib/esm/components/LineItem.js +0 -1
- package/lib/esm/components/LineItemAmount.js +0 -1
- package/lib/esm/components/LineItemCode.js +0 -1
- package/lib/esm/components/LineItemImage.js +0 -1
- package/lib/esm/components/LineItemName.js +0 -1
- package/lib/esm/components/LineItemOption.js +0 -1
- package/lib/esm/components/LineItemOptions.js +0 -1
- package/lib/esm/components/LineItemQuantity.js +0 -1
- package/lib/esm/components/LineItemRemoveLink.js +0 -1
- package/lib/esm/components/LineItemsContainer.js +0 -1
- package/lib/esm/components/LineItemsCount.js +0 -1
- package/lib/esm/components/LineItemsEmpty.js +0 -1
- package/lib/esm/components/PaymentGateway.js +0 -1
- package/lib/esm/components/PaymentMethod.js +0 -1
- package/lib/esm/components/PaymentMethodAmount.js +0 -1
- package/lib/esm/components/PaymentMethodName.js +0 -1
- package/lib/esm/components/PaymentMethodPrice.js +0 -1
- package/lib/esm/components/PaymentMethodRadioButton.js +0 -1
- package/lib/esm/components/PaymentMethodsContainer.js +0 -1
- package/lib/esm/components/PaymentSource.js +0 -1
- package/lib/esm/components/PaymentSourceBrandIcon.js +0 -1
- package/lib/esm/components/PaymentSourceBrandName.js +0 -1
- package/lib/esm/components/PaymentSourceDetail.js +0 -1
- package/lib/esm/components/PaymentSourceEditButton.js +0 -1
- package/lib/esm/components/PaypalPayment.js +0 -1
- package/lib/esm/components/Price.js +0 -1
- package/lib/esm/components/PricesContainer.js +0 -1
- package/lib/esm/components/QuantitySelector.js +0 -1
- package/lib/esm/components/SaveAddressesButton.d.ts +0 -23
- package/lib/esm/components/SaveAddressesButton.js +0 -1
- package/lib/esm/components/SaveCustomerButton.d.ts +0 -24
- package/lib/esm/components/SaveCustomerButton.js +0 -1
- package/lib/esm/components/ShippingAddressContainer.js +0 -1
- package/lib/esm/components/ShippingAddressForm.js +0 -1
- package/lib/esm/components/ShippingAmount.js +0 -1
- package/lib/esm/components/SkuField.d.ts +0 -10
- package/lib/esm/components/SkuField.js +0 -1
- package/lib/esm/components/Skus.d.ts +0 -11
- package/lib/esm/components/Skus.js +0 -1
- package/lib/esm/components/SkusContainer.d.ts +0 -14
- package/lib/esm/components/SkusContainer.js +0 -1
- package/lib/esm/components/StockTransfer.js +0 -1
- package/lib/esm/components/StockTransferField.js +0 -1
- package/lib/esm/components/StripePayment.js +0 -1
- package/lib/esm/components/VariantSelector.js +0 -1
- package/lib/esm/components/VariantsContainer.js +0 -1
- package/lib/esm/components/WireTransferPayment.js +0 -1
- package/lib/esm/components/gateways/AdyenGateway.js +0 -1
- package/lib/esm/components/gateways/BraintreeGateway.js +0 -1
- package/lib/esm/components/gateways/CheckoutComGateway.js +0 -1
- package/lib/esm/components/gateways/KlarnaGateway.js +0 -1
- package/lib/esm/components/gateways/PaypalGateway.js +0 -1
- package/lib/esm/components/gateways/StripeGateway.js +0 -1
- package/lib/esm/components/gateways/WireTransferGateway.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import getCartLink from"../../utils/getCartLink";export function CartLink(props){const{label,children,...p}=props,{order,createOrder}=useContext(OrderContext),{accessToken,endpoint}=useContext(CommerceLayerContext),[slug]=endpoint.split(".commercelayer"),href=slug&&order?.id?getCartLink({slug,orderId:order?.id,accessToken}):"",handleClick=async event=>{if(event.preventDefault(),order?.id)location.href=href;else{const orderId=await createOrder();slug&&(location.href=getCartLink({slug,orderId,accessToken}))}},parentProps={handleClick,label,href,...p};return accessToken?children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,onClick:handleClick,children:
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import getCartLink from"../../utils/getCartLink";export function CartLink(props){const{label,children,...p}=props,{order,createOrder}=useContext(OrderContext),{accessToken,endpoint}=useContext(CommerceLayerContext),[slug]=endpoint.split(".commercelayer"),href=slug&&order?.id?getCartLink({slug,orderId:order?.id,accessToken}):"",handleClick=async event=>{if(event.preventDefault(),order?.id)location.href=href;else{const orderId=await createOrder();slug&&(location.href=getCartLink({slug,orderId,accessToken}))}},parentProps={handleClick,label,href,...p};return accessToken?children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,onClick:handleClick,children:label}):null}export default CartLink;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FunctionChildren } from '
|
|
2
|
+
import { FunctionChildren } from '../../typings/index';
|
|
3
3
|
declare type CheckoutLinkChildrenProps = FunctionChildren<Omit<Props, 'children'> & {
|
|
4
4
|
checkoutUrl: string;
|
|
5
5
|
href: string;
|
|
@@ -10,14 +10,4 @@ declare type Props = {
|
|
|
10
10
|
hostedCheckout?: boolean;
|
|
11
11
|
} & JSX.IntrinsicElements['a'];
|
|
12
12
|
export declare function CheckoutLink(props: Props): JSX.Element;
|
|
13
|
-
export declare namespace CheckoutLink {
|
|
14
|
-
var propTypes: {
|
|
15
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
16
|
-
label: import("prop-types").Requireable<string>;
|
|
17
|
-
};
|
|
18
|
-
var defaultProps: {
|
|
19
|
-
label: string;
|
|
20
|
-
};
|
|
21
|
-
var displayName: string;
|
|
22
|
-
}
|
|
23
13
|
export default CheckoutLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";export function CheckoutLink(props){const{label,hostedCheckout=!0,children,...p}=props,{order}=useContext(OrderContext),{accessToken,endpoint}=useContext(CommerceLayerContext),[slug]=endpoint.split(".commercelayer"),href=hostedCheckout?`${slug}.checkout.commercelayer.app/${order?.id}?accessToken=${accessToken}`:order?.checkout_url,parentProps={checkoutUrl:order?.checkout_url,hostedCheckout,label,href,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,children:label})}export default CheckoutLink;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { BaseAmountComponent } from '
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
3
|
export declare function DiscountAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
4
|
export declare namespace DiscountAmount {
|
|
5
5
|
var propTypes: {
|
|
@@ -8,10 +8,10 @@ export declare namespace DiscountAmount {
|
|
|
8
8
|
style: import("prop-types").Requireable<object>;
|
|
9
9
|
name: import("prop-types").Requireable<string>;
|
|
10
10
|
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
11
|
-
format: import("prop-types").Requireable<import("
|
|
11
|
+
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
12
12
|
};
|
|
13
13
|
var defaultProps: {
|
|
14
|
-
format: import("
|
|
14
|
+
format: import("../../typings/index").BaseFormatPrice;
|
|
15
15
|
};
|
|
16
16
|
var displayName: string;
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.DiscountAmount.propTypes,defaultProps=components.DiscountAmount.defaultProps,displayName=components.DiscountAmount.displayName;export function DiscountAmount(props){return _jsx(BaseOrderPrice,{base:"amount",type:"discount",...props})}DiscountAmount.propTypes=propTypes,DiscountAmount.defaultProps=defaultProps,DiscountAmount.displayName=displayName;export default DiscountAmount;
|
|
@@ -10,7 +10,7 @@ declare type Props = {
|
|
|
10
10
|
export declare function ItemContainer(props: Props): JSX.Element;
|
|
11
11
|
export declare namespace ItemContainer {
|
|
12
12
|
var propTypes: {
|
|
13
|
-
children: import("prop-types").Validator<
|
|
13
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
14
14
|
skuCode: import("prop-types").Requireable<string>;
|
|
15
15
|
lineItem: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
16
16
|
name: import("prop-types").Validator<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useEffect}from"react";import ItemContext,{initialItemContext}from"../../context/ItemContext";import itemReducer,{itemInitialState,setItemState}from"../../reducers/ItemReducer";import components from"../../config/components";const propTypes=components.ItemContainer.propTypes,displayName=components.ItemContainer.displayName;export function ItemContainer(props){const{children,skuCode,lineItem}=props,[state,dispatch]=useReducer(itemReducer,itemInitialState);useEffect(()=>{const code=skuCode;code&&setItemState(code,{type:"setSkuCode",key:"skuCode"},dispatch),lineItem&&setItemState(lineItem,{type:"setCustomLineItem",key:"lineItem"},dispatch)},[]);const itemValue={...initialItemContext,...state,setItems:items=>setItemState(items,{type:"setItems",key:"items"},dispatch),setItem:item=>setItemState(item,{type:"setItem",key:"item"},dispatch),setQuantity:item=>setItemState(item,{type:"setQuantity",key:"quantity"},dispatch),setOption:item=>setItemState(item,{type:"setOption",key:"option"},dispatch),setPrices:item=>setItemState(item,{type:"setPrices",key:"prices"},dispatch),setCustomLineItems:item=>setItemState(item,{type:"setCustomLineItems",key:"lineItems"},dispatch),setSkuCode:code=>setItemState(code,{type:"setSkuCode",key:"skuCode"},dispatch)};return _jsx(ItemContext.Provider,{value:itemValue,children})}ItemContainer.propTypes=propTypes,ItemContainer.displayName=displayName;export default ItemContainer;
|
|
@@ -11,7 +11,7 @@ declare type Props = {
|
|
|
11
11
|
export declare function OrderContainer(props: Props): JSX.Element;
|
|
12
12
|
export declare namespace OrderContainer {
|
|
13
13
|
var propTypes: {
|
|
14
|
-
children: import("prop-types").Validator<
|
|
14
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
15
15
|
orderId: import("prop-types").Requireable<string>;
|
|
16
16
|
metadata: import("prop-types").Requireable<{
|
|
17
17
|
[x: string]: string | null | undefined;
|
|
@@ -54,7 +54,7 @@ declare type Props = {
|
|
|
54
54
|
export declare function OrderList({ children, columns, loadingElement, showActions, actionsComponent, actionsContainerClassName, infiniteScroll, windowOptions, theadClassName, rowTrClassName, ...p }: Props): JSX.Element;
|
|
55
55
|
export declare namespace OrderList {
|
|
56
56
|
var propTypes: {
|
|
57
|
-
children: import("prop-types").Validator<
|
|
57
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
58
58
|
};
|
|
59
59
|
var displayName: string;
|
|
60
60
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { Cell, Row } from 'react-table';
|
|
3
3
|
import type { Order } from '@commercelayer/sdk';
|
|
4
4
|
declare type ChildrenProps = Omit<Props, 'children'> & {
|
|
@@ -20,7 +20,7 @@ declare type ChildrenProps = Omit<Props, 'children'> & {
|
|
|
20
20
|
infiniteScroll: boolean;
|
|
21
21
|
};
|
|
22
22
|
declare type Props = {
|
|
23
|
-
children?: (props: ChildrenProps) =>
|
|
23
|
+
children?: (props: ChildrenProps) => JSX.Element;
|
|
24
24
|
/**
|
|
25
25
|
* The order field to show
|
|
26
26
|
*/
|
|
@@ -7,7 +7,7 @@ declare type Props = {
|
|
|
7
7
|
export declare function OrderStorage(props: Props): JSX.Element;
|
|
8
8
|
export declare namespace OrderStorage {
|
|
9
9
|
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<
|
|
10
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
11
|
clearWhenPlaced: import("prop-types").Requireable<boolean>;
|
|
12
12
|
persistKey: import("prop-types").Validator<string>;
|
|
13
13
|
};
|
|
@@ -14,7 +14,7 @@ export declare function PlaceOrderButton(props: Props): JSX.Element;
|
|
|
14
14
|
export declare namespace PlaceOrderButton {
|
|
15
15
|
var propTypes: {
|
|
16
16
|
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
17
|
-
label: import("prop-types").Requireable<string | import("prop-types").ReactElementLike
|
|
17
|
+
label: import("prop-types").Requireable<NonNullable<string | import("prop-types").ReactElementLike | null | undefined>>;
|
|
18
18
|
};
|
|
19
19
|
var defaultProps: {
|
|
20
20
|
label: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import Parent from"../utils/Parent";import components from"../../config/components";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";const propTypes=components.PlaceOrderButton.propTypes,defaultProps=components.PlaceOrderButton.defaultProps,displayName=components.PlaceOrderButton.displayName;export function PlaceOrderButton(props){const{children,label="Place order",disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource}=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==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.adyen,paymentType]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]);const handleClick=async()=>{let isValid=!0;setForceDisable(!0);const card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:paymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?isValid=await currentPaymentMethodRef.current?.onsubmit(paymentSource):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(paymentSource||isFree)&&await setPlaceOrder({paymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps={...p,label,disabled:disabledButton,handleClick};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{type:"button",disabled:disabledButton||forceDisable,onClick:handleClick,...p,children:isFunction(label)?label():label})}PlaceOrderButton.propTypes=propTypes,PlaceOrderButton.defaultProps=defaultProps,PlaceOrderButton.displayName=displayName;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 components from"../../config/components";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";const propTypes=components.PlaceOrderButton.propTypes,defaultProps=components.PlaceOrderButton.defaultProps,displayName=components.PlaceOrderButton.displayName;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}=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(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&order?.status&&["draft","pending"].includes(order?.status)){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult},paymentData:paymentSource.payment_response.paymentData},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode;["Authorised","Pending","Received"].includes(resultCode)&&handleClick()})}paymentType==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.adyen,paymentType]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]),useEffect(()=>{ref!=null&&ref.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref]);const handleClick=async()=>{let isValid=!0;setForceDisable(!0);const card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:paymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit(paymentSource),isValid===!1&&paymentSource.payment_response?.resultCode==="Authorised"&&(isValid=!0)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(paymentSource||isFree)&&await setPlaceOrder({paymentSource});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:handleClick,...p,children:isFunction(label)?label():label})}PlaceOrderButton.propTypes=propTypes,PlaceOrderButton.defaultProps=defaultProps,PlaceOrderButton.displayName=displayName;export default PlaceOrderButton;
|
|
@@ -7,7 +7,7 @@ declare type Props = {
|
|
|
7
7
|
export declare function PlaceOrderContainer(props: Props): JSX.Element;
|
|
8
8
|
export declare namespace PlaceOrderContainer {
|
|
9
9
|
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<
|
|
10
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
11
|
};
|
|
12
12
|
var displayName: string;
|
|
13
13
|
}
|
|
@@ -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}from"../../reducers/PlaceOrderReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import components from"../../config/components";import{setPlaceOrder}from"../../reducers/PlaceOrderReducer";const propTypes=components.PlaceOrderContainer.propTypes,displayName=components.PlaceOrderContainer.displayName;export function PlaceOrderContainer(props){const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrder,setOrderErrors,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_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.shipment_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:({paymentSource})=>setPlaceOrder({config,order,state,setOrderErrors,paymentSource,include,setOrder}),placeOrderPermitted:()=>placeOrderPermitted({config,dispatch,order,options:{...options}})};return _jsx(PlaceOrderContext.Provider,{value:contextValue,children})}PlaceOrderContainer.propTypes=propTypes,PlaceOrderContainer.displayName=displayName;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 components from"../../config/components";import{setPlaceOrder}from"../../reducers/PlaceOrderReducer";const propTypes=components.PlaceOrderContainer.propTypes,displayName=components.PlaceOrderContainer.displayName;export function PlaceOrderContainer(props){const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrder,setOrderErrors,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_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.shipment_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:({paymentSource})=>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})}PlaceOrderContainer.propTypes=propTypes,PlaceOrderContainer.displayName=displayName;export default PlaceOrderContainer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { BaseAmountComponent } from '
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
3
|
export declare function ShippingAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
4
|
export declare namespace ShippingAmount {
|
|
5
5
|
var propTypes: {
|
|
@@ -8,7 +8,7 @@ export declare namespace ShippingAmount {
|
|
|
8
8
|
style: import("prop-types").Requireable<object>;
|
|
9
9
|
name: import("prop-types").Requireable<string>;
|
|
10
10
|
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
11
|
-
format: import("prop-types").Requireable<import("
|
|
11
|
+
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
12
12
|
};
|
|
13
13
|
var displayName: string;
|
|
14
14
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.ShippingAmount.propTypes,displayName=components.ShippingAmount.displayName;export function ShippingAmount(props){return _jsx(BaseOrderPrice,{base:"amount",type:"shipping",...props})}ShippingAmount.propTypes=propTypes,ShippingAmount.displayName=displayName;export default ShippingAmount;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type AdyenGateway = GatewayBaseType;
|
|
4
4
|
export declare function AdyenGateway(props: AdyenGateway): JSX.Element | null;
|
|
5
5
|
export default AdyenGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";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 isEmpty from"lodash/isEmpty";import{Fragment,useContext}from"react";import AdyenPayment from"../payment_source/AdyenPayment";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import jwt from"../../utils/jwt";import getCardDetails from"../../utils/getCardDetails";export function AdyenGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=useContext(OrderContext),{accessToken}=useContext(CommerceLayerContext),{payment}=useContext(PaymentMethodChildrenContext),{payments,isGuest}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="adyen_payments",locale=order?.language_code,paymentMethods=paymentSource?.payment_methods;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientKey=paymentSource?.public_key,environment=jwt(accessToken).test?"test":"live",adyenConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="adyen_payments"):[];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?clientKey&&!loading&&paymentMethods?_jsxs(Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(AdyenPayment,{templateCustomerSaveToWallet,clientKey,locale,environment,config:adyenConfig})]}):loaderComponent:clientKey&&!loading&&paymentMethods?_jsx(AdyenPayment,{clientKey,locale,config:adyenConfig,environment}):loaderComponent}export default AdyenGateway;
|
package/lib/{cjs/components/gateways → esm/components/payment_gateways}/BraintreeGateway.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type BraintreeGateway = GatewayBaseType;
|
|
4
4
|
export declare function BraintreeGateway(props: BraintreeGateway): JSX.Element | null;
|
|
5
5
|
export default BraintreeGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import BraintreePayment from"../payment_source/BraintreePayment";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{Fragment,useContext}from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function BraintreeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=useContext(OrderContext),{payment}=useContext(PaymentMethodChildrenContext),{payments,isGuest}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="braintree_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const authorization=paymentSource?.client_token,braintreeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="braintree_payments"):[];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?authorization&&!loading?_jsxs(Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(BraintreePayment,{templateCustomerSaveToWallet,authorization,locale,config:braintreeConfig})]}):loaderComponent:authorization&&!loading?_jsx(BraintreePayment,{locale,authorization,config:braintreeConfig}):loaderComponent}export default BraintreeGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type CheckoutComGateway = GatewayBaseType;
|
|
4
4
|
export declare function CheckoutComGateway(props: CheckoutComGateway): JSX.Element | null;
|
|
5
5
|
export default CheckoutComGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CheckoutComPayment from"../payment_source/CheckoutComPayment";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 isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import getCardDetails from"../../utils/getCardDetails";export function CheckoutComGateway(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="checkout_com_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publicKey=paymentSource?.public_key,paymentConfig=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 card.brand?_jsx(PaymentSourceContext.Provider,{value,children}):null}return!isGuest&&templateCustomerCards?publicKey&&!loading?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(CheckoutComPayment,{show,templateCustomerSaveToWallet,publicKey,locale,...paymentConfig})]}):loaderComponent:publicKey&&!loading?_jsx(CheckoutComPayment,{show,publicKey,locale,...paymentConfig}):loaderComponent}export default CheckoutComGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type KlarnaGateway = GatewayBaseType;
|
|
4
4
|
export declare function KlarnaGateway(props: KlarnaGateway): JSX.Element | null;
|
|
5
5
|
export default KlarnaGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import KlarnaPayment from"../payment_source/KlarnaPayment";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 isEmpty from"lodash/isEmpty";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function KlarnaGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="klarna_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientToken=paymentSource?.client_token,klarnaConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=paymentSource?.options?.card,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(KlarnaPayment,{clientToken,locale,...klarnaConfig})]}):clientToken&&!loading?_jsx(KlarnaPayment,{clientToken,locale,...klarnaConfig}):loaderComponent}export default KlarnaGateway;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { LoaderType } from '
|
|
3
|
-
import { PaymentSourceProps } from '
|
|
2
|
+
import { LoaderType } from '../../typings/index';
|
|
3
|
+
import { PaymentSourceProps } from '../payment_source/PaymentSource';
|
|
4
4
|
export declare type GatewayBaseType = Props & {
|
|
5
5
|
show: boolean;
|
|
6
6
|
loading: boolean;
|
|
@@ -0,0 +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 getPaypalConfig from"../../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import CustomerContext from"../../context/CustomerContext";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){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{},setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&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"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type PaypalGateway = Partial<GatewayBaseType>;
|
|
4
4
|
export declare function PaypalGateway(props: PaypalGateway): JSX.Element | null;
|
|
5
5
|
export default PaypalGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaypalPayment from"../payment_source/PaypalPayment";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{useContext}from"react";export function PaypalGateway(props){const{readonly,showCard,handleEditClick,children,...p}=props,{order}=useContext(OrderContext),{payment}=useContext(PaymentMethodChildrenContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="paypal_payments";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:order?.payment_source||paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}const paypalConfig=config&&getPaymentConfig(paymentResource,config);return delete p.show,delete p.templateCustomerCards,delete p.templateCustomerSaveToWallet,delete p.loading,delete p.loaderComponent,delete p.onClickCustomerCards,_jsx(PaypalPayment,{...p,infoMessage:paypalConfig?.infoMessage})}export default PaypalGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type StripeGateway = GatewayBaseType;
|
|
4
4
|
export declare function StripeGateway(props: StripeGateway): JSX.Element | null;
|
|
5
5
|
export default StripeGateway;
|
|
@@ -0,0 +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,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GatewayBaseType } from '../PaymentGateway';
|
|
2
|
+
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
3
|
declare type WireTransferGateway = GatewayBaseType;
|
|
4
4
|
export declare function WireTransferGateway(props: WireTransferGateway): JSX.Element | null;
|
|
5
5
|
export default WireTransferGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import WireTransferPayment from"../payment_source/WireTransferPayment";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export function WireTransferGateway(props){const{readonly,showCard,handleEditClick,children,...p}=props,{payment}=useContext(PaymentMethodChildrenContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="wire_transfers";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=paymentSource?.options?.card||paymentSource?.metadata?.card,value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}const wireTransferConfig=config&&paymentResource?getPaymentConfig(paymentResource,config):{};return _jsx(WireTransferPayment,{...p,...wireTransferConfig})}export default WireTransferGateway;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { LoaderType } from '
|
|
2
|
+
import { LoaderType } from '../../typings/index';
|
|
3
3
|
import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
|
|
4
|
+
import { PaymentResource } from '../../reducers/PaymentMethodReducer';
|
|
4
5
|
declare type Props = {
|
|
6
|
+
/**
|
|
7
|
+
* Hide payment methods by an array of strings
|
|
8
|
+
*/
|
|
9
|
+
hide?: Array<PaymentResource>;
|
|
5
10
|
children: ReactNode;
|
|
6
11
|
activeClass?: string;
|
|
7
12
|
loader?: LoaderType;
|
|
@@ -12,10 +17,10 @@ declare type Props = {
|
|
|
12
17
|
clickableContainer?: never;
|
|
13
18
|
onClick?: never;
|
|
14
19
|
});
|
|
15
|
-
export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, onClick, ...p }: Props): JSX.Element;
|
|
20
|
+
export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, hide, onClick, ...p }: Props): JSX.Element;
|
|
16
21
|
export declare namespace PaymentMethod {
|
|
17
22
|
var propTypes: {
|
|
18
|
-
children: import("prop-types").Validator<
|
|
23
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
19
24
|
};
|
|
20
25
|
var displayName: string;
|
|
21
26
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import components from"../../config/components";import getLoaderComponent from"../../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName;export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useContext(PaymentMethodContext);useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components2=paymentMethods&&paymentMethods.filter(payment=>{if(hide){const source=payment?.payment_source_type;return hide?.includes(source)===!1}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;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-test-id":paymentResource,className:`${className} ${isActive?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(Fragment,{children:components2})}PaymentMethod.propTypes=propTypes,PaymentMethod.displayName=displayName;export default PaymentMethod;
|
package/lib/esm/components/{PaymentMethodAmount.d.ts → payment_methods/PaymentMethodAmount.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { BaseAmountComponent } from '
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
3
|
export declare function PaymentMethodAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
4
|
export declare namespace PaymentMethodAmount {
|
|
5
5
|
var propTypes: {
|
|
@@ -8,10 +8,10 @@ export declare namespace PaymentMethodAmount {
|
|
|
8
8
|
style: import("prop-types").Requireable<object>;
|
|
9
9
|
name: import("prop-types").Requireable<string>;
|
|
10
10
|
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
11
|
-
format: import("prop-types").Requireable<import("
|
|
11
|
+
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
12
12
|
};
|
|
13
13
|
var defaultProps: {
|
|
14
|
-
format: import("
|
|
14
|
+
format: import("../../typings/index").BaseFormatPrice;
|
|
15
15
|
};
|
|
16
16
|
var displayName: string;
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName;export function PaymentMethodAmount(props){return _jsx(BaseOrderPrice,{base:"amount",type:"payment_method",...props})}PaymentMethodAmount.propTypes=propTypes,PaymentMethodAmount.defaultProps=defaultProps,PaymentMethodAmount.displayName=displayName;export default PaymentMethodAmount;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
declare type PaymentMethodNameChildrenProps = Omit<Props, 'children'> & {
|
|
3
3
|
labelName: string;
|
|
4
4
|
};
|
|
5
5
|
declare type Props = {
|
|
6
|
-
children?: (props: PaymentMethodNameChildrenProps) =>
|
|
6
|
+
children?: (props: PaymentMethodNameChildrenProps) => JSX.Element;
|
|
7
7
|
} & JSX.IntrinsicElements['label'];
|
|
8
8
|
export declare function PaymentMethodName(props: Props): JSX.Element;
|
|
9
9
|
export declare namespace PaymentMethodName {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName;export function PaymentMethodName(props){const{payment}=useContext(PaymentMethodChildrenContext),labelName=payment?.name,htmlFor=payment?.payment_source_type,parentProps={htmlFor,labelName,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}PaymentMethodName.propTypes=propTypes,PaymentMethodName.displayName=displayName;export default PaymentMethodName;
|
package/lib/esm/components/{PaymentMethodPrice.d.ts → payment_methods/PaymentMethodPrice.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { BaseAmountComponent } from '
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
type?: 'amount';
|
|
5
5
|
labelFree?: string;
|
|
@@ -13,7 +13,7 @@ export declare namespace PaymentMethodPrice {
|
|
|
13
13
|
style: import("prop-types").Requireable<object>;
|
|
14
14
|
name: import("prop-types").Requireable<string>;
|
|
15
15
|
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
16
|
-
format: import("prop-types").Requireable<import("
|
|
16
|
+
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
17
17
|
};
|
|
18
18
|
var displayName: string;
|
|
19
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName;export function PaymentMethodPrice(props){const{format="formatted",type="amount",labelFree="Free",...p}=props,{payment}=useContext(PaymentMethodChildrenContext),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(payment){const p2=getAmount({base:"price",type,format,obj:payment});setPrice(p2);const c=getAmount({base:"price",type,format:"cents",obj:payment});setPriceCents(c)}return()=>{setPrice(""),setPriceCents(0)}},[payment]);const parentProps={labelFree,price,priceCents,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:priceCents===0?labelFree:price})}PaymentMethodPrice.propTypes=propTypes,PaymentMethodPrice.displayName=displayName;export default PaymentMethodPrice;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
2
|
import { PaymentMethod } from '@commercelayer/sdk';
|
|
3
3
|
declare type ShippingMethodRadioButtonChildrenProps = Omit<Props, 'children'> & {
|
|
4
4
|
checked: boolean;
|
|
5
5
|
handleOnChange: (event: ChangeEvent<HTMLInputElement>) => Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
declare type Props = {
|
|
8
|
-
children?: (props: ShippingMethodRadioButtonChildrenProps) =>
|
|
8
|
+
children?: (props: ShippingMethodRadioButtonChildrenProps) => JSX.Element;
|
|
9
9
|
onChange?: (payment?: PaymentMethod | Record<string, any>) => void;
|
|
10
10
|
} & JSX.IntrinsicElements['input'];
|
|
11
11
|
export declare function PaymentMethodRadioButton(props: Props): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName;export function PaymentMethodRadioButton(props){const{onChange,...p}=props,{payment,paymentSelected,setPaymentSelected,clickableContainer}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=order?.id||"",paymentResource=payment?.payment_source_type,paymentMethodId=payment?.id,name=`payment-${orderId}`,checked=paymentSelected===payment?.id,handleOnChange=async e=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment?.payment_source_type,parentProps={handleOnChange,checked,id,name,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("input",{title:name,type:"radio",id,onChange:handleOnChange,checked,...p})}PaymentMethodRadioButton.propTypes=propTypes,PaymentMethodRadioButton.displayName=displayName;export default PaymentMethodRadioButton;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { PaymentMethodConfig } from '
|
|
2
|
+
import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
config?: PaymentMethodConfig;
|
|
@@ -7,7 +7,7 @@ declare type Props = {
|
|
|
7
7
|
export declare function PaymentMethodsContainer(props: Props): JSX.Element;
|
|
8
8
|
export declare namespace PaymentMethodsContainer {
|
|
9
9
|
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<
|
|
10
|
+
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
11
|
};
|
|
12
12
|
var displayName: string;
|
|
13
13
|
}
|
|
@@ -0,0 +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}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import components from"../../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName;export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useContext(OrderContext),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,includeLoaded]);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})}PaymentMethodsContainer.propTypes=propTypes,PaymentMethodsContainer.displayName=displayName;export default PaymentMethodsContainer;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { PaymentSourceProps } from './PaymentSource';
|
|
3
|
+
declare type Styles = Partial<{
|
|
4
|
+
base: CSSProperties;
|
|
5
|
+
error: CSSProperties;
|
|
6
|
+
placeholder: CSSProperties;
|
|
7
|
+
validated: CSSProperties;
|
|
8
|
+
}>;
|
|
9
|
+
declare type PaypalStyle = Partial<{
|
|
10
|
+
/**
|
|
11
|
+
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#color}
|
|
12
|
+
*/
|
|
13
|
+
color: 'gold' | 'blue' | 'silver' | 'white' | 'black';
|
|
14
|
+
/**
|
|
15
|
+
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#shape}
|
|
16
|
+
*/
|
|
17
|
+
shape: 'rect' | 'pill';
|
|
18
|
+
/**
|
|
19
|
+
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#height}
|
|
20
|
+
*/
|
|
21
|
+
height: string | number;
|
|
22
|
+
/**
|
|
23
|
+
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#label}
|
|
24
|
+
*/
|
|
25
|
+
label: 'paypal' | 'checkout' | 'buynow' | 'pay';
|
|
26
|
+
/**
|
|
27
|
+
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#tagline}
|
|
28
|
+
*/
|
|
29
|
+
tagline: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/#layout}
|
|
32
|
+
*/
|
|
33
|
+
layout: 'vertical' | 'horizontal';
|
|
34
|
+
}>;
|
|
35
|
+
interface PaymentMethodsStyle {
|
|
36
|
+
card?: Styles;
|
|
37
|
+
paypal?: PaypalStyle;
|
|
38
|
+
}
|
|
39
|
+
export declare type AdyenPaymentConfig = {
|
|
40
|
+
cardContainerClassName?: string;
|
|
41
|
+
threeDSecureContainerClassName?: string;
|
|
42
|
+
placeOrderCallback?: (response: {
|
|
43
|
+
placed: boolean;
|
|
44
|
+
}) => void;
|
|
45
|
+
styles?: PaymentMethodsStyle;
|
|
46
|
+
};
|
|
47
|
+
declare type Props = {
|
|
48
|
+
clientKey?: string;
|
|
49
|
+
config?: AdyenPaymentConfig;
|
|
50
|
+
templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
|
|
51
|
+
locale?: string;
|
|
52
|
+
environment?: string;
|
|
53
|
+
};
|
|
54
|
+
export declare function AdyenPayment({ clientKey, config, templateCustomerSaveToWallet, environment, locale, }: Props): JSX.Element | null;
|
|
55
|
+
export default AdyenPayment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{setCustomerOrderParam}from"../../utils/localStorage";import Parent from"../utils/Parent";import getBrowserInfo from"../../utils/browserInfo";import PlaceOrderContext from"../../context/PlaceOrderContext";import OrderContext from"../../context/OrderContext";const threeDSConfiguration={challengeWindowSize:"05"},defaultConfig={};export function AdyenPayment({clientKey,config,templateCustomerSaveToWallet,environment="test",locale="en_US"}){const{cardContainerClassName,threeDSecureContainerClassName,styles}={...defaultConfig,...config},[loadAdyen,setLoadAdyen]=useState(!1),[checkout,setCheckout]=useState(null),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{placeOrderButtonRef}=useContext(PlaceOrderContext),ref=useRef(null),handleSubmit=async(e,component)=>{const savePaymentSourceToCustomerWallet=e?.elements?.save_payment_source_to_customer_wallet?.checked;return savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),component&&component.submit&&component.submit(),!1},handleChange=async(state,checkout2)=>{if(state.isValid){ref.current&&(ref.current.onsubmit=()=>handleSubmit(ref.current,checkout2),setPaymentRef({ref}));const browserInfo=getBrowserInfo(),attributes={payment_request_data:{payment_method:state.data.paymentMethod,shopperInteraction:"Ecommerce",recurringProcessingModel:"CardOnFile",origin:window.location.origin,return_url:window.location.href,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}}};paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes})}},handleOnAdditionalDetails=async(state,component)=>{const attributes={payment_request_details:state.data,_details:1};try{const pSource=paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes}),adyenAction=pSource?.payment_response?.action,resultCode=pSource?.payment_response?.resultCode;if(adyenAction&&component)return component.handleAction(adyenAction),!1;if(["Authorised","Pending","Received"].includes(resultCode))return placeOrderButtonRef!==null&&placeOrderButtonRef?.current!=null&&(placeOrderButtonRef.current.disabled===!0&&(placeOrderButtonRef.current.disabled=!1),placeOrderButtonRef.current?.click()),!0;if(["Cancelled"].includes(resultCode)){const message=pSource?.payment_response?.refusalReason;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}return!1}catch(error){return console.error("Adyen additional details error:",error),!1}},onSubmit=async(state,component)=>{if((await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments"}))?.payment_response?.resultCode==="Authorised")return!0;const attributes={payment_request_data:{...state.data,payment_method:state.data.paymentMethod,return_url:window.location.href},_authorize:1};delete attributes.payment_request_data.paymentMethod;try{const res=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}),action=res?.payment_response?.action;if(component&&action)return component.handleAction(action),!1;const resultCode=res?.payment_response?.resultCode;if(["Authorised","Pending","Received"].includes(resultCode))return placeOrderButtonRef!==null&&placeOrderButtonRef?.current!=null&&(placeOrderButtonRef.current.disabled===!0&&(placeOrderButtonRef.current.disabled=!1),placeOrderButtonRef.current?.click()),!0;if(["Cancelled"].includes(resultCode)){const message=res?.payment_response?.refusalReason;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}if(res?.payment_response?.errorType)if(res?.payment_response?.errorCode==="14_006")onSubmit(state,component);else{const message=res?.payment_response?.message;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}return!1}catch(error){return setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}};return useEffect(()=>{const paymentMethodsResponse=paymentSource?.payment_methods?.paymentMethods?paymentSource?.payment_methods.paymentMethods:[],[firstPaymentMethod]=paymentMethodsResponse,isOnlyCard=paymentMethodsResponse?.length===1&&firstPaymentMethod.type==="scheme";paymentMethodsResponse.length===0&&console.error("Payment methods are not available. Please, check your Adyen configuration.");const options={locale,environment,clientKey,amount:{currency:order?.currency_code||"",value:order?.total_amount_with_taxes_cents||0},countryCode:order?.country_code||"",paymentMethodsResponse:{paymentMethods:paymentMethodsResponse},showPayButton:!1,paymentMethodsConfiguration:{threeDS2:threeDSConfiguration,paypal:{showPayButton:!0,style:styles?.paypal},card:{styles:styles?.card,holderNameRequired:!1}},onAdditionalDetails:handleOnAdditionalDetails,onChange:handleChange,onSubmit};return!ref&&clientKey&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),clientKey&&!loadAdyen&&window&&!checkout&&import("@adyen/adyen-web").then(({default:AdyenCheckout})=>{const type=isOnlyCard?"card":"dropin";AdyenCheckout(options).then(adyenCheckout=>{const component=adyenCheckout.create(type,{onSelect:component2=>{const id=component2._id;id.search("scheme")===-1&&ref.current&&(id.search("paypal")===-1?ref.current.onsubmit=()=>handleSubmit(ref.current,component2):ref.current.onsubmit=null,setPaymentRef({ref}))}}).mount("#adyen-dropin");component&&(setCheckout(component),setLoadAdyen(!0))})}),()=>{setPaymentRef({ref:{current:null}}),setLoadAdyen(!1)}},[clientKey,ref]),!clientKey&&!loadAdyen&&!checkout?null:_jsxs("form",{ref,onSubmit:e=>handleSubmit(e,checkout),children:[_jsx("div",{className:cardContainerClassName,id:"adyen-dropin"}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet}),_jsx("div",{className:threeDSecureContainerClassName,id:"adyen-action"})]})}export default AdyenPayment;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import isEmpty from"lodash/isEmpty";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";import promisify from"../../utils/promisify";const defaultConfig={styles:{input:{"font-size":"16px",color:"#3A3A3A"},".number":{"font-family":"monospace"},":focus":{color:"blue"},".valid":{color:"green"},".invalid":{color:"red"},"@media screen and (max-width: 700px)":{input:{"font-size":"14px"}}},fields:{number:{label:"Card Number",selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{label:"CVV",selector:"#cvv",placeholder:"123"},expirationDate:{label:"Expiration Date",selector:"#expiration-date",placeholder:"10/2022"}},submitLabel:"Set payment method"};export function BraintreePayment({authorization,config,templateCustomerSaveToWallet}){const{fields,styles,containerClassName,cardContainerClassName,fieldsContainerClassName,expDateContainerClassName,fieldLabelClassName,cvvContainerClassName,inputWrapperClassName,cardDetailsContainerClassName}={...defaultConfig,...config},[loadBraintree,setLoadBraintree]=useState(!1),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),ref=useRef(null),handleSubmitForm=async({event,hostedFieldsInstance,threeDSInstance})=>{const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),hostedFieldsInstance)try{const payload=await promisify(hostedFieldsInstance).then(payload2=>payload2),billingAddress=order?.billing_address,verifyCardOptions={nonce:payload.nonce,bin:payload.details.bin,amount:order?.total_amount_with_taxes_float,email:order?.customer_email,billingAddress:{givenName:billingAddress?.first_name,surname:billingAddress?.last_name,phoneNumber:billingAddress?.phone,streetAddress:billingAddress?.line_1,countryCodeAlpha2:billingAddress?.country_code,postalCode:billingAddress?.zip_code,region:billingAddress?.state_code,locality:billingAddress?.city},onLookupComplete:(_data,next)=>{next()}},response=await threeDSInstance.verifyCard(verifyCardOptions);return response.rawCardinalSDKVerificationData.Validated&&paymentSource?(paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"braintree_payments",attributes:{payment_method_nonce:response.nonce,options:{id:response.nonce,card:{last4:response.details.lastFour,exp_year:response.details.expirationYear,exp_month:response.details.expirationMonth,brand:response.details.cardType.toLowerCase()}}}}),!0):!1}catch(error){return console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}return!1};return useEffect(()=>{if(!ref&&authorization&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),authorization&&!loadBraintree&&!isEmpty(window)){const braintreeClient=require("braintree-web/client"),hostedFields=require("braintree-web/hosted-fields"),threeDSecure=require("braintree-web/three-d-secure");braintreeClient.create({authorization},(clientErr,clientInstance)=>{if(clientErr){console.error(clientErr);return}hostedFields.create({client:clientInstance,fields,styles},(hostedFieldsErr,hostedFieldsInstance)=>{if(hostedFieldsErr){console.error(hostedFieldsErr);return}setLoadBraintree(!0),threeDSecure.create({authorization,version:2},(threeDSecureErr,threeDSInstance)=>{threeDSecureErr&&(console.error("3DSecure error",threeDSecureErr),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:threeDSecureErr.message}])),ref.current&&(ref.current.onsubmit=paymentSource2=>handleSubmitForm({event:ref.current,hostedFieldsInstance,threeDSInstance,paymentSource:paymentSource2}),setPaymentRef({ref}))})})})}return()=>{setPaymentRef({ref:{current:null}}),setLoadBraintree(!1)}},[authorization,ref]),!authorization&&!loadBraintree?null:_jsx("div",{className:containerClassName,children:_jsxs("form",{ref,id:"braintree-form",onSubmit:handleSubmitForm,className:containerClassName,children:[_jsxs("div",{className:fieldsContainerClassName,children:[_jsxs("div",{className:cardContainerClassName,children:[_jsx("label",{className:fieldLabelClassName,htmlFor:"card-number",children:fields?.number?.label}),_jsx("div",{className:inputWrapperClassName,id:"card-number"})]}),_jsxs("div",{className:cardDetailsContainerClassName,children:[_jsxs("div",{className:expDateContainerClassName,children:[_jsx("label",{className:fieldLabelClassName,htmlFor:"expiration-date",children:fields?.expirationDate?.label}),_jsx("div",{className:inputWrapperClassName,id:"expiration-date"})]}),_jsxs("div",{className:cvvContainerClassName,children:[_jsx("label",{className:fieldLabelClassName,htmlFor:"cvv",children:fields?.cvv?.label}),_jsx("div",{className:inputWrapperClassName,id:"cvv"})]})]})]}),_jsx("div",{className:fieldsContainerClassName,children:templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})})]})})}export default BraintreePayment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { PaymentMethodConfig } from '
|
|
2
|
+
import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
|
|
3
3
|
import { PaymentSourceProps } from './PaymentSource';
|
|
4
4
|
import { FramesStyle } from 'frames-react';
|
|
5
5
|
export declare type CheckoutComConfig = {
|