- JAVA >= 1.8
<dependency>
<groupId>com.yuansfer</groupId>
<artifactId>yuansfer-payment</artifactId>
<version>3.0.4</version>
</dependency>
Please see examples
YuanpayConfig config = new YuanpayConfig(); //Initialize Yuansfer Configuration
config.setEnv(EnviromentEnums.SANDBOX.getValue()) //Set Yuansfer to SandBox Environment, Possible Value: SANDBOX, PRODUCTION
.setMerchantNo("200043") //Set Yuansfer MerchantNo
.setStoreNo("300014") //Set Yuansfer StoreNo
.setToken("5cbfb079f15b150122261c8537086d77a"); //Set Yuansfer Token
YuanpayClient client = new YuanpayV200Client(config); //Initialize Yuansfer Client with above configuration
YuanpayClient client = new YuanpayV300Client(InitYuanpayConfig.initMerchantConfig()); //Initialize Yuansfer Client with default configuration
JSONArray goods = new JSONArray();
JSONObject item = new JSONObject();
item.put("goods_name","name1");
item.put("quantity", "1");
goods.add(item); //Add product items to JSON Object with above format
OnlineSecurepayRequest request = new OnlineSecurepayRequest(); //Initialize Yuansfer SecurePay request object
/**
* Assign required values to request body
**/
request.setAmount("0.01")
.setCurrency("USD")
.setSettleCurrency("USD")
.setVendor("alipay")
.setTerminal("WAP")
.setReference(System.nanoTime()+"")
.setIpnUrl("http://zk-tys.yunkeguan.com/ttest/test")
.setCallbackUrl("http://zk-tys.yunkeguan.com/ttest/test2?status={status}&amount={amount}&transactionNo={transactionNo}")
.setDescription("testDescription")
.setNote("testNote")
.setGoodsInfo(goods.toString());
OnlineSecurepayResponse response = client.execute(request);
System.out.println(JSONObject.fromObject(response));
YuanpayClient client = new YuanpayV300Client(InitYuanpayConfig.initMerchantConfig());
//add,pay流程
InstoreAddRequest addRequest = new InstoreAddRequest();
addRequest.setAmount("0.01")
.setCurrency("USD")
.setSettleCurrency("USD")
.setReference(System.nanoTime()+"");
InstoreAddResponse addResponse = client.execute(addRequest);
System.out.println("add response:" + JSONObject.fromObject(addResponse));
String transactionNo = addResponse.getResult().getString("transactionNo");
InstorePrepayRequest payRequest = new InstorePrepayRequest();
payRequest.setTransactionNo(transactionNo)
.setPaymentBarcode("280946163113394921");
InstorePrepayResponse payResponse = client.execute(payRequest);
System.out.println("pay response:" + JSONObject.fromObject(payResponse));
YuanpayClient client = new YuanpayV300Client(InitYuanpayConfig.initMerchantConfig()); //Initialize Yuansfer Client with default configuration
MobilePrepayRequest request = new MobilePrepayRequest(); //Initialize Yuansfer Mobile PrePay request object
/**
* Assign required values to request body
**/
request.setAmount("0.01")
.setCurrency("USD")
.setSettleCurrency("USD")
.setDescription("testDescription")
.setIpnUrl("http://zk-tys.yunkeguan.com/ttest/test")
.setNote("testNote")
.setReference(System.nanoTime()+"")
.setTerminal("APP")
.setVendor("alipay");
MobilePrepayResponse response = client.execute(request); //Make Mobile PrePay request with above request body
System.out.println(JSONObject.fromObject(response));
YuanpayClient client = new YuanpayV300Client(InitYuanpayConfig.initMerchantConfig()); //Initialize Yuansfer Client with default configuration
RefundRequest request = new RefundRequest(); //Initialize Yuansfer Refund request object
/**
* Assign required values to request body
**/
request.setRefundAmount("0.01")
.setCurrency("USD")
.setSettleCurrency("USD")
.setRefundReference("refund" + System.nanoTime())
.setTransactionNo("297553648150331212");
RefundResponse response = client.execute(request); //Make Refund request with above request body
System.out.println(JSONObject.fromObject(response));