Home > Mobile >  The Android studio development integration pay treasure to pay function (barcode, sweep code to pay)
The Android studio development integration pay treasure to pay function (barcode, sweep code to pay)

Time:09-25

Private static final String APP_ID="APP_ID";
Private AlipayClient AlipayClient;
Private static final String APP_PRIVATE_KEY="key";
Private static final String APP_PUBLIC_KEY="pay treasure to public";
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Activity_main);
AlipayClient=new DefaultAlipayClient (" https://openapi.alipay.com/gateway.do ", APP_ID, APP_PRIVATE_KEY, "json", "GBK", APP_PUBLIC_KEY);

//barcode pay
Final AlipayTradePayRequest request=new AlipayTradePayRequest ();
Request. SetBizContent ({" + "
"" out_trade_no \ ": " 20150320010101001 \ ", "+
"" scene \ ": " bar_code, wave_code \ ", "+
"" auth_code \ ": " 28763443825664394 \ ", "+
The subject \ '\' \ ": " Iphone6 16 g, "" +
Seller_id "" \ ", \ "", "2088102146225135 +
Total_amount \ "" + ": 88.88,"
Discountable_amount \ "" + ": 8.88,"
Undiscountable_amount \ "" + ": 80.00,"
The body \ '\' \ ": " Iphone6 16 g, "" +
"" goods_detail \ ": [{" +
Goods_id "" \ ", \ "apple - 01 ", "+
"" alipay_goods_id \ ": " 20010001 \ ", "+
Goods_name "" \ ", \ "it ", "+
Quantity \ "" ": 1, +"
Price, \ '\' ": 2000, +
""" goods_category \ ": " 34543238 \ ", "+
"" body \ ": " special phone \ ", "+
Show_url "" \ ", \ "http://www.alipay.com/xxx.jpg" + "
}], "+"
Operator_id "" \ ", \ "yx_001 ", "+
NJ_001 store_id "" \ ": " \ ", "+
"" terminal_id \ ": " NJ_T_001 \ ", "+
"" alipay_store_id \ ": " 2016041400077000000003314986 \ ", "+
"" extend_params \ ": {" +
"" sys_service_provider_id \ ": " 2088511833207846 \ ", "+
"" hb_fq_num \ ": \ ", "3 +"
"" hb_fq_seller_percent \ ": " 100 \ "" +
"}, "+
"" timeout_express \ ": " m \ ", "90 +
"" royalty_info \ ": {" +
"" royalty_type \ ": " ROYALTY \ ", "+
"" royalty_detail_infos \ ": [{" +
Serial_no \ "" ": 1, +"
"" trans_in_type \ ": " userId \ ", "+
Batch_no "" \ ", \ "", "123 +
"" out_relation_id \ ": " 20131124001 \ ", "+
"" trans_out_type \ ": " userId \ ", "+
"" trans_out \ ": " 2088101126765726 \ ", "+
"" trans_in \ ": " 2088101126708402 \ ", "+
Amount \ "" + ": 0.1,"
Desc "" \ ", \ "the fashionable test 1 ", "+
"" amount_percentage \ ": " 100 \ "" +
"}] + "
"}, "+
"" sub_merchant \ ": {" +
Merchant_id "" \ ", \ "19023454 " "+
"} + "
"} ");
New Thread (new Runnable () {
@ Override
Public void the run () {
Try {
AlipayTradePayResponse response=alipayClient. Execute (request);
Response System. Out. Println (" result "+ response. GetBuyerPayAmount ());
} the catch (AlipayApiException e) {
e.printStackTrace();
}
}
}).start();

//scan code to pay
The findViewById (R.i db t_sm). SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
Final AlipayTradePrecreateRequest request=new AlipayTradePrecreateRequest ();//create the corresponding request API class
Request. SetBizContent ({" + "
"" out_trade_no \ ": " 20150320010101002 \ ", "+
Total_amount \ "" + ": 88.88,"
The subject \ '\' \ ": " Iphone6 16 g, "" +
NJ_001 store_id "" \ ": " \ ", "+
"" timeout_express \ ": " m \ ", "90 +
"} ");//set the business parameters
New Thread (new Runnable () {
@ Override
Public void the run () {
Try {
AlipayTradePrecreateResponse response=alipayClient. Execute (request);
System. The out. Println (" result="+ response. GetQrCode ());
} the catch (AlipayApiException e) {
System. The out. Println (" enter the exception ");
The e (" 1 ", "Exception:" + Log. GetStackTraceString (e));
e.printStackTrace();
}
}
}).start();
}
});


}

CodePudding user response:

The building Lord solved? I also encountered such a problem

CodePudding user response:

Hello, your problem solved, how to solve?

CodePudding user response:

Didn't you solve, back to a message

CodePudding user response:

Oh my god, the building Lord really solve, I also is the problem

CodePudding user response:

The building Lord, you solved this problem?

CodePudding user response:

AlipayClient. Execute (request); . Will quote the Java beans package can't find bosses how to solve the
  • Related