我想使用Recurly stoed结算信息创建交易。我使用节点Reculry模块调用node-recurly https://github.com/robrighter/node-recurly
下面请找我的代码
recurly.transactions.create({
'account_code': orgId,
'amount_in_cents': 200,
'currency': 'AUD'
}, function (err, response) {
if (err) {
return res.send({
success :false,
message :message_common.coupon_create_err,
data: err,
status :status_common.error_res
});
} else {
return res.send({
success :true,
message :message_common.coupon_create_success,
data: [],
status :status_common.success_res
});
}
});
它返回以下错误消息,
{
"statusCode": 400,
"headers": {
"date": "Mon, 05 Dec 2016 11:34:53 GMT",
"content-type": "application/xml; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "close",
"set-cookie": [
"__cfduid=deb9088318b3890486d479eb2a9a4aed11480937692; expires=Tue, 05-Dec-17 11:34:52 GMT; path=/; domain=.recurly.com; HttpOnly"
],
"x-api-version": "2.0",
"content-language": "en-US",
"x-ratelimit-limit": "2000",
"x-ratelimit-remaining": "1996",
"x-ratelimit-reset": "1480937940",
"cache-control": "no-cache",
"x-request-id": "aopr1tvaaooktujne13g",
"strict-transport-security": "max-age=15552000; includeSubDomains; preload",
"server": "cloudflare-nginx",
"cf-ray": "30c73103cdd42384-FRA"
},
"data": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n <symbol>invalid_xml</symbol>\n <description>The provided XML was invalid.</description>\n <details>Unacceptable tag <account_code></details>\n</error>"
}
答案 0 :(得分:0)
如果您知道节点的libxmljs模块然后使用node-recurly来帮助解决问题,那么就不会出现XML数据格式错误,
var libxmljs = require("libxmljs");
var xml = '<?xml version="1.0" encoding="UTF-8"?>' +
'<root>' +
'<child foo="bar">' +
'<grandchild baz="fizbuzz">grandchild content</grandchild>' +
'</child>' +
'<sibling>with content!</sibling>' +
'</root>';
使用create transactional code replace with xml variable values。
// Example with Stored Billing Info
<transaction>
<amount_in_cents>100</amount_in_cents>
<currency>USD</currency>
<account>
<account_code>1</account_code>
</account>
</transaction>
// Example with new Billing Info
<transaction>
<amount_in_cents>1000</amount_in_cents>
<currency>USD</currency>
<account>
<account_code>1</account_code>
<billing_info>
<first_name>Verena</first_name>
<last_name>Example</last_name>
<address1>123 Main St.</address1>
<city>San Francisco</city>
<zip>94105</zip>
<country>US</country>
<number>4111-1111-1111-1111</number>
<verification_value>123</verification_value>
<month>11</month>
<year>2015</year>
</billing_info>
</account>
</transaction>