支付宝沙箱环境 电脑支付

项目场景:

java语言,jdk1.8也可以使用 。支付宝沙箱环境电脑支付。
电脑端生成二维码,手机端扫描支付


AlipayConfig:

APP 中接收数据代码:

package com.hc;

/**
 * Project:sx
 * Date:2021/4/27
 * Time:22:08
 *
 * @author hs
 * @version 1.0
 */
public class AlipayConfig {
   

    // 应用ID,您的APPID,是沙箱应用的APPID 不是商家的UID值
    public static String app_id = "";//

    // 私钥  去保存的本地私钥文件中查找
    public static String merchant_private_key = "";

    // 支付宝公钥  在必看部分-->RSA2 设置查看中查看支付宝公钥  不是应用公钥
    public static String alipay_public_key = "";

    // 异步通知   需要公网可访问 采用内网穿透映射公网url
    // 将来放的就是具体异步通知请求
    public static String notify_url = "http://884hvng.natappfree.cc/jgyx/pay/async/notify.do";
    // 同步通知   需要公网可访问  采用内网穿透映射公网URL
    public static String return_url = "http://884hvng.natappfree.cc/jgyx/pay/sync/notify.do";//同步通知请求
    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关   dev 代表沙箱环境
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "D:\\";

    /**
     * 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
     * @param sWord 要写入日志里的文本内容
     */
//    public static void logResult(String sWord) {
   
//        FileWriter writer = null;
//        try {
   
//            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
//            writer.write(sWord);
//        } catch (Exception e) {
   
//            e.printStackTrace();
//        } finally {
   
//            if (writer != null) {
   
//                try {
   
//                    writer.close();
//                } catch (IOException e) {
   
//                    e.printStackTrace();
//                }
//            }
//        }
//    }
}

Controller代码:

package com.hc.controller.h_controller;

import com.hc.AlipayConfig;
import com.hc.pojo.Account;
import com.hc.pojo.GoodsPay;
import com.hc.pojo.OrderInfo;
import com.hc.service.h_service.impl.PayServiceImpl;
import com.hc.service.l_service.impl.OrderServiceImpl;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值