java怎么对接连连支付?java-sdk 使用文档使用文档分享

本文是关于连连支付的对接工具:java-sdk 使用文档的详细介绍。

java怎么对接连连支付?java-sdk 使用文档使用文档分享

连连支付对接工具:java-sdk 使用文档

一、简介

适用于 JAVA 6 及以上的开发环境。

二、使用说明

概述:连连支付将与服务端交互的接口(OpenAPI)封装在开发工具包(SDK)中,开发者无需自行实现同服务端交互的复杂逻辑,直接将 SDK jar 包引入自己的工程后,通过 OpenAPI 的示例代码实现同连连支付服务端的交互

适用人群

本文阅读对象:商户系统集成连连支付涉及的技术架构师,研发工程师,测试工程师,系统运维工程师等相关人员

三、支持接口

提供创单支付、退款、支付查询、退款查询、物流上传、支付取消、获取 iframe 支付 token 方法、支付/退款通知接口,开发者只需修改部分参数即可调用

目前已支持的接口,如 api 文档所示 :https://doc.lianlianpay.com/doc-api/open-api/pay-order

四、开发准备

相关依赖

sdk jar 包资源:

globalpay-sdk-0.0.5.zip

sdk 使用 demo 资源:

pay-v3-sdk-demo-java.zip

所需额外依赖资源:https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.2

引入 sdk:

方式一:将 sdk jar 包上传至贵公司 maven 仓库

1.上传至maven仓库

mvn deploy:deploy-file -DgroupId=com.lianpay.globalpay -DartifactId=globalpay-sdk -Dversion=0.0.5 -Dpacckaging=jar -Dfile=globalpay-sdk-0.0.5.jar -DrepositoryId=maven-releases -Durl=maven url

–Dversion 版本信息

-DrepositoryId 仓库标识id

-Durl 私服上仓库的位置,打开nexus——>repositories菜单,可以看到该路径。

-Dfile 直接写文件名即可

2.使用依赖

maven:

<dependency>

<groupId>com.lianpay.globalpay</groupId>

<artifactId>globalpay-sdk</artifactId>

<version>0.0.5</version>

</dependency>

<dependency>

<groupId>org.apache.httpcomponents</groupId>

<artifactId>httpclient</artifactId>

<version>4.5.2</version>

</dependency>

gralde:

compile group: ‘com.lianpay.globalpay’, name:’globalpay-sdk’, version:’0.0.5′

complie group: ‘org.apache.httpcomponents’, name:’httpclient’, version:’4.5.2′

方式二:使用本地 sdk jar 包方式

1.maven

<dependency>

<groupId>com.lianpay.globalpay</groupId>

<artifactId>globalpay-sdk</artifactId>

<version>0.0.5</version>

<type>jar</type>

<scope>system</scope>

<systemPath>${basedir}/lib/globalpay-sdk-0.0.5.jar</systemPath>

</dependency>

<dependency>

<groupId>org.apache.httpcomponents</groupId>

<artifactId>httpclient</artifactId>

<version>4.5.2</version>

</dependency>

2.gradle

dependencies { compile files(‘lib/globalpay-sdk-0.0.5.jar’)}

complie group: ‘org.apache.httpcomponents’, name:’httpclient’, version:’4.5.2′

修改商户参数

商户配置文件信息修改:商户号、连连公钥、商户私钥、环境设置

#可参考pay-v3-sdk-demo-java.zip中globalpay-merchant.properties

# ON / OFF

DEBUGGER_FLAG=ON

# (测试模式)ON / OFF

TEST_MODEL=ON

# 商户号 连连提供

MERCHANT_ID=

# 二级商户号 连连提供(若无则不填)

SUB_MERCHANT_ID=

# 见 AlgorithmEnum

SIGN_TYPE=RSA

# 配置商户秘钥

# RSA – 商户私钥 – 商户自己创建

# HMAC – 连连提供的HMAC key

MERCHANT_SIGN_KEY=

# 配置连连秘钥

# RSA – 连连公钥 – 连连提供

# HMAC – 连连提供的HMAC key

LL_SIGN_KEY=

五、SDK 调用示例代码

LianLianpay SDK 集成说明:SDK 已经对加签验签逻辑做了封装,使用 SDK 时传入商户公钥等内容可直接通过 SDK 自动进行加验签,签名方法:加签验签详情参见https://doc.lianlianpay.com/pay-guide/dev-ready/rule

创单支付调用示例

public class PaymentsTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final PaymentsService payService = new PaymentsService();

public void testPaySuccess() {

//创单支付接口详细请见: https://doc.lianlianpay.com/doc-api/open-api/pay-order

PaymentsRequest payRequest = buildCheckoutPagePayRequest();

ApiResult<PaymentsResponse> s = payService.sendPaymentRequest(payRequest, merchant);

}

}

