我正在尝试自定义界面提供程序qiwi 这是我的代码:
http = Net::HTTP.new('w.qiwi.com', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
body = {
:bill_id => "BILL-#{payment.id}",
:user => 'tel:' + params[:qiwi][:phone],
:amount => payment.amount,
:ccy => 'RUB',
:comment => "",
:prv_name => 'Company'
}.to_param
key = "Basic " + Base64.encode64s("secret_key")
http.send_request('POST', "/qiwi-notify.php HTTP/1.1", body, {'Accept' => application/xml', 'Authorization' => key})
我需要做以下事情:
POST /qiwi-notify.php HTTP/1.1
Accept: application/xml
Content-type: application/x-www-form-urlencoded
Authorization: Basic MjA0Mjp0ZXN0Cg==
bill_id=BILL-
1&status=paid&error=0&amount=1.00&user=tel%3A%2B79031811737&prv_nam
e=TEST&ccy=RUB&comment=test&command=bill
Response should XML-doc:
HTTP/1.1 200 OK
Content-Type: text/xml
<?xml version="1.0"?> <result><result_code>0</result_code></result>
如何在下面实施privednny请求,我的代码不起作用 感谢
答案 0 :(得分:1)
您没有明确说明您的问题是什么,但在查看代码之前,有一些问题可以解决。
:bill_id => "BILL-#{payment.id}"
最后需要,
。
http.send_request('POST', "/qiwi-notify.php HTTP/1.1", body, {'Accept' => application/xml', 'Authorization' => key})
在application/xml'
之前缺少撇号。
有了这些修复,代码最终看起来像
http = Net::HTTP.new('w.qiwi.com', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
body = {
:bill_id => "BILL-#{payment.id}",
:user => 'tel:' + params[:qiwi][:phone],
:amount => payment.amount,
:ccy => 'RUB',
:comment => "",
:prv_name => 'Company'
}.to_param
key = "Basic " + Base64.encode64s("secret_key")
http.send_request('POST', "/qiwi-notify.php HTTP/1.1", body, {'Accept' => 'application/xml', 'Authorization' => key})