我正在尝试将 Instamojo 支付网关集成到Chris Kacerguis 的 REST 服务器中。
问题:
下面的代码:
public function instamojotest_post()
{
$api = new Instamojo\Instamojo(‘abcd1234’, ‘efgh5678’, 'https://test.instamojo.com/api/1.1/');
try {
$response = $api->paymentRequestCreate([
'amount' => 100,
'purpose' => 'New Product Purchase',
'buyer_name' => 'Test User',
'email' => 'testuser@gmail.com',
'phone' => '9876543210',
'redirect_url' => 'http://www.example.com/products_api/validate_payment'
]);
header('Location: ' . $response['longurl']);
} catch (Exception $e) {
$this->response([
'success' => false,
'message' => $e->getMessage()
], 500);
}
}
没有重定向到 Instamojo 支付站点,也没有显示错误。
它工作正常并使用香草 CodeIgniter 成功重定向。
问题:
1) 是否可以从 REST 服务器发布方法中重定向?
2)如果上述是可能的,那么我的代码有什么问题?
3)还有其他方法可以实现我想要做的事情吗?
我在互联网上找到了很多教程,但没有一个使用 REST Server。