Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/desmond1121/weixin-pay-android
a simple generation api of WeiXin NATIVE pay on android, include post an order, query order status and close a order.
https://github.com/desmond1121/weixin-pay-android
Last synced: 2 months ago
JSON representation
a simple generation api of WeiXin NATIVE pay on android, include post an order, query order status and close a order.
- Host: GitHub
- URL: https://github.com/desmond1121/weixin-pay-android
- Owner: desmond1121
- Created: 2015-07-31T06:03:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-31T07:50:28.000Z (over 9 years ago)
- Last Synced: 2023-03-03T05:51:17.677Z (almost 2 years ago)
- Language: Java
- Size: 223 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WeiXin-pay-android
微信官方的API太难用了,为微信NATIVE支付提供了简单实现,目前可通过简单的代码实现统一下单、生成二维码、查询订单、关闭订单。a simple generation api of WeiXin pay on android.
more details, see: [WeiXin Pay API](https://pay.weixin.qq.com/wiki/doc/api/index.html)#Dependencies:
QRGen, link:[https://github.com/kenglxn/QRGen](https://github.com/kenglxn/QRGen)OkHttp, link:[https://github.com/kenglxn/QRGen](https://github.com/square/okhttp)
#only implements posting NATIVE UnifyOrder now.
#Post a UnifiedOrder
UnifyOrderParam param = new UnifyOrderParam(APPID, MCHID)
.initOrder("description", total_Fee, "http://notify_url", "NATIVE")
.setOrderGenerator(new GenOrderRule() {
@Override
public String generateOrderNumber() {
return "123456789";
}
}).build(APIKEY);UnifyOrder order = new UnifyOrder(param);
/* post a unified order */
order.postOrder(callback);HttpCallBack callback = new HttpCallBack(){
@Override
void onSuccess(BaseTask.From msgFrom, WxResult result){
switch(msgFrom){
case POST:
/* get QR Bitmap (can also get uri and file) */
imageView.setImageBitmap(result.getPayQRBitmap(500, 500));
/* query order status */
order.queryOrder(1000, 60, this);
break;case QUERY:
/* close order */
order.closeOrder(this);
break;
}
}@Override
void onFail(BaseTask.From msgFrom, String err){
switch(msgFrom){
handle error.
}
}
}