springboot 整合支付宝支付(沙箱)

支付宝开放平台官方文档:https://opendocs.alipay.com/open/200/105311

1.创建沙箱应用

登录支付宝开放平台,创建沙箱应用
如何创建沙箱应用

  1. 在控制台页面点击研发服务
    在这里插入图片描述
    红框的信息用于配置springboot,后面会讲到
    在这里插入图片描述
    2.下载支付宝开放平台开发助手
    下载支付宝开放平台助手,用以生成公钥和私钥

https://opendocs.alipay.com/open/291/105971

在这里插入图片描述
在这里插入图片描述
生成密钥和公钥后,在你的沙箱应用中配置公钥
在这里插入图片描述
在这里插入图片描述
3.下载支付demo
https://opendocs.alipay.com/open/54/106682
在这里插入图片描述

4.使用demo的代码整合到spring boot中

(以下的代码均可在demo中找到)

添加maven依赖

<dependency>
            <groupId>com.alipay.sdk</groupId>
            <artifactId>alipay-sdk-java</artifactId>
            <version>4.11.33.ALL</version>
        </dependency>

编写springboot的配置类
在这里插入图片描述
AlipayProperties.class

@ConfigurationProperties(prefix = "ali.pay")
public class AlipayProperties {
   

    public  String appId;

    // 商户私钥,您的PKCS8格式RSA2私钥
    public  String merchantPrivateKey;

    // 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public  String alipayPublicKey;

    // 服务器异步通知页面路径  需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
//    public static String notifyUrl = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";
    public  String notifyUrl;

//    // 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问00000
//    public static String returnUrl = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";
    public  String returnUrl;

    // 签名方式
//    public static String sign_type = "RSA2";
    public  String signType;

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

    // 支付宝网关
//    public static String gateWayUrl = "https://openapi.alipay.com/gateway.do";
    public  String gatewayUrl;


    public String getAppId() {
   
        return appId;
    }

    public void setAppId(String appId) {
   
        this.appId = appId;
    }

    public String getMerchantPrivateKey() {
   
        return merchantPrivateKey;
    }

    public void setMerchantPrivateKey(String merchantPrivateKey) {
   
        this.merchantPrivateKey = merchantPrivateKey;
    }

    public String getAlipayPublicKey() {
   
        return alipayPublicKey;
    }

    public void setAlipayPublicKey(String alipayPublicKey) {
   
        this.alipayPublicKey = alipayPublicKey;
    }

    public String getNotifyUrl() {
   
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
   
        this.notifyUrl = notifyUrl;
    }

    public String getReturnUrl() {
   
        return returnUrl;
    }

    public void setReturnUrl(String returnUrl) {
   
        this.returnUrl = returnUrl;
    }

    public String getSignType() {
   
        return signType;
    }

    public void setSignType(String signType) {
   
        this.signType = signType;
    }

    public String getCharset() {
   
        return charset;
    }

    public 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值