Yuansfer API 文档
搜索文档…
C# SDK

环境需求

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

安装

程序包管理器控制台命令
PM > Install-Package yuansfer-payment -Version 1.0.2
或者使用Visual Studio
  1. 1.
    打开解决方案资源管理器。
  2. 2.
    在解决方案中的项目上单击鼠标右键。
  3. 3.
    单击管理NuGet软件包...
  4. 4.
    单击浏览选项卡,然后搜索“yuansfer-payment”。
  5. 5.
    单击yuansfer-payment软件包,在右侧选项卡中选择适当的版本,然后单击安装。

范例

1. 初始化

YuanpayConfig config = new YuanpayConfig();
config.env = EnvironmentEnums.SANDBOX.Value;
config.merchantNo = "200043";
config.storeNo = "300014";
config.token = "5cbfb079f15b150122261c8537086d77a";
YuanpayClient client = new YuanpayV3Client(config);

2. 在线API

JArray goods = new JArray();
JObject item = new JObject();
item.Add("goods_name","name1");
item.Add("quantity","1");
goods.Add(item);
OnlineSecurepayRequest request = new OnlineSecurepayRequest();
request.amount = "1.00";
request.currency = "USD";
request.settleCurrency = "USD";
request.vendor = "alipay";
request.terminal = "ONLINE";
request.reference = DateTime.Now.ToString();
request.ipnUrl = "http://zk-tys.yunkeguan.com/ttest/test";
request.description = "testDescription";
request.note = "testNote";
item.Add("goods_name","name1");
item.Add("quantity", "1");
goods.Add(item);
request.goodsInfo = goods.ToString();
OnlineSecurepayResponse response = client.execute(request);
Console.Write(JObject.FromObject(response));

3. 线下API

InstoreCreateTranQrcodeRequest request = new InstoreCreateTranQrcodeRequest();
request.amount = "1.11";
request.currency = "USD";
request.settleCurrency = "USD";
request.vendor = "alipay";
request.reference = DateTime.Now.ToString();
request.ipnUrl = "http://zk-tys.yunkeguan.com/ttest/test";
request.needQrcode = "true";
request.timeout = 120;
InstoreCreateTranQrcodeResponse response = client.execute(request);
Console.Write(JObject.FromObject(response));

4. 手机API

MobilePrepayRequest request = new MobilePrepayRequest();
request.amount = "0.11";
request.currency = "USD";
request.settleCurrency = "USD";
request.vendor = "alipay";
request.terminal = "APP";
request.reference = DateTime.Now.ToString();
request.ipnUrl = "http://zk-tys.yunkeguan.com/ttest/test";
request.description = "Test for description";
request.note = "Test for note";
MobilePrepayResponse response = client.execute(request);
Console.Write(JObject.FromObject(response));

5. 退款API

RefundRequest request = new RefundRequest();
request.refundAmount = "1.11";
request.currency = "USD";
request.settleCurrency = "USD";
request.reference = DateTime.Now.ToString();
RefundResponse response = client.execute(request);
Console.Write(JObject.FromObject(response));
System.out.println(JSONObject.fromObject(response));
最近更新 1yr ago
复制链接
大纲
环境需求
安装
范例