-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add verify business details notification #212
Add verify business details notification #212
Conversation
Use the account endpoint in Automattic/transact-platform-server#62 to fetch data regarding the Stripe account.
After the Stripe account has already been connected, sometimes Stripe might fail to verify the already provided KYC data or require more data. In such cases, the account object returned by Stripe will contain a requirements field. This method uses those fields and the account endpoint to check if there are pending requirements for the connected account.
Display a wp-admin notice for when the store does not have a Stripe account connected, this notice contains the OAuth connect link so that the user can connect to a new/existing account. Display a wp-admin notice for when Stripe has pending requirements for the connected account and provide a link to the Express Dashboard so the user can go ahead and address them.
@LevinMedia - any suggestions on the notice text for merchants? Currently, I've used (links are to Stripe connect flow and Stripe Dashboard, respectively):
|
Thanks @luizreis! RE: messaging: If for some reason the account_id and key are not set up, display: Use a green alert: WooCommerce Payments If the account_id and key are set, but the Stripe account endpoint returns some requirement, we display Use a red alert: WooCommerce Payments |
6576125
to
8ba226a
Compare
5b0ba6e
to
fdb2601
Compare
8ba226a
to
a1bdf82
Compare
Create an admin notice specifying the class. Changed print_admin_error to use this.
The account object contains data regarding the requirements, such as current_deadline, which needs to be used outside of the account_has_pending_requirements method. To avoid calling the account API multiple times, account became a parameter of that method and the caller is responsible for actually fetching the account data.
Display the default WCPay gateway messages as wp-admin notices when checking the Stripe account connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good AFAICT! Just address comments and we should be good.
I don't know if this is an actual issue, but when I tried to go to the WooCommerce Payments settings screen before updating the payments server I got this error:
[04-Oct-2019 08:13:12 UTC] PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /app/public/wp-content/plugins/woocommerce-payments/includes/class-wc-payment-gateway-wcpay.php:390
Stack trace:
#0 /app/public/wp-content/plugins/woocommerce-payments/includes/class-wc-payments.php(227): WC_Payment_Gateway_WCPay->account_has_pending_requirements(Object(WP_Error))
#1 /app/public/wp-content/plugins/woocommerce-payments/includes/class-wc-payments.php(68): WC_Payments::check_stripe_account_status()
#2 /app/public/wp-content/plugins/woocommerce-payments/woocommerce-payments.php(31): WC_Payments::init()
#3 /app/public/wp-includes/class-wp-hook.php(286): wcpay_init('')
#4 /app/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#5 /app/public/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#6 /app/public/wp-settings.php(394): do_action('plugins_loaded')
#7 /app/public/wp-config.php(84): require_once('/app/public/wp-...')
#8 /app/public/wp-load.php(37): require_once('/app/public/wp-...')
#9 /app/public/w in /app/public/wp-content/plugins/woocommerce-payments/includes/class-wc-payment-gateway-wcpay.php on line 390
I think there might be an issue with how the WP_Error
is being handled, but I didn't look into it closely.
Check if $api_client is defined before fetching account data in WC_Payments::check_stripe_account_status.
In case the request fails, an WP_Error object is returned from get_account_data. Check if that happened before checking pending requirements to avoid some issues with addressing the account properties in a WP_error object.
@reykjalin - I have added a check to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me!
I have added a check to the $account object to see if it is a WP_Error before attempting to check the account status. Could you take a look at it?
Seems to work right for now. The error isn't very helpful, but that said I don't really ever expect this particular error to happen in production.
Looks good! 😄
I agree. Currently, the only case where the API client request method returns a WP_Error is when status code is 4xx. So it most likely means that this is caused by something wrong in our end. As for the message: I'm just reprinting the one returned by WP.com API, but we could override it and reword to be more meaningful in another issue. |
* Add account endpoint call to API client * Add method to check for pending requirements * Add get login and connect url methods to WCPay gateway * Add wp-admin notices for issues with Stripe account * Add connect to Stripe and update business information messages * Use Gateway messages when checking for Stripe connection issues * Check if account request succeeds before checking its status
Oh yeah, I know why it's showing up. I hadn't merged server62 into my local payments server when I saw the error 🙂. I believe that means the endpoint doesn't exist, which actually does make the error message accurate. Just not very helpful because there's no way a store owner would be able to do anything about that. Which leads me to:
I don't think this is necessary. As an error message for developers it's good 👍. |
Fixes #203
Depends on #211 and woocommerce-payments-server #62
Changes proposed in this Pull Request
Testing instructions