Java SDK instructions for use
You can use the open SDK we provide to integrate with the PayCloud payment gateway. The SDK encapsulates the process of performing the integration, including adding and validating signatures that call the payment gateway API. We do not guarantee the security and practicality of this code. It is just a examples that demonstrates the process of calling our API. You can refer to this code to write a program that is more suitable for your business system.
Condition
Suitable for Java language, JDK version 1.8 and above development environment.
Java SDK integration
- The SDK has encapsulated the signature verification logic, and the API can be called directly using the SDK.
- Determine the class corresponding to the interface
Such as the interface name:
wisehub.cloud.pay.order
The class in the SDK is: capitalize the first letter of each word and remove the delimiter ("." ) and add Request (or Response) at the end.
The class corresponding to the interface name in the example is:
WisehubCloudPayOrderRequest
(Request class)
BscancPaySubmitResponse
(Response class)
Usage steps
1. Download the jar and add it to your project, please refer to github source code
wise-paycloud-open-api-sdk-java


2. This JAR depends on some open source third party JARs. If these JARs are not integrated in your project, you will need to manually add dependencies to your project
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
3. Refer to the following sample and develop against the cloud API documentation
// Instantiate the client
OpenApiClient openapiClient = new OpenApiClient(<YOUR_APP_ID>, <GATEWAY_URL>, <YOUR_APP_RSA_PRIVATE_KEY>, <GATEWAY_RSA_PUBLIC_KEY>);
// Instantiate the request class corresponding to the specific API.
// The class name corresponds to the interface name, and the name of the current calling interface: paycloud.pay.barcodepay
BscancPaySubmitRequest request = new BscancPaySubmitRequest();
// The SDK already encapsulates the public parameters; here you only need to pass in the business parameters
request.setMerchant_no("M01902792415");
request.setMerchant_order_no("TEST_" + System.currentTimeMillis());
request.setPrice_currency("USD");
request.setTrans_amount(new BigDecimal(10000.00));
request.setAuth_code("135170366275527172");
request.setDescription("test");
BscancPaySubmitResponse response;
try {
response = openapiClient.execute(request);
} catch (OpenApiException e) {
// The call failed with an error message printed
System.err.println();
System.err.println("request api error:" + e.getErrCode() + "->>" + e.getErrMsg());
return;
}
if (!response.isSuccess()) {
// Interface failed to execute, error message printed
System.err.println();
System.err.println("api execute error: " + JSON.toJSONString(response));
}