WooCommerce自定义支付网关集成不做POST


WooCommerce custom payment gateway integration not doing POST

我想知道你是否可以帮助我。我正在开发一个与WooCommerce集成的定制支付网关,但我现在被卡住了。在我点击支付的那一刻,我在chrome控制台得到一个500内部服务器错误,它被卡在收据页面。

你可以在这里查看我目前得到的代码

https://github.com/tora-soft/visanet-uy-payment-gateway/blob/master/visanet-uy-payment-gateway.php

它应该生成一个html表单并向支付网关发送POST,用户将在其中输入他/她的CC详细信息,然后返回。正在运行

8月15日更新

现在帖子正在工作,但当从支付网关返回时,是在一个默认的结帐页面登陆,而不是处理结果。

如有任何帮助,不胜感激。

@Federico你不应该依赖用户按下"返回到网站"来接收支付响应有效载荷。你应该依靠IPN响应谈话从他们的后端到你的后端。您的支付提供商告诉用户支付成功,用户关闭浏览器。

步骤1。当将用户重定向到VisaNetUY时,使其返回Thank You URL。

$return_url = $this->get_return_url($order);

步骤2。将此URL提供给您的支付网关,以便它可以在交易获得批准时通知您的网站。(有时称为webhook或ipn响应)

http://myurl.com/?wc-api=WC_VisaNetUY

步骤3。你需要删除这一行。

add_action('woocommerce_thankyou_' . $this->id, array( $this, 'check_response'  ));

步骤4。用这行代替:

add_action('woocommerce_api_wc_visanetuy', array($this, 'check_response') ); 
//the WC_VisaNetUY from step2 url gets converted to lowercase by wordpress and appended to woocommerce_api_, and if it matches then it calls your function name, in this case it calls your 'check_response', but you could have put any function name here instead of check_reponse in fact some people call it handle_callback or check_ipn_response. 

第5步。不要调用$order->reduce_order_stock(),因为$order->payment_complete()已经为您做了减少库存和更改状态的操作。