INVALID_REQUEST: Field [order.avsDetails.billToFirstname] was not in charset [ISO-8859-1]

可紊 提交于 2019-12-12 02:25:04

问题


For some Reasons when I use OnTap MasterCard Extension, Any Arabic characters in shippment addresses throws an error:

INVALID_REQUEST: Field [order.avsDetails.billToFirstname] was not in charset [ISO-8859-1]

The extension link :

https://marketplace.magento.com/ontap-module-mastercard.html

Please help.


回答1:


You can try encoding the data generated in the Builders (inside the Gateway/Request folder) by using plugins.

You can read more how to create plugins here that perform the encoding on all the fields in the builders when needed.

You will create a new module that is doing the modifications needed on the extension you took from the market.

To define your builder in this case your di.xml will look something like:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="\OnTap\MasterCard\Gateway\Request\ShippingDataBuilder">
        <plugin name="jsparo_ontap_mastercard_gateway_request_shippingdatabuilder" type="Jsparo\MasterCard\Plugin\Gateway\Request\ShippingDataBuilder" sortOrder="1"/>
    </type>
</config>

And the Plugin/Gateway/Request/ShippingDataBuilder.php that you will be something like:

<?php
namespace Jsparo\MasterCard\Plugin\Gateway\Request;
class ShippingDataBuilder {
    public function afterBuild(array $subject, $result) {
        array_walk_recursive($result, function(&$value) {
            $value = mb_convert_encoding($value, 'ISO-8859-1', 'UTF-8');
        }
        return $result;
    }
}

You will have to do this for all the builders that generate incorrect data.



来源:https://stackoverflow.com/questions/43448327/invalid-request-field-order-avsdetails-billtofirstname-was-not-in-charset-is

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!