* Check callback for payment method is available before trying to run it
* Check if callback is a function before trying to run it
* Update tests to ensure callbacks only run if they are registered
* Improve the type for callbacks registered by extensions
The previous type was CanMakePaymentCallback, used for the payment methods's own canMakePayment callbacks, which could also return Promises. In order to eliminate the confusion, a new type has been created that defines callbacks that only return true or false.
* Document registerPaymentMethodExtensionCallbacks
* Update docs/extensibility/filtering-payment-methods.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Add information about payment method name in documentation
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Support express payment methods filtering by extensions
* Add tests for getCanMakePayment and fix payment tests' TS errors
* Add comments for payment-method-config-helper test
* Type payment method under /block-registry
* Type assertions and add them back to PaymentMethodConfig
* Type ExpressPaymentMethodConfig
* Fix comment on payments types
* Fix CanMakePayment type
* Fix assertion for payment methods and the savedTokenComponent property
Because class properties come from the config object, they will never be null except if somebody explicitly adds them the the object with a value of null.
Which is not the case for savedTokenComponent for example, because it's optional and that's why we check it like this paymentMethods[ activePaymentMethod ]?.savedTokenComponent
* Add the complete CanMakePaymentReturnType and account for null for PaymentMethod.icons
- canMakePayment can also return a Promise and this was not included in the type definition
- in PaymentMethodConfig's constructor we also need to account for extensions passing {icons: null}.
* Revert Fix assertion for payment methods and the savedTokenComponent property
* Fix failing tests because of savedTokenComponent
I've reverted my changes and left the initialization of savedTokenComponent as it was.
* Rename types for more clarity
* Fix ExtensionNamespace and PaymentMethodName types
* Rename Supports and *PaymentMethodOptions type for better clarity