Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 799e15f

Browse files
authored
Audit payment method interface API (#2622)
* remove obsolete useStoreOrder hook and implementation. This hook was actually never completed and was only implemented in the `usePaymentMethodInterface` hook/api. The original purpose was to expose order details to registered payment methods, but that is now exposed via checkout state event emitters so it’s no longer needed. OrderId is exposed via the `CheckoutState` context provider. * remove setBillingData from being exposed to payment methods directly billingData is updated via event emitter callback responses (see payment method data context provider) and is not something that should be set directly via payment methods. We want checkout to have control over how billing data is updated in the state.
1 parent 96d363a commit 799e15f

File tree

6 files changed

+3
-20
lines changed

6 files changed

+3
-20
lines changed

assets/js/base/hooks/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from './cart';
22
export * from './checkout';
3-
export * from './order';
43
export * from './payment-methods';
54
export * from './shipping';
65
export * from './use-collection';

assets/js/base/hooks/order/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/js/base/hooks/order/use-store-order.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

assets/js/base/hooks/payment-methods/use-payment-method-interface.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
/**
2222
* Internal dependencies
2323
*/
24-
import { useStoreOrder, useStoreCartCoupons, useStoreCart } from '..';
24+
import { useStoreCartCoupons, useStoreCart } from '..';
2525

2626
/**
2727
* @typedef {import('@woocommerce/type-defs/registered-payment-method-props').RegisteredPaymentMethodProps} RegisteredPaymentMethodProps
@@ -116,8 +116,7 @@ export const usePaymentMethodInterface = () => {
116116
onShippingRateSelectFail,
117117
needsShipping,
118118
} = useShippingDataContext();
119-
const { billingData, setBillingData } = useBillingDataContext();
120-
const { order, isLoading: orderLoading } = useStoreOrder();
119+
const { billingData } = useBillingDataContext();
121120
const { cartTotals } = useStoreCart();
122121
const { appliedCoupons } = useStoreCartCoupons();
123122
const { noticeContexts, responseTypes } = useEmitResponse();
@@ -164,9 +163,6 @@ export const usePaymentMethodInterface = () => {
164163
},
165164
billing: {
166165
billingData,
167-
setBillingData,
168-
order,
169-
orderLoading,
170166
cartTotal: currentCartTotal.current,
171167
currency: getCurrencyFromPriceResponse( cartTotals ),
172168
cartTotalItems: currentCartTotals.current,

assets/js/type-defs/registered-payment-method-props.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@
119119
* @typedef BillingDataProps
120120
*
121121
* @property {BillingData} billingData The address used for billing.
122-
* @property {Function} setBillingData Used to set the cart billing
123-
* address.
124-
* @property {Object} order The order object for the purchase.
125-
* @property {boolean} orderLoading True if the order is being loaded.
126122
* @property {PreparedCartTotalItem} cartTotal The total item for the cart.
127123
* @property {SiteCurrency} currency Currency object.
128124
* @property {PreparedCartTotalItem[]} cartTotalItems The various subtotal amounts.

docs/extensibility/payment-method-integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ A big part of the payment method integration is the interface that is exposed fo
106106
- `paymentStatus`: This is an object with the [following payment status properties](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/308e968c700028180cab391f2223eb0a43dd2d4d/assets/js/type-defs/contexts.js#L91-L113) - `isPristine`, `isStarted`, `isProcessing`, `isFinished`, `hasError`, `hasFailed`, `isSuccessful`. Note, your payment method does not have to handle setting this status client side. Checkout will handle this via the responses your payment method gives from observers registered to [checkout event emitters](./checkout-flow-and-events.md).
107107
- `shippingStatus`: This object has two properties - `shippingErrorStatus`, which is an object with various error statuses that might exist for shipping, and `shippingErrorTypes`, which is an object containing all the possible types for shipping error status.
108108
- `shippingData`: This object contains all shipping related data (outside of status) - `shippingRates`, `shippingRatesLoading`, `selectedRates`, `setSelectedRates`, `isSelectingRate`, `shippingAddress`, `setShippingAddress`, and `needsShipping`.
109-
- `billing`: This object contains everything related to billing - `billingData`, `setBillingData`, `order`, `orderLoading`, `cartTotal`, `currency`, `cartTotalItems`, `displayPricesIncludingTax`, `appliedCoupons`, `customerId`
109+
- `billing`: This object contains everything related to billing - `billingData`, `cartTotal`, `currency`, `cartTotalItems`, `displayPricesIncludingTax`, `appliedCoupons`, `customerId`
110110
- `eventRegistration`: This object contains all the checkout event emitter registration functions. These are functions the payment method can register observers on to interact with various points in the checkout flow (see [this doc](./checkout-flow-and-events.md) for more info). The following properties are available - `onCheckoutBeforeProcessing`, `onCheckoutAfterProcessingWithSuccess`, `onCheckoutAfterProcessingWithError`, `onPaymentProcessing`, `onShippingRateSuccess`, `onShippingRateFail`, `onShippingRateSelectSuccess`, `onShippingRateSelectFail`
111111
- `components`: The properties on this object are exposed components that can be implemented by your payment method for various common interface elements used by payment methods. Currently the available components on this property are: `ValidationInputError` (a container for holding validation errors which typically you'll include after any inputs), and `CheckboxControl`(which is usually used for indicating to save the payment method). **Note: this last one is subject to change**
112112
- `setExpressPaymentError`: This function receives a string and allows express payment methods to set an error notice for the express payment area on demand. This can be necessary because some express payment method processing might happen outside of checkout events.

0 commit comments

Comments
 (0)