uniapp支付宝App支付编写(沙箱支付)

uniapp前端代码不需要操作, 只是一个中转站。因为uniapp不支持沙箱支付,所以找了一个插件实现沙箱支付。

  1 <template>
  2     <view>
  3         <view class="login-form">
  4             <form @submit="formSubmit">
  5                 <view class="form-input">
  6                     <view style="margin-top: 60rpx;font-weight: 600;text-align: center;">支付测试</view>
  7                 </view>
  8                 <view class="form-input">
  9                     <input type="text" v-model="name" placeholder="商品名称" />
 10                 </view>
 11                 <view class="form-input">
 12                     <input type="text" v-model="remark" placeholder="商品描述" />
 13                 </view>
 14                 <view class="form-input">
 15                     <input type="text" v-model="totalAmount" placeholder="商品金额" />
 16                 </view>
 17                 <button type="primary" @click="payOrder" form-type="submit">下单</button>
 18             </form>
 19         </view>
 20 
 21     </view>
 22 </template>
 23 <script>
 24     export default {
 25         data() {
 26             return {
 27                 name: '',
 28                 remark:'',
 29                 totalAmount:'',
 30             }
 31         },
 32         onLoad() {
 33 
 34         },
 35         methods: {
 36             payOrder() {
 37                 var thst = this;
 38                 uni.request({
 39                     method: 'GET',
 40                     url: 'http://8.140.176.58:8081/pay/gotopay/'+thst.name+'/'+thst.remark+'/'+thst.totalAmount,
 41                     success: res => {
 42                         console.log(res)
 43                         console.log(res.data.data.payPath)
 44                          const jyAliPay = uni.requireNativePlugin('JY-ALIPAY')
 45                         jyAliPay.show({ // 发起支付
 46                             if_sanbox: true,
 47                             auto_create_order_info: false,
 48                             appid: '',
 49                             rsa2_private: '',
 50                             order_info: res.data.data.payPath,
 51                         }, function(result) { // 支付完成回调
 52                             console.log(result)
 53                             if (result.resultStatus == '5002555') {
 54                                 that.vusui.msg('支付sdk出错')
 55                             } else if (result.resultStatus == '9000') {
 56                                 that.vusui.msg('支付成功')
 57                             } else {
 58                                 that.vusui.msg(result.memo)
 59                             }
 60                         }); 
 61                     }
 62                 });
 63             },
 64             /* pay111() {
 65                 uni.request({
 66                     method: 'GET',
 67                     url: 'http://8.140.176.58:8081/pay/gotopay',
 68                     success: res => {
 69                         console.log(JSON.stringify(res.data.data.payPath))
 70                         uni.requestPayment({  
 71                             provider: 'alipay', //服务提供商(支付宝)(服务提供商,通过uni.getProvider获取)
 72                             orderInfo:'alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2016100900646815&biz_content=%7B%22body%22%3A%224234435%22%2C%22goods_type%22%3A%220%22%2C%22out_trade_no%22%3A%221627263817114%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22subject%22%3A%222112%22%2C%22time_expire%22%3A%222021-07-31+10%3A05%22%2C%22timeout_express%22%3A%2290m%22%2C%22total_amount%22%3A%229.00%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay&sign=O8ldbU0IbovVWwAEP1X47tuo0s8T7PWeHHBZKlDPyy%2Bndaa0iDJ3vLwAQispnOxaBj0%2FZPmKBooljllDF1ZC9C8EU8ijoVYx2eqf7BowEvhIQl4mVzo4lMHCZaVmD%2BS5DDX2t7qGKAZNN59ojj560Xtndo%2FCRK9SYITjD7HL4ZzpfbWgTqENmBQAES6%2BVNYT%2BW842ty6wvJW%2FbOX0UGllxPh6NOUJJDVJOenn1nVXbtN03BDFbT9z6q2d0V7jHyrjv66jwX1r90ZRmaHUJExfWDkXAVr0UKaNHQOm7l8kboSseNnh1wGUAQMsDFuDZbWPNYF%2FoNy1IKhCQ4ecUlgOQ%3D%3D&sign_type=RSA2&timestamp=2021-07-26+10%3A33%3A59&version=1.0',
 73                             success(res) {
 74                                 console.log("支付返回成功了。。。。。。。。。。")
 75                                 console.log(res)
 76                             },
 77                             fail(err) {
 78                                 console.log("支付返回失败了.........................")
 79                                 console.log(res)
 80                             }
 81                         });
 82                     }
 83                 }); */
 84             /* uni.request({
 85                 method: 'GET',
 86                 url: 'http://localhost:8088/pay/gotopay',
 87                 success: res => {
 88                     var orderInfo = res.data.data.payPath;
 89                     console.log(orderInfo)
 90                 }
 91             }); */
 92             //}
 93         }
 94     }
 95 </script>
 96 
 97 
 98 <style>
 99     .line-tatle-input {
100         width: 97%;
101         line-height: 80upx;
102         color: #000;
103         padding-left: 20rpx;
104         height: 80upx;
105         font-size: 28upx;
106         border-radius: 14upx;
107         background-color: #fff;
108     }
109 
110     .saomiao {
111         height: 80rpx;
112         line-height: 80rpx;
113         border: #2C405A 1rpx solid;
114     }
115 
116     .date-style {
117         width: 94%;
118         height: 60rpx;
119         float: left;
120         color: #000;
121         font-size: 28upx;
122         line-height: 80upx;
123     }
124 
125     .login-form {
126 
127         margin: 10px 10px 0 10px;
128         height: 1000rpx;
129         background: #007AFF;
130         border-radius: 10px;
131         background-color: #EEEEEE;
132         box-shadow: 0 2px 10px #9B9B9B;
133         padding: 20px;
134     }
135 
136     .table-row-dates {
137         width: 82%;
138         line-height: 80upx;
139         font-size: 24px;
140         box-shadow: 0px 16px 16px -7px #E1E3F2;
141         background-color: #F1F6F9;
142         float: right;
143         border-radius: 16upx;
144     }
145 
146     .form-input input {
147         background: #ffffff;
148         border-radius: 5px;
149         height: 40px;
150         margin: 20px 0;
151         padding: 0 10px;
152     }
153 
154     .login-img {
155         display: flex;
156         justify-content: center;
157         align-items: center;
158         height: 108px;
159         margin-top: 100rpx;
160     }
161 
162     .owl-login {
163         width: 211px;
164         height: 108px;
165         background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaYAAADYCAMAAACX8Lc0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURQAAAHhROYBWPXpSOpRkR4teQ3NNN3lSOpZlSH9VPHFMNpBhRY1fQ5BhRYxeQ2hGMpVkR4VZP3pSOmxJNJJiRnRON5NjRpBhRV9ALXVPOHpSOnVPOIZaQF8/LW9KNWFALpRkR3ZPOIZaQG9LNV9ALlo8K5VkR31UO1U5KE41JYxeQ3VPOEkyI1U6KU0zJWBALkArHv///93d3BoWG3dQOZVkR5RkR0syJEYvIk0zJZJiRpBhRXhROUkxI3lSOnZQOXZPOHpSOkQuIUEsH0UuIUcwIoRZP1o8K4dbQZNjRoxeQ5FiRopdQntTO0gwI31UPIFXPo1fRIhcQYZaQHhROnZQOIVaQEwzJDYlGl8/LfzHA1I3J5NjRzUkGl4+LT8rH0oxIzgmG4BWPYNYP0MtIFQ4KIJYPlA1Jo9gRIteQ1c6KU40JU81Jj4qHnVPOEoyJDknHH9WPTsoHI5gRGA/LVw9LJRjR0gwIlU5KYlcQlE2J5ZlSF09LD0pHTclG35VPJVlSDQkGVk7KnxTOzonHDwoHT8qHmBALpFhRYVZQIZbQHpTO4hbQTQjGUIsIINZP0cvIoldQoJXPn9VPX5VPUYvIZFiRV4+LI1fQ040JsS+utbKwvn4+Pz8/ItdQ2hGMv7+/nFMNmtIM2ZEMMrCvWNCL+7u7W5KNODg38fAvOTj41c5Kd/Qx/Lx8Vk7K9fV1Ovr6ujo5/X19bmzsIV1bNrZ2LSsp4t9dX5uZJmNhWxXS6+moCckKNTR0N3OxcC6tk40JpKDe6uinM3Kx2hPQkZDR4mHiltGOnJeU5GQkiAcIX57fkw5LTMvM6uqrKGYk9HNy3VkWV5ORf/77f7ur8nGxP3bWkQzKWRJOp6TjfzMFlM8Ljo3O2ZkZ3xnW6GfoWBdYaqel+u5BtDFv6eZkVg9IW9sb1lWWlJDOVE/NPnGCXJSG5qYmmFEH/G9Bf3SMIJhGP7pmP/2131cGpBsFqyEEVpBM4hlF8WZDbuQDqSclt7DbdipCcrArMGVDYJeIqKadIMAAACtdFJOUwARC9SxQFAgwQVkcFBhMSmSGIQ9fd+j16G1pfPC3cDz43SPkn2w+Oj04+zp7Lr0y/r////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+2IAVYAAAF8VJREFUeNrt3XtcE1e+AHBERZGHolZb66vWal+73QxRAwE0gKZoAR9YxNjEB1kQIVBoLIJaC2p0a9lb613REmMSQ5AuIu+XlA+Cz/reddVqrfb93O29+7rvz51HMplJZjKTZITkZH5/tp+PJ8x35nfO+Z2ZcwICBjkiAnwrhjwe4Icx6hkf+8Ezn/VHpim+9ldPyRrlf0oRK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2JYnsmON7XucT01eeUTP90NekpcvSpqeVWJrMaYVIoYpwwPQY8U7YRYRItxYYQlSsWbbExZRct16td6Jt+oMp6/+fiECLdKElNJTCZMKZCo58w/Z46Pvrgiy+++AiLD44dO3742Eek+OCLYzRx3CH+21Hp+/+1/e/DzHHsA/v4Am2J6v8QIoAPV+JPDkx/5C+K98Uf/mKn9Cf+mnhj/PsnJKVP/sBfEq+MP/Ipz+e6Jz7leW/8hU95PjGM+IRPeb7UPfEpz7vj3/iU5zvDCD7l+cIsl095PjDL/Z5PeT7RPfEpjw8++OCDDz4ebfw/69Hcv7hil4YAAAAASUVORK5CYII=');
166         background-repeat: no-repeat;
167         background-size: 100%;
168         position: absolute;
169     }
170 
171     .owl-login .hand {
172         width: 34px;
173         height: 34px;
174         -webkit-border-radius: 40px;
175         border-radius: 40px;
176         background-color: #472d20;
177         transform: scaleY(0.6);
178         transition: 0.3s ease-out;
179         position: absolute;
180         left: 14px;
181         bottom: -8px;
182     }
183 
184     .owl-login .hand.hand-r {
185         left: 170px;
186     }
187 
188     .owl-login .arms {
189         top: 58px;
190         position: absolute;
191         width: 100%;
192         height: 41px;
193         overflow: hidden;
194     }
195 
196     .owl-login .arms .arm {
197         width: 40px;
198         height: 65px;
199         position: absolute;
200         left: 20px;
201         top: 40px;
202         background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAACCCAMAAADmOb+7AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURQAAAE40JVc6KV8/LVQ4KFs8K1I2J1k7KkkxI1I2J2A/LUUuIVI2Jz4qHlo8KkgwIkgwIkIsIEoxI0gwIkgwImA/LUkxI109LGA/LV8/LU40JVE2Jls8K1I3J1s8KzooHFw9LFo7Klo7KzYlGjclG0UuIUwzJUkxI0kwIkkxI040JWA/LVc5KWFALlg6KjknHGE/LTsoHVE1Jl4+LT8rHkIsIDsoHUQtIFw9LFU4KGA/LVk7Kl09LFs8KzonHDknHDkmGzgmGz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 100%;
204         transition: 0.3s ease-out;
205         transform: rotate(-20deg);
206     }
207 
208     .owl-login .arms .arm.arm-r {
209         transform: rotate(20deg) scaleX(-1);
210         left: 158px;
211     }
212 
213     .owl-login.password .hand {
214         transform: translateX(42px) translateY(-15px) scale(0.7);
215     }
216 
217     .owl-login.password .hand.hand-r {
218         transform: translateX(-42px) translateY(-15px) scale(0.7);
219     }
220 
221     .owl-login.password .arms .arm {
222         transform: translateY(-40px) translateX(40px);
223     }
224 
225     .owl-login.password .arms .arm.arm-r {
226         transform: translateY(-40px) translateX(-40px) scaleX(-1);
227     }
228 </style>
View Code

