krokedil / klarna-payments-for-woocommerce

GNU General Public License v3.0
10 stars 19 forks source link

There has been an error with your address (using Myparcel shipping plugin) #84

Closed Marienernl closed 6 years ago

Marienernl commented 6 years ago

We've switched from the depreciated Klarna Gateway to this plugin,but without success.

We have an active API, and all seems well, but when a customer wants to place an order, it shows

There has been an error with your address

Please check the following fields: Street address

Support on Klarna's end says the Address information is not properly forwarded towards Klarna.

Help??

kristibarbosky commented 6 years ago

Can you please provide your merchant id (e.g. K100123) and the address that was used so we can review the Klarna logs?

Marienernl commented 6 years ago

53157 - http://bit.ly/2mGRarH

kristibarbosky commented 6 years ago

thanks for the info @Marienernl - 53157 works for KPM, but not Klarna Payments. Klarna Payments requires a new Klarna contract, which you can do from https://eu.portal.klarna.com/signup/ A new contract will provide you with new Klarna credentials (as documented https://docs.woocommerce.com/document/moving-v2-v3-klarna/ and https://www.klarna.com/international/business/woocommerce/).

Marienernl commented 6 years ago

@kristibarbosky I forwarded the wrong id. It is K504295

We've already got a new contract for the new platform.

kristibarbosky commented 6 years ago

Great @Marienernl The street_address sent to Klarna is empty:

"country" : "NL", "region" : "", "postal_code" : "4332XM", "city" : "Middelburg", "street_address" : "", "street_address2" : ""

Does your store have customizations to the Woo checkout form that change the street_address fields?

image

Marienernl commented 6 years ago

@kristibarbosky it seems to be because of the Myparcel shipping plugin, which adds a prefix and number field to the address line, for it to work to print labels for our shipping.

Hmmm, is there someway you can filter these fields and have them connect to the Klarna plugin?

NiklasHogefjord commented 6 years ago

This seems to be a compatibility issue between the Klarna Payments plugin and the Myparcel plugin. Is this the plugin you are using @Marienernl https://wordpress.org/plugins/woocommerce-myparcel/ ?

