admin管理员组文章数量:1415673
I am working on a plugin with a payment system. I need to provide a return url for the payment gateway in order to receive its answers. I don't want to create a specific page but to have a kind of listener to do the treatments according to the return and redirect to a page of success or failure. So, i need some suggestions.
Thanks.
I am working on a plugin with a payment system. I need to provide a return url for the payment gateway in order to receive its answers. I don't want to create a specific page but to have a kind of listener to do the treatments according to the return and redirect to a page of success or failure. So, i need some suggestions.
Thanks.
Share Improve this question asked Aug 29, 2019 at 23:18 AlibagdadAlibagdad 31 bronze badge1 Answer
Reset to default 0You could register a rest route (ref: https://developer.wordpress/reference/functions/register_rest_route/).
In your case, something like this would do the trick:
register_rest_route( 'your-plugin/v1', '/payments/(?P<trans_id>\d+)(?:/(?P<amount>\d+))?', array(
'methods' => 'GET',
'callback' => array( $this, 'your_callback_function'),
'args' => array(
'trans_id' => array(
'validate_callback' => function($param, $request, $key) {
return is_numeric( $param );
}
),
'amount' => array(
'validate_callback' => function($param, $request, $key) {
return is_numeric( $param );
}
),
),
) );
Figure out all of your parameters, setup validation here and then write yourself a callback function to do the actual work.
Wordpress is moving down this path to replace the old admin-ajax api, and it's pretty easy to work with. More info: https://developer.wordpress/rest-api/
本文标签: plugin developmentCreating a return url for getting data from external api
版权声明:本文标题:plugin development - Creating a return url for getting data from external api 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745200523a2647345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论