{"id":15441862,"date":"2022-03-09T13:42:03","date_gmt":"2022-03-09T13:42:03","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/payment-callback-url\/"},"modified":"2022-03-09T13:42:03","modified_gmt":"2022-03-09T13:42:03","slug":"payment-callback-url","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/payment-callback-url\/","title":{"rendered":"Payment callback url"},"content":{"rendered":"<p>Hello,<\/p>\n<p>Currently this plugin uses the value of <code>get_bloginfo(&#039;wpurl&#039;)<\/code> to build Paysera payment request callback url. Please refer to <code>PayseraPaymentRequest::buildParameters<\/code> method.<\/p>\n<p>The call to <code>get_bloginfo(&#039;wpurl&#039;)<\/code> is basically and equivalent of calling <code>get_site_url()<\/code> function which is not the best function to use for any frontend urls, including API endpoints. This value is mostly used in admin area, while <code>get_home_url()<\/code> is used for any front-facing urls.<\/p>\n<p>WooCommerce itself uses <code>get_home_url()<\/code> to build it&#8217;s own <code>wc-api<\/code> urls. Please refer to it&#8217;s source code: https:\/\/github.com\/woocommerce\/woocommerce\/blob\/3c9d1353e5b0b30c4613b158ce471cd7b9933472\/plugins\/woocommerce\/includes\/wc-core-functions.php#L1070<\/p>\n<p>We are using custom multilingual solution for some websites which appends language code to all frontend urls. This is done via <code>home_url<\/code> filter because this is the only correct way to do it.<\/p>\n<p>We also redirect user from root url to default language. I.e. https:\/\/example.com is redirected to https:\/\/example.com\/en\/.<\/p>\n<p>Since this plugin uses <code>site_url<\/code> option to build it&#8217;s callback url, the callback is being sent to root url (i.e. https:\/\/example.com\/?wc-api=wc_gateway_paysera) which is then redirected to https:\/\/example.com\/en\/?wc-api=wc_gateway_paysera which might not be the language version that user used during checkout. For example if user placed an order via <strong>estonian<\/strong> version, the callback will be sent to root url without language code and then redirected to <strong>english<\/strong> version. This might cause some inconsistencies in our custom workflow and that tiny redirect is also bothering me.<\/p>\n<p>Please consider using <code>home_url<\/code> or <code>get_home_url<\/code> functions for building callback requests instead of <code>get_bloginfo(&#039;wpurl&#039;)<\/code> or please make <code>callbackurl<\/code> value filterable via WordPress hooks so we can adjust the value ourselves.<\/p>\n<p>Best Regards,<br \/>\nRoman<\/p>\n","protected":false},"template":"","class_list":["post-15441862","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15441862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15441862\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=15441862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}