【发布时间】:2018-01-14 04:41:33
【问题描述】:
我正在尝试将 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 支付网站,也没有显示错误。
使用 vanilla CodeIgniter 可以正常工作并成功重定向。
问题:
1) 是否可以从 REST 服务器发布方法中进行重定向?
2) 如果上述情况可行,那么我的代码有什么问题?
3) 有没有其他方法可以实现我想要做的事情?
我在网上找到了很多教程,但都没有使用 REST Server。
【问题讨论】:
标签: rest codeigniter payment-gateway codeigniter-restserver instamojo