Yuansfer DOCS
Search…
C# SDK

Requirements

    .NET Core >=2.0 or .NET Standard >=2.0

Installation

Package Manager Console command
1
PM > Install-Package yuansfer-payment -Version 1.0.2
Copied!
Or Visual Studio
    1.
    Open the Solution Explorer.
    2.
    Right-click on a project within your solution.
    3.
    Click on Manage NuGet Packages...
    4.
    Click on the Browse tab and search for "yuansfer-payment".
    5.
    Click on the yuansfer-payment package, select the appropriate version in the right-tab and click Install.

Example

1. Init

1
YuanpayConfig config = new YuanpayConfig();
2
config.env = EnvironmentEnums.SANDBOX.Value;
3
config.merchantNo = "200043";
4
config.storeNo = "300014";
5
config.token = "5cbfb079f15b150122261c8537086d77a";
6
7
YuanpayClient client = new YuanpayV3Client(config);
Copied!

2. Online API

1
JArray goods = new JArray();
2
JObject item = new JObject();
3
item.Add("goods_name","name1");
4
item.Add("quantity","1");
5
goods.Add(item);
6
OnlineSecurepayRequest request = new OnlineSecurepayRequest();
7
8
request.amount = "1.00";
9
request.currency = "USD";
10
request.settleCurrency = "USD";
11
request.vendor = "alipay";
12
request.terminal = "ONLINE";
13
request.reference = DateTime.Now.ToString();
14
request.ipnUrl = "http://zk-tys.yunkeguan.com/ttest/test";
15
request.description = "testDescription";
16
request.note = "testNote";
17
item.Add("goods_name","name1");
18
item.Add("quantity", "1");
19
goods.Add(item);
20
request.goodsInfo = goods.ToString();
21
22
OnlineSecurepayResponse response = client.execute(request);
23
Console.Write(JObject.FromObject(response));
Copied!

3. Offline API

1
InstoreCreateTranQrcodeRequest request = new InstoreCreateTranQrcodeRequest();
2
3
request.amount = "1.11";
4
request.currency = "USD";
5
request.settleCurrency = "USD";
6
request.vendor = "alipay";
7
request.reference = DateTime.Now.ToString();
8
request.ipnUrl = "http://zk-tys.yunkeguan.com/ttest/test";
9
request.needQrcode = "true";
10
request.timeout = 120;
11
12
InstoreCreateTranQrcodeResponse response = client.execute(request);
13
Console.Write(JObject.FromObject(response));
Copied!

4. Mobile API

1
MobilePrepayRequest request = new MobilePrepayRequest();
2
3
request.amount = "0.11";
4
request.currency = "USD";
5
request.settleCurrency = "USD";
6
request.vendor = "alipay";
7
request.terminal = "APP";
8
request.reference = DateTime.Now.ToString();
9
request.ipnUrl = "http://zk-tys.yunkeguan.com/ttest/test";
10
request.description = "Test for description";
11
request.note = "Test for note";
12
13
MobilePrepayResponse response = client.execute(request);
14
Console.Write(JObject.FromObject(response));
Copied!

5. Return API

1
RefundRequest request = new RefundRequest();
2
3
request.refundAmount = "1.11";
4
request.currency = "USD";
5
request.settleCurrency = "USD";
6
request.reference = DateTime.Now.ToString();
7
8
RefundResponse response = client.execute(request);
9
Console.Write(JObject.FromObject(response));
10
System.out.println(JSONObject.fromObject(response));
Copied!
Last modified 7mo ago