Clayton R
Forum Replies Created
-
- Yes, it calls WC()->cart->calculate_totals() and the customer’s tax address is guaranteed to be complete since you have the
Validate Checkout Fieldsoption enabled. - No, it doesn’t need to prevent WooCommerce from performing cart calculations. During the checkout process, WooCommerce performs a cart calculation and then creates the WooCommerce order. Before the PayPal plugin captures/authorizes the payment for the order, it performs a patch request. The patch request uses the WooCommerce order object to update the PayPal order, which ensures all totals match the WooCommerce order.
If you look at the
wc-ppcplog file entries for this order, it should show the data that’s sent to PayPal before the PayPal order object is created. What do the totals show in that request? Is the tax $0 there or is it accurate? That could provide you a clue as to when the tax calculation is breaking down.If those are empty or not yet set, the result is $0.
They can’t be empty because if they were, the
class-wc-checkout.phpfile from core WooCommerce would trigger a validation error. WooCommerce validates that all required fields have a value; if they don’t then WooCommerce shows a notice on the checkout page. The order can’t be processed unless all required fields pass validation. As you confirmed, the WooCommerce order has the correct address info, which is why the order was allowed to have the payment processed.customer clicks the PayPal button on the cart or product page and completes payment on PayPal’s side before reaching the WC checkout form
No, that is not correct. The payment is processed using the standard WooCommerce flow.
the customer’s address comes from PayPal’s API response
That is not correct. The address does not come from PayPal since you confirmed you have the
Disable PayPal Shipping Addressoption enabled.That difference in behavior points directly at the Express flow — which is your plugin’s code
You stated in your original post that this was not the express checkout flow. Here is a direct quote:
Place Order button (not Express Checkout)
Can you show where in your plugin’s execution order the customer tax address is set relative to
I can explain to you how it works.
- The customer clicks the PayPal button.
- A request is made to the WordPress API which routes to the
CartOrderclass. - The customer’s address info is updated, using the checkout form data.
- The PayPal order is created and the response contains the PayPal order ID
- The PayPal wallet opens and the customer then makes their payment method selection.
- The customer clicks the “Complete payment” button in the PayPal wallet.
- Control is returned to the PayPal plugin and the checkout form is submitted.
- WooCommerce updates the customer object using the checkout form data. https://plugins.trac.ww.wp.xz.cn/browser/woocommerce/tags/10.7.0/includes/class-wc-checkout.php#L1310
- WooCommerce triggers the cart calculation.
- WooCommerce validates all of the checkout form data and if any required fields are missing, the process is exited and a notice is shown on the checkout page. It’s impossible that the address info is empty because if it was the validation here would fail.
- No validation errors so WooCommerce creates the WooCommerce order and populates the address info using the checkout form data. As you confirmed, the order’s address info is correct and it comes directly from the form data.
- WooCommerce tells the PayPal plugin to process the payment.
There is no part of that process where the PayPal plugin is manipulating the order address info, the order totals, or the cart totals.
Hi @joyryde
Thank you for your response. I get why you think the PayPal plugin is the cause, but knowing how this plugin is coded I can confirm it’s not the reason your tax calculation is $0. WooCommerce performs a cart calculation right before the WooCommerce order is created. How do you explain the $0 tax total when it’s Woo that’s performing the tax calculation during the checkout process, not the PayPal plugin? How could the PayPal plugin affect the tax value when it’s not involved in the cart calculation logic?
Here is the code from WooCommerce where the customer’s address is updated from the checkout form fields:
And here you can see WooCommerce performs the final cart calculation before the WooCommerce order is created.
You confirmed that all the address info is associated with the order correctly. So here is what we know:
- The order contains all of the correct address info that’s used for tax calculation
- The PayPal plugin does not interact with the cart calculation logic during the checkout process
Given that information, can you explain exactly how the PayPal plugin is responsible for your tax value of $0?
Kind Regards
Hi @joyryde
When the PayPal button is clicked, your plugin makes a
POSTto its REST route (cart/order) to create the PayPal order object before WooCommerce creates the WC order.That’s not a bug, it’s designed that way. You must create a PayPal order ID when the PayPal button is clicked, because that’s how PayPal works. PayPal requires that the button click callback returns a PayPal order ID.
but the shipping address from the checkout form has not yet been fully committed to the WC customer/session at the point your REST handler runs.
WooCommerce updates the session when the customer enters their address info via the
update_checkoutevent that triggers an ajax request. If the address is incomplete, there will be a validation error when you click the PayPal button.You should have the
Validate Checkout Fieldsoption enabled since you are not relying on PayPal to provide the customer’s shipping address info. https://paymentplugins.com/documentation/paypal/advanced-settings/#validate-checkout-fieldsThe fact that the WooCommerce order has a tax value of $0 wouldn’t be related to the PayPal plugin because it doesn’t interact with the order creation logic.
The bug appears intermittent because it depends on the exact timing of when the customer’s address data is flushed to the WC session relative to when the REST request hits
CartOrder::handle_post_request()That code doesn’t create the WooCommerce order though. The WooCommerce order is created during the checkout flow after all required fields have been validated by Woo. If an address is incomplete, it would result in a notice showing on the checkout page. The PayPal plugin doesn’t create WooCommerce orders so it wouldn’t have anything to do with a $0 tax calculation.
Anything in
CartOrderlikeWC()->cart->calculate_totals()has no bearing on the order creation which occurs later after the checkout form is submitted. During the checkout process, WooCommerce re-calculates the cart totals, using the checkout form data that was already entered by your customer.Kind Regards
Hi @barnabas1
That is not Stripe plugin functionality that’s causing the payment section refresh every time you change a billing address field.
It looks like the requests are being triggered by your
eas-eu-complianceplugin.Kind Regards
Forum: Plugins
In reply to: [Payment Plugins for PayPal WooCommerce] Error getAddress() on nullHi @karlob
We encountered the same issue when trying to process refunds via the WooCommerce mobile app.
Can you share the error log? The AjaxFrontendHandler is not involved in the refund process so I’d like to review the error log.
That code has been in place since nearly the first release of this plugin several years ago so it’s odd that errors would just now start triggering for you.
You can reach out via the support widget via the WordPress Admin > WooCommerce > PayPal > Support page and we can share the next release.
Kind Regards
Yes, I will respond to this support request when the next version is released.
Kind Regards
Forum: Plugins
In reply to: [Payment Plugins for Stripe WooCommerce] Managed PaymentsHi @adampaine
Thank you for contacting Payment Plugins. This is an interesting concept to use Stripe’s merchant of record functionality within a WooCommerce store. I’ve forward this on to Stripe’s internal team so they can shed some light on what something like that could look like.
Kind Regards,
Forum: Plugins
In reply to: [Payment Plugins for Stripe WooCommerce] Address AutocompleteHi @barnabas1
After reviewing the WooCommerce and WooPayments code, it looks like the address search functionality is being provided by an endpoint that’s controlled by WooCommerce via
https://public-api.wordpress.com/wpcom/v2/sites/%s/address-autocomplete-token. That would indicate registration is required or an account at wordpress.com in order to use that address completion functionality.In order to implement something similar in the Stripe plugin, we would need to choose a provider, like Google, that provides the address completion functionality. However, those solutions already exist and are not payment gateway specific. https://woocommerce.com/products/google-autofill-customer-addresses
Kind Regards
Forum: Plugins
In reply to: [Payment Plugins for PayPal WooCommerce] Error getAddress() on nullHi @karlob
In the next release, we’re going to be deprecating the AjaxFrontendHandler class where that error occurred because it’s no longer needed.
Kind Regards
Thank you for contacting Payment Plugins. The plugin has styling in its CSS file that hides that HTML when the customer doesn’t have any payment methods. But since you’re using the
Use place order buttonoption that CSS isn’t being loaded so that HTML is visible.I would classify this as a small UX bug which we will address in the next release. You can add the following custom CSS for now that will hide that HTML.
.wc-saved-payment-methods[data-count="0"] {
display: none
}Kind Regards
Forum: Plugins
In reply to: [Payment Plugins for Stripe WooCommerce] Address AutocompleteHi @barnabas1
Thank you for contacting Payment Plugins. Let me have the code for the predictive address search functionality reviewed so I can confirm if it’s possible to build that into the Stripe plugin.
It seems to me that this feature should be available through core rather than a payment solution since a merchant is likely to offer other payment gateways like PayPal, Square, etc.
Kind Regards
Forum: Plugins
In reply to: [Payment Plugins for PayPal WooCommerce] Error getAddress() on nullHi @karlob
Thank you for contacting Payment Plugins. We will review this error and respond with feedback. Do you know if the customer attempted to use PayPal originally and then switched to Apple Pay?
Kind Regards
Thank you for contacting Payment Plugins. Can you confirm that you’re using our plugin, which is called “Payment Plugins for Stripe WooCommerce”? There is another plugin called “WooCommerce Stripe Payment Gateway” so I wanted to confirm that you are using our plugin.
Kind Regards
Hi @rudolfl
“Disable PayPal Shipping Address” option is disabled.
If you review my previous replies, you will see I am recommending that you enable that option, not disable it. By enabling that option, the PayPal integration will not be involved in the shipping selection or calculation.
Kind Regards
- Yes, it calls WC()->cart->calculate_totals() and the customer’s tax address is guaranteed to be complete since you have the