In the plugin we need to send the customer address information to Klarna. To do this we use the standard WooCommerce checkout fields (https://github.com/krokedil/klarna-payments-for-woocommerce/blob/master/includes/class-wc-gateway-klarna-payments.php#L911-L922). But the Myparcel plugin seem to change this and add new checkout fields for the customer address.

If you can confirm that this is the plugin you're using then I can take a closer look and see how we can proceed with trying to make the two plugins compatible.

Marienernl commented 6 years ago

@NiklasHogefjord Yes that is the one. Myparce is used by many in The Netherlands, so it would be great if the Klarna plugin could pick up on the extra fields to get the address.

NiklasHogefjord commented 6 years ago

Thanks @Marienernl!

I will look into this but we need to have an internal discussion on how to handle these kinds of compatibility issues. There might be a lot of plugins that stores order data in different customized ways and we should probably look into which ones of these we need to add support for.

To solve the issue that you have right now I introduced a new filter in the array containing the order data sent to Klarna. Via this filter you have the possibility to add address, house number and house number suffix from the fields added by the My Parcel plugin.

The name of the filter is called _kp_wc_api_requestargs and can be used in the following way:

https://gist.github.com/krokedilgists/a53a087f2b21702368aa75cb0eca108c

NiklasHogefjord commented 6 years ago

Oh, and this filter is not live yet. You need to download and use the plugin from the Develop branch here: https://github.com/krokedil/klarna-payments-for-woocommerce/tree/develop.

Marienernl commented 6 years ago

@NiklasHogefjord Thanks for getting back to me on this. can I just replace the code you pasted above in the designated file? Or should I replace everything with the development version

Marienernl commented 6 years ago

@NiklasHogefjord I've downloaded the development version as a whole, installed it, but it still seems to be giving the address error. Any suggestions?

NiklasHogefjord commented 6 years ago

If you are used to coding perhaps you can error_log() $order and $posted_data that is available in the my_kp_wc_api_request_args function and see what the exact name is for the fields that you need to pass to Klarna.

Marienernl commented 6 years ago

Hi @NiklasHogefjord, I've forwarded Myparcel to this issue, see if you both can come up with a working solution. I haven't seen it work yet. :( Its been 1.5 weeks since we last used Klarna. So we are basically not able to offer Klarna payments to our customers.

adem-demir commented 6 years ago

Hi,

For the MyParcel plugin we need the following: billing_street_name billing_house_number

This is needed for the correct label.

Marienernl commented 6 years ago

Hi @NiklasHogefjord, any updates on the issue?

NiklasHogefjord commented 6 years ago

Hi @Marienernl, I will try to get you an addon-plugin that will help solve your problem during this week.

Marienernl commented 6 years ago

@NiklasHogefjord that would be great. Thanks so much.

NiklasHogefjord commented 6 years ago

@Marienernl I've updated the code example in the gist now so it fetches the data from the order instead. If you're running WooCommerce v3.x it should fetch the meta fields for _billing_street_name, _billing_house_number, _shipping_street_name & _shipping_house_number correctly.

https://gist.github.com/krokedilgists/a53a087f2b21702368aa75cb0eca108c

Remember that you need to use the Develop branch (https://github.com/krokedil/klarna-payments-for-woocommerce/tree/develop) of the Klarna Payments plugin for this to work.

Marienernl commented 6 years ago

Hi @NiklasHogefjord, thank you for getting back on this. Either im doing something wrong, or its not working. I've downloaded and installed the develop branch version to our site, enabled it, but it keeps bugging about.

There has been an error with your address

Please check the following fields: Street address

What am I doing wrong? Am I downloading the correct files?

mischasigtermans commented 6 years ago

I'm experiencing the exact same issue as @Marienernl. Please fix this.

NiklasHogefjord commented 6 years ago

@Marienernl Just to be sure that you are using the code example as described in the gist I also created a plugin that you could use: https://www.dropbox.com/s/3svmw1ku8p5vojl/klarna-payments-myparcel.zip?dl=0

If that doesn't solve your problem I need to look into this more in detail. I don't have a MyParcel account myself so I would need access to a temporary WP admin login to your site to be able to troubleshoot this.

Please get in touch with us at support@krokedil.se for further communication regarding the login credentials.

Marienernl commented 6 years ago

Hi @NiklasHogefjord Thank you for the effort, but im afraid im still getting the dreaded:

There has been an error with your address

Please check the following fields: Street address

I will send an email with our credentials and see if you can figure out what the issue is.

Marienernl commented 6 years ago

@NiklasHogefjord its been a while since we heard back. It's been weeks now without payment afterwards. i know we are not the only business around, but this is frustrating to say the least. I've send an email to support days ago.

NiklasHogefjord commented 6 years ago

Hi @Marienernl & @Pixelstart, After more testing I realize that address data is sent to Klarna both before the order is created in Woo (via javascript events in front end) and after the order has been created in Woo.

The code I've provided so far have only been for after the order has been created in Woo.

I have now implemented a new filter that can be used for the frontend/javascript communication. I have an updated version of the MyParcel compatibility plugin here: https://gist.github.com/krokedilgists/a53a087f2b21702368aa75cb0eca108c (can be downloaded as a zip directly here: https://gist.github.com/krokedilgists/a53a087f2b21702368aa75cb0eca108c/archive/28ce322e9b1930d1016859c58868e733bb1c8338.zip).

To be able to use it you also need the latest version of the Klarna plugin from the Develop branch here: https://github.com/krokedil/klarna-payments-for-woocommerce/tree/develop.

Marienernl commented 6 years ago

Hi @NiklasHogefjord I appreciate the help.

We are getting somewhere, but unfortunately it now says

Option not available

Unfortunately this option is not available. Please choose a different payment method.

after adding my date of birth and trying to fulfill an order.

Will the changes to the plugin be added to the release version? I hate using dev plugins on a working site.

NiklasHogefjord commented 6 years ago

@Marienernl The changes will be added to the next version. I hope to release it during this week.

@kristibarbosky Is Option not available an error message you're familiar with?

kristibarbosky commented 6 years ago

@Marienernl @NiklasHogefjord - "Option not available" is a common Klarna response, but does indicate that the address data is working now. I recommend testing further with test credentials, not live credentials, as that is easy to be approved by Klarna and complete orders (without incurring fees and such).

If there are still questions or concerns with approvals, please contact your Klarna implementation advisor and they can help work through the reason for the message.

kristibarbosky commented 6 years ago

Closing this ticket as the merchant has now been able to go live with KP; please reopen if further support is needed.

Marienernl commented 6 years ago

@NiklasHogefjord Is it normal for the plugin to export all order information to Klarna even if they are not fulfilled by a klarna payment method? I've been checking the logs in the merchant login and I see that Klarna captures all order information. As far as I can see this is all anonymized, no customer data is send through, but still?

NiklasHogefjord commented 6 years ago

Hi @Marienernl, yes the cart information is sent to Klarna even if the purchase is not finalized with Klarna as the selected payment method.

The reason for this is because the contents of the cart (or the cart value) determines which Klarna payment methods that should be available/visible for the customer in the checkout.

Marienernl commented 6 years ago

@NiklasHogefjord alright. When can I update to the latest stable build? For it to work with the compatibility plugin?

MichaelBengtsson commented 6 years ago

@Marienernl This has been added in the 1.6.0 release. So you can update to that version now.