25 Star 36 Fork 10

tedi/wxpay

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo.js 3.46 KB
一键复制 编辑 原始数据 按行查看 历史
tedi 提交于 2016-10-10 09:35 . add test line
var api = new require("./index").WechatPayAPI({
appid:"XXXXXXXXXXXXXXXX",
mch_id:"XXXXXXXXXXX",
partner_key:"XXXXXXXXXXXXXXXX",
cert:"certs/apiclient_cert.pem",
cert_key:"certs/apiclient_key.pem"
});
//var item = {batch:"v0101",name:"tedi3231",age:2030};
//var str = api._generate_string_form_obj(item);
//console.log(str);
function test_unifiedorder(){
var order_item = {
notify_url:"http://wedo.avosapps.com/order/aa.php",
openid:"opmukt4SZzas_TinMqpT5JkC3z6Q",
out_trade_no:Number.parseInt(Math.random()*1000000),
spbill_create_ip:"14.23.150.211",
total_fee:1,
trade_type:"NATIVE",
body:"aavv"
};
api.unifiedorder(order_item).then(function(data){
console.log(data);
}).fail(function(err){
console.log(err);
});
}
test_unifiedorder();
api.orderquery("1005450053201511261776573190","").then(function(data){
console.log(data);
}).fail(function(err){
console.log(err);
});
/*
api.closeorder("35370664").then(function(data){
console.log(data);
}).fail(function(err){
console.log(err);
});
*/
/*
api.orderquery("1005450053201511261776573190","").then(function(data){
console.log("data is ",data);
});
*/
/*
var api = new require("./wxapi")("wxbd626ed750b05e5f","ca545a10101efc536107e8cf9eda83f7");
api.get_token().then(function(access_token){
console.log("access_token 1 is ",access_token);
});
setTimeout(function(){
api.get_token().then(function(access_token){
console.log("access_token 2 is ",access_token);
});
},10000);
api.get_ticket().then(function(access_token){
console.log("ticket 1 ",access_token);
});
setTimeout(function(){
api.get_ticket().then(function(access_token){
console.log("ticket 2 " ,access_token);
});
},10000);
setTimeout(function(){
api.get_sns_token("001d2b3c211a0b1858ee558bc9210388").then(function(res){
console.log("ticket 1 ",res);
});
},10000);
*/
/*
var https = require("https");
function test_https(){
var options = {
hostname: 'mail.qq.com',
port: 443,
path: '/',
method: 'GET',
};
var req = https.request(options,function(res){
console.log("Jejjjj");
console.log(res);
});
req.end();
}
*/
/*
https.get('https://mail.qq.com/', function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
}).on('error', function(e) {
console.error(e);
});
*/
//test_https();
/*
var q = require("q");
function test_promise(){
function one(){
var deferred = q.defer();
deferred.resolve(500);
return deferred.promise;
}
one().then(function(data){ console.log(data);});
}
test_promise();
*/
//测试退款功能
function test_refund(){
var params = {
device_info:"WEB",
transaction_id:"1005270053201511261778229445",
out_refund_no:"REFUND0001",
total_fee:1,
refund_fee:1,
refund_fee_type:"CNY",
op_user_id:"1289247501"
};
api.refund(params).then(function(data){
console.log("refund data is ", data);
}).fail(function(err){
console.log("refund erro is",err);
});
}
function test_refundquery(){
var params = {
device_info:"WEB",
transaction_id:"1005270053201511261778229445",
out_refund_no:"REFUND0001"
};
api.refund(params).then(function(data){
console.log("refundquery data is ", data);
}).fail(function(err){
console.log("refundquery erro is",err);
});
}
//test_refund();
function test_generate_barcode_url(){
var url = api.generate_barcode_url(Number.parseInt(Math.random()*100000000));
console.log("barcode url is ",url);
}
test_generate_barcode_url();
var test = function(){}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/tedi/wxpay.git
git@gitee.com:tedi/wxpay.git
tedi
wxpay
wxpay
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385