图片效果如下:

 

 下单调用支付宝沙箱支付,后面换成真实支付,前端注释沙箱支付代码,使用uni.requestPayment该方法就OK。

java后端类需要配置支付宝相关AppID,支付宝公钥,以及应用私钥。

 1     // APPID
 2     public static String app_id = "你自己的AppID";
 3 
 4     //异步回调接口:得放到服务器上,且使用域名解析 IP
 5     public static String notify_url = "异步回调接口";
 6 
 7     //支付宝网关(注意沙箱alipaydev,正式则为 alipay)不需要修改
 8     public static String url = "https://openapi.alipaydev.com/gateway.do";
 9 
10     //编码类型
11     public static String charset = "UTF-8";
12 
13     //数据类型
14     public static String format = "json";
15 
16     // 公钥
17     public static String public_key = "支付宝公钥";
18 
19     // 生成公钥时对应的私钥(填自己的)
20     public static String private_key = "应用公钥生成的私钥";
21 
22     //签名类型
23     public static String signtype = "RSA2";
View Code

支付controller类编写

 

  1 @RestController
  2 @RequestMapping("/pay")
  3 @CrossOrigin
  4 public class AlipayOrderController {
  5 
  6     @GetMapping("/test")
  7     public String test(){
  8         return "hellor word";
  9     }
 10 
 11     /**
 12      * @Function: 去支付
 13      * @author: Lee
 14      * @Date: 2021/7/25 16:10
 15      */
 16     @GetMapping("/gotopay/{name}/{remark}/{totalAmount}")
 17     public Map<String, Object> goToPay(@PathVariable String name,@PathVariable String remark, @PathVariable String totalAmount) {
 18         Map<String, Object> map = new HashMap<>();
 19         map.put("code", "error");
 20         map.put("msg", "失败");
 21         /* 查询订单信息 */
 22         AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.url, AlipayConfig.app_id, AlipayConfig.private_key, AlipayConfig.format, AlipayConfig.charset, AlipayConfig.public_key, AlipayConfig.signtype);//支付宝需要的参数serverUrl、appId、private_key、format、charset、public_key、signType
 23         AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
 24         AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
 25         model.setProductCode("QUICK_MSECURITY_PAY");
 26         model.setGoodsType("0");
 27         model.setSubject(name);
 28         model.setBody(remark);
 29         model.setTotalAmount(totalAmount);
 30         model.setTimeExpire("2021-07-31 10:05");
 31         model.setOutTradeNo(UUID.randomUUID().toString().replaceAll("-", ""));
 32         model.setTimeoutExpress("90m");
 33         request.setBizModel(model);
 34         // 回调地址(充值订单)
 35         request.setNotifyUrl(AlipayConfig.notify_url);//AlipayConfig.notify_url 回调地址
 36         //这里和普通的接口调用不同,使用的是sdkExecute
 37         AlipayTradeAppPayResponse response = null;
 38         try {
 39             response = alipayClient.sdkExecute(request);
 40             map.put("code", "SUCCESS");
 41             map.put("msg", "成功");
 42             Map<String, Object> dataMap = new HashMap<>();
 43             dataMap.put("payPath", response.getBody());
 44             map.put("data", dataMap);
 45             return map;
 46         } catch (AlipayApiException e) {
 47             e.printStackTrace();
 48         }
 49         map.put("code", "error");
 50         map.put("msg", "失败");
 51         return map;
 52     }
 53 
 54 
 55     /**
 56      * @Function: 支付宝异步通知回调
 57      * @author: Lee
 58      * @Date: 2021/7/26 10:10
 59      */
 60     @ResponseBody
 61     @RequestMapping("/notify")
 62     public String notify(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
 63         System.out.println("进notify成功了。。。。。。。。。。。。。。。。。。。。。。。");
 64         Map<String, String> params = new HashMap<String, String>();
 65         //从支付宝回调的request域中取值
 66         Map<String, String[]> requestParams = request.getParameterMap();
 67         for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
 68             String name = iter.next();
 69             String[] values = requestParams.get(name);
 70             String valueStr = "";
 71             for (int i = 0; i < values.length; i++) {
 72                 valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
 73             }
 74             // 乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
 75            //  valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
 76             params.put(name, valueStr);
 77         }
 78         //商品订单号
 79         String out_trade_no = request.getParameter("out_trade_no");            // 商户订单号
 80         // 当前交易状态
 81         String tradeStatus = request.getParameter("trade_status");            //交易状态
 82         // 支付金额
 83         String totalAmount = request.getParameter("total_amount");            //交易状态
 84         // 支付时间
 85         String payDate = request.getParameter("gmt_payment");            //交易状态
 86         //3.签名验证(对支付宝返回的数据验证,确定是支付宝返回的)
 87         boolean signVerified = false;
 88         try {
 89             //3.1调用SDK验证签名
 90             signVerified = AlipaySignature.rsaCheckV1(params, AlipayConfig.public_key, AlipayConfig.charset, AlipayConfig.signtype);
 91         } catch (AlipayApiException e) {
 92             e.printStackTrace();
 93         }
 94         //返回状态存入redis中
 95         //对验签进行处理
 96         if (signVerified) {
 97             //验签通过
 98             if (tradeStatus.equals("TRADE_SUCCESS")) {
 99                 //支付成功后的业务处理
100                 System.out.println("成功了。。。。。。。。。。。。。。。。。。。。。。。");
101                 /* 添加支付信息 */
102                 /*OrderPayEntity orderPay = new OrderPayEntity();
103                 orderPay.setId(Long.valueOf(IdUtils.getPrimaryKey()));
104                 orderPay.setOrderId(order.getId());
105                 orderPay.setUserId(order.getUserId());
106                 orderPay.setPayPrice(Double.valueOf(totalAmount));
107                 orderPay.setPayType(PayTypeEnum.ALI_PAY.intKey());
108                 orderPay.setStatus(CalculatStaticConstant.CHECK_ONE);
109                 orderPay.setPayTime(payDate);
110                 orderMapper.saveOrderPay(orderPay);
111                 RedisUtil.set("ali"+out_trade_no, tradeStatus,300);*/
112                 return "success";
113             }
114         } else {  //验签不通过
115             System.err.println("验签失败");
116             return "failure";
117         }
118         return "failure";
119     }
120  }
View Code

pom文件

      <!-- 支付宝sdk -->
        <dependency>
            <groupId>com.alipay.sdk</groupId>
            <artifactId>alipay-sdk-java</artifactId>
            <version>4.15.20.ALL</version>
        </dependency>

 

如有错误,请谅解,共同学习,谢谢。

posted @ 2021-07-28 16:19  初见如月  阅读(2635)  评论(0编辑  收藏  举报