WASABICARD

Get started

Java demo

Interactive source explorer for the WasabiCard Java 8+ Maven demo project — covering SHA256withRSA signing, response verification, multipart file upload, account queries, and global payout flows.

Project explorer

AbstractTest.java — wasabicard-java-demo
wasabicard-java-demosrcmainjavacomwsbcarddemoAbstractTest.java
Base endpoint, headers, credentials, and SHA256withRSA signature verification
1package com.wsbcard.demo;
2
3import cn.hutool.log.Log;
4import cn.hutool.log.LogFactory;
5import com.alibaba.fastjson2.JSON;
6import com.wsbcard.demo.utils.RsaUtils;
7import com.wsbcard.demo.model.ResultData;
8import com.wsbcard.demo.model.TwoTuple;
9
10/**
11 * @Author: main
12 * @date: 2024/10/29 17:33
13 * @describe:
14 */
15public abstract class AbstractTest {
16
17 private static final Log logger = LogFactory.get();
18
19 public static final String HEADER_SIGNATURE = "X-WSB-SIGNATURE";
20 public static final String HEADER_API_KEY = "X-WSB-API-KEY";
21
22 public static final String MERCHANT_API_KEY = "<YOUR_API_KEY>";
23 public static final String MERCHANT_PRIVATE_KEY = "<YOUR_RSA_PRIVATE_KEY_BASE64>";
24 public static final String MERCHANT_PUBLIC_KEY = "<YOUR_RSA_PUBLIC_KEY_BASE64>";
25
26 public static final String WSB_PUBLIC_KEY = "<WASABICARD_PUBLIC_KEY_BASE64>";
27 public static final String ENDPOINT = "https://sandbox-api-merchant.wasabicard.com";
28
29 /**
30 * 商户的标识,可自定义
31 */
32 public static final String MERCHANT_TAG = "T";
33
34
35
36 public static void verifySignature(TwoTuple<String, String> result) {
37 ResultData resultData = JSON.parseObject(result.getSecond(), ResultData.class);
38 if (resultData.isSuccess()) {
39 boolean verify = RsaUtils.verify(result.getSecond(), WSB_PUBLIC_KEY, result.getFirst(), RsaUtils.SIGNATURE_ALGORITHM_SHA256);
40 logger.info("验证签名:{}", verify);
41 }
42 }
43
44}
mainJava 8+ · Maven
44 linesUTF-8Spaces: 4java
Before running

Replace the placeholder credentials in AbstractTest.java with your sandbox API key, merchant RSA key pair, and WasabiCard platform public key from the merchant dashboard.