2 Payment callback interfaces in a project

Source: Internet
Author: User

@RequestMapping (value = "Callbackalipay", method = Requestmethod.post)
@ResponseBody
Public responseentity<?> Callbackalipay (
@RequestParam (value = "discount", required = False) String discount,
@RequestParam (value = "Payment_type", required = False) String Payment_type,
@RequestParam (value = "subject", Required = False) String subject,
@RequestParam (value = "Trade_no", required = False) String Trade_no,
@RequestParam (value = "Buyer_email", required = False) String Buyer_email,
@RequestParam (value = "Gmt_create", required = False) String Gmt_create,
@RequestParam (value = "Notify_type", required = False) String Notify_type,
@RequestParam (value = "Quantity", Required = False) String quantity,
@RequestParam (value = "Out_trade_no", required = False) String Out_trade_no,
@RequestParam (value = "seller_id", required = False) String seller_id,
@RequestParam (value = "Notify_time", required = False) String Notify_time,
@RequestParam (value = "Body", required = false) String body,
@RequestParam (value = "Trade_status", required = False) String Trade_status,
@RequestParam (value = "Is_total_fee_adjust", required = False) String Is_total_fee_adjust,
@RequestParam (value = "Total_fee", required = False) String Total_fee,
@RequestParam (value = "gmt_payment", required = False) String gmt_payment,
@RequestParam (value = "Seller_email", required = False) String Seller_email,
@RequestParam (value = "price", required = false) of String price,
@RequestParam (value = "buyer_id", required = False) String buyer_id,
@RequestParam (value = "notify_id", required = False) String notify_id,
@RequestParam (value = "Use_coupon", required = False) String Use_coupon,
@RequestParam (value = "Sign_type", required = False) String Sign_type,
@RequestParam (value = "sign", required = false)-String sign) {

Logger.warn ("Trade_no:" +trade_no);
Logger.warn ("Out_trade_no:" +out_trade_no);
Logger.warn ("Trade_status:" +trade_status);



String result = "fail";

if ("trade_finished". Equals (trade_status) | | "Trade_success". Equals (Trade_status)) {

Business logic

}

/**
* Callback Wechatpay One Order
*
* @param orderdto
* @return HTTP 200
*/
@RequestMapping (value = "Callbackwechatpay", method = Requestmethod.post, produces = "text/xml; Charset=utf-8 ")
@ResponseBody
Public responseentity<?> Callbackwechatpay (
@RequestBody wechatcallbackdto wechatcallbackdto) {

Logger.info ("*******************result_code:*************" +wechatcallbackdto.getresult_code ());
Logger.info ("*******************out_trade_no*************:" +wechatcallbackdto.getout_trade_no ());
Logger.info ("*******************total_fee***************:" +wechatcallbackdto.gettotal_fee ());
String result= "<xml><return_code><! [cdata[fail]]></return_code><return_msg><! [cdata[fail]]></return_msg></xml> ";
try {
if ("SUCCESS". Equals (Wechatcallbackdto.getresult_code ())) {
Orderdto order = new Orderdto ();
Order.setordernum (Wechatcallbackdto.getout_trade_no ());
Order.setpaymentamount ((int) double.parsedouble (Wechatcallbackdto.gettotal_fee ())/100);
Payment Methods
ORDER.SETPAYMENTTYPECD (CONSTANTS.PAYMENTTYPEDC_D05B02);
Business logic
if (!orderservice.callback (order)) {

return new responseentity<string> (result, Httpstatus.ok);

}
Save Payment Records
Wechatpaymenthistorydto wechatpaymenthistorydto=new wechatpaymenthistorydto ();
Wechatpaymenthistorydto.setappid (Wechatcallbackdto.getappid ());
Wechatpaymenthistorydto.setbank_type (Wechatcallbackdto.getbank_type ());
Wechatpaymenthistorydto.setcash_fee (Wechatcallbackdto.getbank_type ());
Wechatpaymenthistorydto.setfee_type (Wechatcallbackdto.getfee_type ());
Wechatpaymenthistorydto.setis_subscribe (Wechatcallbackdto.getis_subscribe ());
WECHATPAYMENTHISTORYDTO.SETMCH_ID (wechatcallbackdto.getmch_id ());
Wechatpaymenthistorydto.setnonce_str (Wechatcallbackdto.getnonce_str ());
Wechatpaymenthistorydto.setopenid (Wechatcallbackdto.getopenid ());
Wechatpaymenthistorydto.setout_trade_no (Wechatcallbackdto.getout_trade_no ());
Wechatpaymenthistorydto.setresult_code (Wechatcallbackdto.getresult_code ());
Wechatpaymenthistorydto.setreturn_code (Wechatcallbackdto.getreturn_code ());
Wechatpaymenthistorydto.setsign (Wechatcallbackdto.getsign ());
Wechatpaymenthistorydto.settime_end (Wechatcallbackdto.gettime_end ());
Wechatpaymenthistorydto.settotal_fee (Wechatcallbackdto.gettotal_fee ());
Wechatpaymenthistorydto.settrade_type (Wechatcallbackdto.gettrade_type ());
WECHATPAYMENTHISTORYDTO.SETTRANSACTION_ID (wechatcallbackdto.gettransaction_id ());
Wechatpaymenthistoryservice.add (wechatpaymenthistorydto);

result= "<xml><return_code><! [cdata[success]]></return_code><return_msg><! [cdata[ok]]></return_msg></xml> ";
}
} catch (Exception e) {
E.printstacktrace ();
}

return new responseentity<string> (result, Httpstatus.ok);
}

2 Payment callback interfaces in a project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.