备注:CheckoutPage 模式见代码 demo 包中 CheckoutPagePaymentsTest 测试类,IFrame 模式见 IFramePaymentsTest 测试类,Direct Api 模式见 DirectApiPaymentsTest 测试类。

退款调用示例

public class RefundTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final RefundService refundService = new RefundService();

public void testRefund() {

//退款接口详细请见:https://doc.lianlianpay.com/doc-api/open-api/pay-result

RefundRequest request = buildRefundRequest();

//原始交易订单号 必填

request.setOriginalTransactionId(“”);

ApiResult<RefundResponse> refundResponseApiResult = refundService.sendRefundRequest(request, merchant);

}

}

支付结果查询调用示例

public class PaymentsQueryTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final PaymentsQueryService paymentsQueryService = new PaymentsQueryService();

public void testPaymentsQuery() {

//支付查询接口详细请见:https://doc.lianlianpay.com/doc-api/open-api/pay-result

String merchantTransactionId = “”;

ApiResult<PaymentsResponse> payResponseApiResult = paymentsQueryService.sendPaymentQueryRequest(merchantTransactionId, merchant);

}

}

退款结果查询调用示例

public class RefundQueryTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final RefundQueryService refundQueryService = new RefundQueryService();

public void testRefundQuery() {

//退款查询接口详细请见:https://doc.lianlianpay.com/doc-api/open-api/refund-result

String merchantTransactionId = “”;

ApiResult<RefundResponse> refundResponseApiResult = refundQueryService.sendRefundQueryRequest(merchantTransactionId, merchant);

}

}

支付取消调用示例

public class PaymentsCancelTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final PaymentsCancelService paymentsCancelService = new PaymentsCancelService();

public void testPaymentsCancel() {

//支付取消接口详细请见:https://doc.lianlianpay.com/doc-api/open-api/pay-cancel

String merchantTransactionId = “”;

ApiResult<CancelPayResponse> cancelPayResponseApiResult = paymentsCancelService.sendPaymentCancelRequest(merchantTransactionId, merchant);

}

}

物流上传调用示例

public class ShipmentsUploadTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final ShipmentsService shipmentsService = new ShipmentsService();

public void testShipmentsUpload() {

//物流上传接口详细请见:https://doc.lianlianpay.com/doc-api/open-api/logistics

ShipmentRequest shipmentRequest = buildShipmentRequest();

ApiResult<?> apiResult = shipmentsService.sendShipmentsRequest(shipmentRequest, merchant);

}

}

获取 iframe 支付 token 调用示例

public class IFrameToken {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final IFrameTokenService iFrameTokenService = new IFrameTokenService();

public void testGetIframeToken() {

//获取IFrame支付token详情见:https://doc.lianlianpay.com/doc-api/open-api/get-token

ApiResult<String> iFrameTokenRes = iFrameTokenService.sendIFrameTokenRequest(merchant);

}

}

支付结果通知调用示例

public class PaymentsNotifyTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final PaymentNotifyService paymentNotifyService = new PaymentNotifyService();

public void testPaymentNotify() {

System.out.println(“支付通知详细请见:https://doc.lianlianpay.com/doc-api/open-news/pay-result”);

//通知头部信息

Map<String, String> headers;

//通知body体信息

String requestBody;

PaymentsNotifyRequest paymentsNotifyRequest = paymentNotifyService.checkNotifySignAndGetPaymentsNotifyRequest(headers, requestBody, merchant);

}

}

退款结果通知调用示例

public class RefundNotifyTest {

private final MerchantPropertyReader merchant = new MerchantPropertyReader(“/globalpay-merchant.properties”);

private final RefundNotifyService refundNotifyService = new RefundNotifyService();

public void testRefundNotify() {

System.out.println(“退款通知详细请见:https://doc.lianlianpay.com/doc-api/open-news/refund-result”);

//通知头部信息

Map<String, String> headers;

//通知body体信息

String requestBody;

RefundNotifyRequest refundNotifyRequest = refundNotifyService.checkNotifySignAndGetRefundNotifyRequest(headers, requestBody, merchant);

}

}

生成公私钥示例

public class RsaPairKeyTest {

public static void main(String[] args) throws Exception {

ImmutablePair<String, String> rsaKeyPair = SignUtil.initRsaKey();

System.out.println(“获取Rsa公钥:” + rsaKeyPair.getLeft());

System.out.println(“获取Rsa私钥:” + rsaKeyPair.getRight());

}

}

【版权声明】:以上内容源自互联网,由出海club后台编辑整理汇总,其目的在于收集传播行业新闻资讯。出海club系信息发布平台,仅提供信息存储空间服务。如发现文章、图片等侵权行为,请联系网站管理员,本站将立即删除。

(0)

相关推荐