├── .gitignore
├── CHANGELOG.md
├── Demo
├── Charges.aspx
├── Charges.aspx.cs
├── Charges.aspx.designer.cs
├── Demo.csproj
├── Properties
│ └── AssemblyInfo.cs
├── RSACryptoServiceProviderExtension.cs
├── Scripts
│ ├── jquery-1.7.1.intellisense.js
│ ├── jquery-1.7.1.js
│ └── jquery-1.7.1.min.js
├── Web.Debug.config
├── Web.Release.config
├── Web.config
├── Webhooks.aspx
├── Webhooks.aspx.cs
└── Webhooks.aspx.designer.cs
├── Doc
├── SDK 接口文档.md
└── 接入指南.md
├── Example
├── Entry.cs
├── Example.csproj
├── Example
│ ├── AgreementDemo.cs
│ ├── BalanceBonusDemo.cs
│ ├── BalanceDemo.cs
│ ├── BalanceSettlementDemo.cs
│ ├── BalanceTransactionDemo.cs
│ ├── BalanceTransferDemo.cs
│ ├── BatchRefundDemo.cs
│ ├── BatchTransferDemo.cs
│ ├── BatchWithdrawalDemo.cs
│ ├── CardInfoDemo.cs
│ ├── ChannelDemo.cs
│ ├── ChargeDemo.cs
│ ├── CouponDemo.cs
│ ├── CustomsDemo.cs
│ ├── EventDemo.cs
│ ├── IdentificationDemo.cs
│ ├── OrderDemo.cs
│ ├── OrderRefundDemo.cs
│ ├── ProfitTransactionDemo.cs
│ ├── RSACryptoServiceProviderExtension.cs
│ ├── RechargeDemo.cs
│ ├── RedEnvelopeDemo.cs
│ ├── RefundDemo.cs
│ ├── RoyaltyDemo.cs
│ ├── RoyaltySettlementDemo.cs
│ ├── RoyaltyTemplateDemo.cs
│ ├── RoyaltyTransactionDemo.cs
│ ├── SettleAccountDemo.cs
│ ├── SplitProfitDemo.cs
│ ├── SplitReceiverDemo.cs
│ ├── SubAppDemo.cs
│ ├── SubBankDemo.cs
│ ├── TransferDemo.cs
│ ├── UserDemo.cs
│ ├── VerifyDemo.cs
│ ├── WebhooksDemo.cs
│ ├── WithdrawalDemo.cs
│ ├── data.txt
│ └── key.pem
├── InAppExample
│ └── InAppChargeDemo.cs
├── Properties
│ └── AssemblyInfo.cs
├── app.config
├── your_rsa_private_key.pem
└── your_rsa_public_key.pem
├── README.md
├── VERSION
├── libs
├── Newtonsoft.Json.dll
└── pingpp.dll
├── pingpp.sln
└── pingpp
├── Exception
└── PingppException.cs
├── Models
├── Agreement.cs
├── AgreementList.cs
├── BalanceBonus.cs
├── BalanceBonusList.cs
├── BalanceSettlement.cs
├── BalanceSettlementList.cs
├── BalanceTransaction.cs
├── BalanceTransactionList.cs
├── BalanceTransfer.cs
├── BalanceTransferList.cs
├── BatchRefund.cs
├── BatchRefundList.cs
├── BatchTransfer.cs
├── BatchTransferList.cs
├── BatchWithdrawal.cs
├── BatchWithdrawalList.cs
├── Card.cs
├── CardInfo.cs
├── CardList.cs
├── Charge.cs
├── ChargeList.cs
├── Coupon.cs
├── CouponList.cs
├── CouponTemplate.cs
├── CouponTemplateList.cs
├── Customs.cs
├── Deleted.cs
├── DeletedSubAppChannel.cs
├── Error.cs
├── Event.cs
├── EventList.cs
├── Identification.cs
├── Order.cs
├── OrderList.cs
├── OrderRefund.cs
├── OrderRefundList.cs
├── ProfitTransaction.cs
├── ProfitTransactionList.cs
├── Recharge.cs
├── RechargeList.cs
├── RechargeRefund.cs
├── RedEnvelope.cs
├── RedEnvelopeList.cs
├── Refund.cs
├── RefundList.cs
├── Royalty.cs
├── RoyaltyList.cs
├── RoyaltySettlement.cs
├── RoyaltySettlementList.cs
├── RoyaltyTemplate.cs
├── RoyaltyTemplateList.cs
├── RoyaltyTransaction.cs
├── RoyaltyTransactionList.cs
├── SettleAccount.cs
├── SettleAccountList.cs
├── SmsCode.cs
├── SplitProfit.cs
├── SplitProfitList.cs
├── SplitReceiver.cs
├── SplitReceiverList.cs
├── SubApp.cs
├── SubAppChannel.cs
├── SubAppList.cs
├── SubBank.cs
├── SubBankList.cs
├── Token.cs
├── Transfer.cs
├── TransferList.cs
├── User.cs
├── UserList.cs
├── Webhooks.cs
├── Withdrawal.cs
└── WithdrawalList.cs
├── Net
├── Mapper.cs
└── Requestor.cs
├── Pingpp.cs
├── Properties
└── AssemblyInfo.cs
├── Utils
├── OAuthResult.cs
├── RSAUtils.cs
├── WxLiteOauthResult.cs
└── WxPubUtils.cs
├── app.config
├── packages.config
└── pingpp.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | */[Bb]in/
3 | */[Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.log
36 | *.vspscc
37 | *.vssscc
38 | .builds
39 |
40 | # Visual C++ cache files
41 | ipch/
42 | *.aps
43 | *.ncb
44 | *.opensdf
45 | *.sdf
46 |
47 | # Visual Studio profiler
48 | *.psess
49 | *.vsp
50 | *.vspx
51 |
52 | # Guidance Automation Toolkit
53 | *.gpState
54 |
55 | # ReSharper is a .NET coding add-in
56 | _ReSharper*
57 |
58 | # NCrunch
59 | *.ncrunch*
60 | .*crunch*.local.xml
61 |
62 | # Installshield output folder
63 | [Ee]xpress
64 |
65 | # DocProject is a documentation generator add-in
66 | DocProject/buildhelp/
67 | DocProject/Help/*.HxT
68 | DocProject/Help/*.HxC
69 | DocProject/Help/*.hhc
70 | DocProject/Help/*.hhk
71 | DocProject/Help/*.hhp
72 | DocProject/Help/Html2
73 | DocProject/Help/html
74 |
75 | # Click-Once directory
76 | publish
77 |
78 | # Publish Web Output
79 | *.Publish.xml
80 |
81 | # NuGet Packages Directory
82 | packages
83 |
84 | # Windows Azure Build Output
85 | csx
86 | *.build.csdef
87 |
88 | # Windows Store app package directory
89 | AppPackages/
90 |
91 | # Others
92 | sql
93 | TestResults
94 | [Tt]est[Rr]esult*
95 | *.Cache
96 | ClientBin
97 | [Ss]tyle[Cc]op.*
98 | ~$*
99 | *.dbmdl
100 | Generated_Code #added for RIA/Silverlight projects
101 |
102 | # Backup & report files from converting an old project file to a newer
103 | # Visual Studio version. Backup files are not needed, because we have git ;-)
104 | _UpgradeReport_Files/
105 | Backup*/
106 | UpgradeLog*.XML
107 | *.cmd
108 | *.nupkg
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # ChangeLog
2 | ### 1.6.0
3 | - 新增
4 | - 新增:SplitProfit、SplitReceiver、ProfitTransaction、SubBank 相关接口
5 |
6 | ### 1.5.0
7 | - 修改
8 | - 修改目标框架为.NET Framework 4.6
9 | - 修复 Pingpp.WxPubUtils.GetSignature 生成微信公众号 jssdk signature 返回null的bug
10 |
11 | ### 1.4.5
12 | - 新增
13 | - 新增签约接口
14 | - 新增微信小程序获取openid方法
15 | - 修改
16 | - 部分对象字段从 int 改成 long
17 |
18 | ### 1.4.4
19 | - 修改
20 | - order创建示例参数新增 余额结算信息
21 | - 所有接口URI强制验签
22 | - 新增
23 | - 余额结算查询/列表接口
24 | - 银行卡信息查询接口
25 |
26 | ### 1.4.3
27 | - 修改
28 | - order移除 credential,user_from字段,添加amount 字段.
29 | - 移除无卡接口类及示例
30 | - 移除转账/批量转账取消接口
31 | - 更新Newtonsoft.Json 版本至9.0.1
32 | - 新增
33 | - 优惠券对象新增 user_times_circulated 字段
34 | - 优惠券模板对象删除 user_times_circulated 字段
35 |
36 | ### 1.4.2
37 | - 新增
38 | - 支付宝/微信跨境渠道创建charge支付示例
39 | - 优惠券模板对象新增 user_times_circulated 字段
40 |
41 | ### 1.4.1
42 | - 新增
43 | - 分润(royalty)对象返回新增royalty_settlement字段
44 | - 分润结算明细(royalty_transaction)对象新增failure_msg,transfer字段
45 | - 优惠券模板(coupon_template)对象创建请求新增max_user_circulation参数
46 | - 修改
47 | - 自动重试机制
48 | - order对象添加charge字段
49 |
50 | ### 1.4.0
51 | - 新增
52 | - 新增订单退款接口
53 | - 新增余额转账balance_transfers接口
54 | - 新增余额赠送接口 balance_bonuses
55 | - 新增用户余额充值接口 /v1/apps/APP_ID/recharges
56 | - 新增分润模板接口
57 | - 修改
58 | - 子商户对象新增level,parent_app 字段,创建参数新增 parent_app 参数
59 | - 提现创建接口新增settle_account 参数, channel,extra 参数由必填修改为选填.
60 | - order退款列表order_refund变更为refund对象
61 | - 原order退款创建、查询列表返回的order_refund变更为refund对象.
62 | - order对象新增charge对象列表,actual_amount参数;
63 | - 订单支付接口支持传商户订单号,此时支付的商户订单号不等于订单的商户订单号;
64 | - 原/v1/recharge 接口废弃,请使用新用户余额充值接口
65 | - 原用户余额转账transfers 接口废弃请使用 balance_transfers 接口
66 | - 原余额提现withdrawals废弃 请使用/v1/apps/APP_ID/withdrawals 接口
67 | - 原余额收款接口 receipts 废弃,请使用 balance_bonus 接口
68 | - 原 asset_transactions transaction_statistics接口下线.
69 |
70 | ### 1.3.0
71 | - 新增
72 | - 子商户应用(SubApp)及渠道参数(Channel)接口
73 | - 分润相关接口(Royalty,RoyaltySettlement,RoyaltyTransaction)
74 | - 用户新增结算账户(SettleAccount)
75 | - 修改
76 | - AssetTransaction 字段删除及增加
77 | - Order 增加字段
78 | - TransactionStatistics 增加字段
79 | - User 增加字段
80 |
81 | ### 1.2.1(2016-12-26)
82 | - 新增
83 | - withdrawal对象 添加 failure_msg,operation_url字段
84 | - batch_withdrawal列表 添加 time_finished字段
85 | - user 对象 balance 字段改成 available_balance
86 | - balance_transaction 对象 balance 字段改成 available_balance。
87 | - 新增用户收款接口
88 | ### 1.2.0
89 | - 新增:
90 | - 企业付款SDK更新接口
91 | - 请求认证接口接口
92 | - 报关接口接口
93 | - 批量退款接口
94 | - 订单创建更新查询删除支付接口
95 | - 用户充值接口接口
96 | - 企业清算账户交易明细接口
97 | - 用户接口
98 | - 余额转账接口
99 | - 优惠券及优惠券模板接口
100 | - 企业清算账户额度统计,批量提现确认新增和查询接口
101 |
102 | - 修改
103 | - 示例代码 Demo、Example 的修改
104 | - 修改接口请求签名
105 |
106 | ### 1.1.0
107 | - 新增:
108 | - 添加请求签名
109 | - 修改:
110 | - namespace 由 pingpp 改为 Pingpp
111 | - 方法名更改,首字母大写
112 | - 一些细节以及 bug 的改进和修正
113 | - 示例代码 Demo、Example 的修改
114 |
--------------------------------------------------------------------------------
/Demo/Charges.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Charges.aspx.cs" Inherits="Demo.Charges" %>
2 |
3 | <%--
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 | --%>
17 |
--------------------------------------------------------------------------------
/Demo/Charges.aspx.designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Demo {
11 |
12 |
13 | public partial class Charges {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Demo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Demo")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("a6cb8e79-0cff-4f9c-8de6-a2d3de1d01d6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Demo/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/Demo/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/Demo/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
13 |
14 |
15 |
20 |
21 |
33 |
34 |
35 |
39 |
--------------------------------------------------------------------------------
/Demo/Webhooks.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Webhooks.aspx.cs" Inherits="Demo.Webhooks" %>
2 |
3 | <%--
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 | --%>
17 |
--------------------------------------------------------------------------------
/Demo/Webhooks.aspx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Web.UI;
3 | using System.IO;
4 | using System.Text;
5 | using Newtonsoft.Json.Linq;
6 | using System.Security.Cryptography;
7 |
8 | namespace Demo
9 | {
10 | public partial class Webhooks : Page
11 | {
12 | protected void Page_Load(object sender, EventArgs e)
13 | {
14 | if (Request.RequestType.ToUpper().Equals("POST"))
15 | {
16 | //获取 post 的 event对象
17 | var inputData = ReadStream(Request.InputStream);
18 |
19 | //获取 header 中的签名
20 | var sig = Request.Headers.Get("x-pingplusplus-signature");
21 |
22 | //string sig = "BX5sToHUzPSJvAfXqhtJicsuPjt3yvq804PguzLnMruCSvZ4C7xYS4trdg1blJPh26eeK/P2QfCCHpWKedsRS3bPKkjAvugnMKs+3Zs1k+PshAiZsET4sWPGNnf1E89Kh7/2XMa1mgbXtHt7zPNC4kamTqUL/QmEVI8LJNq7C9P3LR03kK2szJDhPzkWPgRyY2YpD2eq1aCJm0bkX9mBWTZdSYFhKt3vuM1Qjp5PWXk0tN5h9dNFqpisihK7XboB81poER2SmnZ8PIslzWu2iULM7VWxmEDA70JKBJFweqLCFBHRszA8Nt3AXF0z5qe61oH1oSUmtPwNhdQQ2G5X3g==";
23 |
24 | //公钥路径(请检查你的公钥 .pem 文件存放路径)
25 | var path = @"D:\workspace\csharpProject\demo\WebApplication1\WebApplication1\key.pem";
26 |
27 | //验证签名
28 | VerifySignedHash(inputData, sig, path);
29 |
30 | var jObject = JObject.Parse(inputData);
31 | var type = jObject.SelectToken("type");
32 | if (type.ToString() == "charge.succeeded" || type.ToString() == "refund.succeeded")
33 | {
34 | // TODO what you need do
35 | Response.StatusCode = 200;
36 | }
37 | else
38 | {
39 | // TODO what you need do
40 | Response.StatusCode = 500;
41 | }
42 |
43 | }
44 |
45 | }
46 |
47 | private static string ReadStream(Stream stream)
48 | {
49 | using (var reader = new StreamReader(stream, Encoding.UTF8))
50 | {
51 | return reader.ReadToEnd();
52 | }
53 | }
54 |
55 |
56 | public static string ReadFileToString(string path)
57 | {
58 | using (StreamReader sr = new StreamReader(path))
59 | {
60 | return sr.ReadToEnd();
61 | }
62 | }
63 |
64 | public static string VerifySignedHash(string strDataToVerify, string strSignedData, string strPublicKeyFilePath)
65 | {
66 | byte[] signedData = Convert.FromBase64String(strSignedData);
67 |
68 | UTF8Encoding ByteConverter = new UTF8Encoding();
69 | byte[] dataToVerify = ByteConverter.GetBytes(strDataToVerify);
70 | try
71 | {
72 | string sPublicKeyPem = File.ReadAllText(strPublicKeyFilePath);
73 | RSACryptoServiceProvider rsa = new RSACryptoServiceProvider {PersistKeyInCsp = false};
74 |
75 | rsa.LoadPublicKeyPEM(sPublicKeyPem);
76 |
77 | if (rsa.VerifyData(dataToVerify, "SHA256", signedData))
78 | {
79 | return "verify success";
80 | }
81 | else
82 | {
83 | return "verify fail";
84 | }
85 |
86 | }
87 | catch (CryptographicException e)
88 | {
89 | Console.WriteLine(e.Message);
90 |
91 | return "verify error";
92 | }
93 |
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/Demo/Webhooks.aspx.designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Demo {
11 |
12 |
13 | public partial class Webhooks {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Example/Entry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Example.Example;
3 | using Example.InAppExample;
4 | using Pingpp;
5 | using Pingpp.Exception;
6 |
7 | namespace Example
8 | {
9 | internal class Entry
10 | {
11 | ///
12 | /// 作为示例的入口,你可以使用示例的配置参数或者更改为你在 Ping++ 注册后从管理平台中获得的配置参数
13 | /// 示例分为 3 类:收款/付款类、用户账户类、应用内支付类,你可以通过取消/增加注释的方式根据你的业务场景选择需要调试的接口
14 | ///
15 | ///
16 | private static void Main(string[] args)
17 | {
18 | try
19 | {
20 | //设置 Api Key, 可换成你自己的 test secret key 或者 live secret key
21 | Pingpp.Pingpp.SetApiKey("sk_test_ibbTe5jLGCi5rzfH4OqPW9KC");
22 |
23 | //设置请求签名密钥,密钥对需要你自己用 openssl 工具生成,同时把配对的公钥填写到 https://dashboard.pingxx.com
24 | Pingpp.Pingpp.SetPrivateKeyPath(@"../../your_rsa_private_key.pem");
25 |
26 | //设置 App Id, 可以换成自己的应用 Id
27 | var appId = "app_1Gqj58ynP0mHeX1q";
28 |
29 | // 收款/付款类相关示例
30 | Examples(appId);
31 |
32 | // 用户账户类相关示例
33 | //AccountExamples(appId);
34 |
35 | // 应用内支付类相关示例
36 | //InAppExamples(appId);
37 | }
38 | catch (PingppException e)
39 | {
40 | Console.WriteLine(e.Message);
41 | Console.ReadKey();
42 | }
43 | Console.ReadKey();
44 | }
45 |
46 | private static void Examples(string appId)
47 | {
48 | ChargeDemo.Example(appId);
49 | AgreementDemo.Example(appId);
50 | RedEnvelopeDemo.Example(appId);
51 | TransferDemo.Example(appId);
52 | VerifyDemo.Example();
53 | WebhooksDemo.Example();
54 | IdentificationDemo.Example(appId);
55 | CustomsDemo.Example(appId, "ch_avbPyT4aDCe1r9W1eHfv1SuP");
56 | CardInfoDemo.Example(appId);
57 | //批量退款示例
58 | BatchRefundDemo.Example(appId);
59 | SplitReceiverDemo.Example(appId);
60 | SplitProfitDemo.Example(appId);
61 | ProfitTransactionDemo.Example(appId);
62 | SubBankDemo.Example(appId);
63 | }
64 |
65 | private static void AccountExamples(string appId)
66 | {
67 | //Order 示例
68 | OrderDemo.Example(appId);
69 | //Order退款示例
70 | OrderRefundDemo.Example("2011708140000074741");
71 | //User 对象相关示例
72 | UserDemo.Example(appId);
73 | //用户余额明细示例
74 | BalanceTransactionDemo.Example(appId);
75 | //转账 示例
76 | TransferDemo.Example(appId);
77 | //余额提现 示例
78 | WithdrawalDemo.Example(appId);
79 | //优惠券 示例
80 | CouponDemo.Example(appId);
81 | //批量转账 示例
82 | BatchTransferDemo.Example(appId);
83 | //批量体现示例
84 | BatchWithdrawalDemo.Example(appId);
85 | //子商户示例
86 | SubAppDemo.Example(appId);
87 | //子商户渠道设置示例
88 | ChannelDemo.Example(appId, "app_jXH8WHCCSGC0GCGu");
89 | //结算账号示例
90 | SettleAccountDemo.Example(appId);
91 | //分润示例
92 | RoyaltyDemo.Example();
93 | //分润结算明细示例
94 | RoyaltyTransactionDemo.Example();
95 | //分润结算示例
96 | RoyaltySettlementDemo.Example();
97 | OrderDemo.Example(appId);
98 | var user = UserDemo.Example(appId);
99 | BalanceDemo.Example(appId);
100 | CouponDemo.Example(appId);
101 | //余额充值接口示例
102 | RechargeDemo.Example(appId);
103 |
104 | //余额赠送示例
105 | BalanceBonusDemo.Example(appId);
106 | //余额转账示例
107 | BalanceTransferDemo.Example(appId);
108 | //分润模板示例
109 | RoyaltyTemplateDemo.Example(appId);
110 | //余额结算对象示例
111 | BalanceSettlementDemo.Example(appId);
112 | }
113 |
114 | private static void InAppExamples(string appId)
115 | {
116 | InAppChargeDemo.Example(appId);
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/Example/Example/AgreementDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class AgreementDemo
9 | {
10 | ///
11 | /// 本示例只介绍如何请求支付凭据(charge 对象),以及如何查询指定 charge 对象和 charge 列表,
12 | /// 至于如何将 charge 对象传递给客户端需要接入者自行处理
13 | ///
14 | public static void Example(string appId)
15 | {
16 |
17 | Console.WriteLine("**** 创建签约示例 ****");
18 | var param = new Dictionary {
19 | {"app", appId},
20 | {"contract_no", randomStr(10)},
21 | {"channel", "qpay"},
22 | {"extra", new Dictionary{
23 | {"display_account", "签约测试"}
24 | }},
25 | {"metadata", new Dictionary{}}
26 | };
27 |
28 | var agreement = Agreement.Create(param);
29 | Console.WriteLine(agreement);
30 | Console.WriteLine();
31 |
32 | Console.WriteLine("****查询 agreement 对象****");
33 | Console.WriteLine(Agreement.Retrieve(agreement.Id));
34 | Console.WriteLine();
35 |
36 | Console.WriteLine("****解除签约 agreement 对象****");
37 | Console.WriteLine(Agreement.Cancel(agreement.Id));
38 | Console.WriteLine();
39 |
40 |
41 | Console.WriteLine("****查询 agreement 列表****");
42 | Dictionary listParams = new Dictionary{
43 | {"app", appId}, // 必填 签约使用的 app id
44 | {"per_page", 10}, //限制有多少对象可以被返回,限制范围是从 1-100 项,默认是 10 项。
45 | };
46 | Console.WriteLine(Agreement.List(listParams));
47 | }
48 |
49 | public static String randomStr(int length)
50 | {
51 | string result = "";
52 | System.Random random = new Random();
53 | for (int i = 0; i < length; i++)
54 | {
55 | result += random.Next(10).ToString();
56 | }
57 | return result;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Example/Example/BalanceBonusDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | internal class BalanceBonusDemo
10 | {
11 | ///
12 | /// 本示例介绍用户余额赠送创建,查询,/查询对象列表
13 | ///
14 | ///
15 | public static void Example(String appId)
16 | {
17 | var createParams = new Dictionary
18 | {
19 | {"amount",10},
20 | {"description", "Your Description"},
21 | {"user", "user_test_02"},
22 | {"order_no", new Random().Next(1, 999999999).ToString()}
23 | };
24 | Console.WriteLine("*** 创建 balance_bonus 对象***");
25 | Console.WriteLine(BalanceBonus.Create(appId, createParams));
26 | Console.WriteLine();
27 |
28 | Console.WriteLine("*** 查询 balance_bonus 对象 ***");
29 | Console.WriteLine(BalanceBonus.Retrieve(appId, "651170811577777244160000"));
30 | Console.WriteLine();
31 |
32 | Console.WriteLine("*** 查询 balance_bonus 对象列表 ***");
33 | Console.WriteLine(BalanceBonus.List(appId, new Dictionary
34 | {
35 | {"page", 1},
36 | {"per_page", 10}
37 | }
38 | ));
39 | Console.WriteLine();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Example/Example/BalanceDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | internal class BalanceDemo
10 | {
11 | ///
12 | ///
13 | /// 本示例介绍对余额提现和查看用户余额明细对象/对象列表
14 | /// 余额的消费、退款请查看 OrderDemo 示例
15 | /// 查看用户当前余额请使用查看 User 对象接口
16 | ///
17 | ///
18 | public static void Example(string appId)
19 | {
20 | var uid = "test_user_001";
21 | var orParams = new Dictionary
22 | {
23 | {"app", appId},
24 | {"uid", uid},
25 | {"merchant_order_no", new Random().Next(1, 999999999)},
26 | {"channel", "wx"}, // 充值接口需要设置支付渠道
27 | {"amount", 1},
28 | {"currency", "cny"},
29 | {"client_ip", "127.0.0.1"},
30 | {"subject", "Your Subject"},
31 | {"body", "Your Body"},
32 | {"description", "Your description"},
33 | };
34 |
35 | var wdParams = new Dictionary
36 | {
37 | {"amount", 1},
38 | {"order_no", "20160829133002"},
39 | {"description", "withdraw request"},
40 | {"extra", new Dictionary
41 | {
42 | {"card_number", "6225210207073918"},
43 | {"user_name", "姓名"},
44 | {"open_bank_code", "0102"},
45 | {"prov", "上海"},
46 | {"city", "上海"}
47 | }
48 | },
49 | };
50 | Console.WriteLine("****创建提现 Withdrawal 对象(发起提现申请)****");
51 | var wd = Withdrawal.Request(appId, wdParams);
52 | Console.WriteLine(wd);
53 | Console.WriteLine();
54 |
55 | Console.WriteLine("****提现完成 Withdrawal 对象****");
56 | Console.WriteLine(Withdrawal.Confirm(appId, wd.Id));
57 | Console.WriteLine();
58 |
59 | Console.WriteLine("****查看用户交易明细 Balance Transaction 对象列表****");
60 | var balanceList = BalanceTransaction.List(appId);
61 | Console.WriteLine(balanceList);
62 | Console.WriteLine();
63 |
64 | Console.WriteLine("****查看用户交易明细 Balance Transaction 对象****");
65 | Console.WriteLine(BalanceTransaction.Retrieve(appId, balanceList.Data.First().Id));
66 | Console.WriteLine();
67 |
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Example/Example/BalanceSettlementDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Pingpp;
6 | using Pingpp.Models;
7 |
8 | namespace Example.Example
9 | {
10 | internal class BalanceSettlementDemo
11 | {
12 | ///
13 | /// 本示例展示 余额结算 查询列表,明细
14 | ///
15 | ///
16 | public static void Example(string appId)
17 | {
18 | Console.WriteLine("****查询批量转账明细 balance_settlement 对象****");
19 | Console.WriteLine(BalanceSettlement.Retrieve(appId, "670180228410834298880001"));
20 | Console.WriteLine();
21 |
22 | var listParams = new Dictionary
23 | {
24 | {"page", 1}, //页码,取值范围:1~1000000000;默认值为"1"
25 | {"per_page", 10}, //每页数量,取值范围:1~100;默认值为"10",
26 | };
27 |
28 | Console.WriteLine("****查询余额结算 balance_settlement 对象列表****");
29 | Console.WriteLine(BalanceSettlement.List(appId, listParams));
30 | Console.WriteLine();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Example/Example/BalanceTransactionDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | internal class BalanceTransactionDemo
10 | {
11 | ///
12 | /// 本示例展示 用户账户交易明细 查询列表,明细
13 | ///
14 | ///
15 | public static void Example(string appId)
16 | {
17 | var listParams = new Dictionary
18 | {
19 | {"page", 1},
20 | {"per_page", 10},
21 | };
22 |
23 | var list = BalanceTransaction.List(appId, listParams);
24 | Console.WriteLine("****查询 balance_transactions 列表****");
25 | Console.WriteLine(list);
26 | Console.WriteLine();
27 |
28 |
29 | Console.WriteLine("****查询 balance_transactions 明细****");
30 | Console.WriteLine(BalanceTransaction.Retrieve(appId, "310217032213081700008201"));
31 | Console.WriteLine();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Example/Example/BalanceTransferDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | internal class BalanceTransferDemo
10 | {
11 | ///
12 | /// 本示例介绍用户余额转账创建,查询,/查询对象列表
13 | ///
14 | public static void Example(string appId)
15 | {
16 | var createParams = new Dictionary
17 | {
18 | {"amount",10}, //用户收到转账的余额,单位:分
19 | {"user_fee", 0}, //向发起转账的用户额外收取的手续费,单位:分
20 | {"user", "user_test_01"}, //发起转账的用户 ID(可以是 customer 或 business,但不能填 0)
21 | {"recipient", "user_test_02"}, //接收转账的用户 ID(可以是 customer 或 business,可以为 0)
22 | {"order_no", new Random().Next(1, 999999999).ToString()}, //商户订单号,必须在商户系统内唯一
23 | {"description", "Your Description"}, // 描述
24 | {"metadata", new Dictionary{}} //metadata 元数据
25 | };
26 | var balanceTransfer = BalanceTransfer.Create(appId, createParams);
27 | Console.WriteLine("*** 创建 balance_transfer 对象***");
28 | Console.WriteLine(balanceTransfer);
29 | Console.WriteLine();
30 |
31 | Console.WriteLine("*** 查询 balance_transfer 对象 ***");
32 | Console.WriteLine(BalanceTransfer.Retrieve(appId, balanceTransfer.Id));
33 | Console.WriteLine();
34 |
35 | Console.WriteLine("*** 查询 balance_transfer 对象列表 ***");
36 | Console.WriteLine(BalanceTransfer.List(appId, new Dictionary
37 | {
38 | {"page", 1},
39 | {"per_page", 10}
40 | }
41 | ));
42 | Console.WriteLine();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Example/Example/BatchRefundDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | internal class BatchRefundDemo
10 | {
11 | ///
12 | /// 本示例介绍批量Batch Refunds 批量退款创建,查询对象,查询对象列表
13 | ///
14 | ///
15 | public static void Example(string appId)
16 | {
17 | var reParams = new Dictionary
18 | {
19 | {"app", appId},
20 | //批量退款批次号,3-24位,允许字母和英文
21 | {"batch_no", "batchrefund2016113"},
22 | //需要退款的 charge id 列表,一次最多 100 个
23 | {"charges", new List
24 | {
25 | "ch_fn1WXHDur5qPvfffbL1uXnv9",
26 | "ch_1OmvXTzr9WnPPKuf50iH4aP0"
27 | }
28 | },
29 | //批量退款详情,最多 255 个 Unicode 字符
30 | {"description", "Batch refund description."},
31 | {"metadata", null}
32 | };
33 |
34 | var batchRefund = BatchRefund.Create(reParams);
35 | Console.WriteLine("****创建批量退款 Batch Refund 对象****");
36 | Console.WriteLine(batchRefund);
37 | Console.WriteLine();
38 |
39 | Console.WriteLine("****查询 Batch refund 对象****");
40 | Console.WriteLine(BatchRefund.Retrieve(batchRefund.Id));
41 | Console.WriteLine();
42 |
43 | Console.WriteLine("****查询 Batch refund 对象列表****");
44 | var listParams = new Dictionary
45 | {
46 | {"app", appId}, //批量退款对应的 app 对象 ID,如何获取App ID请查看: https://help.pingxx.com/article/198599/
47 | {"page", 1}, //页码,取值范围:1~1000000000;默认值为"1"
48 | {"per_page", 10} //每页数量,取值范围:1~100;默认值为"10"
49 | };
50 | Console.WriteLine(BatchRefund.List(listParams));
51 | Console.WriteLine();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Example/Example/BatchWithdrawalDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Pingpp;
6 | using Pingpp.Models;
7 |
8 | namespace Example.Example
9 | {
10 | internal class BatchWithdrawalDemo
11 | {
12 | public static void Example(string appId)
13 | {
14 | var batchwrParams = new Dictionary
15 | {
16 | {"withdrawals", new List{
17 | "1701611150302360654",
18 | "1701611151015078981"}}
19 | };
20 | var batchWithDrawal = BatchWithdrawal.Create(appId, batchwrParams);
21 | Console.WriteLine("****创建批量提现确认 batch_withdrawals 对象****");
22 | Console.WriteLine(batchWithDrawal);
23 | Console.WriteLine();
24 |
25 | Console.WriteLine("****查询批量提现确认 batch_withdrawals 对象****");
26 | Console.WriteLine(BatchWithdrawal.Retrieve(appId, "1911612011126056780"));
27 | Console.WriteLine();
28 |
29 | //status 参数可选:提现状态,已申请:created,处理中:pending,完成:succeeded,失败:failed,取消:canceled
30 | var listParams = new Dictionary
31 | {
32 | {"page", 1},
33 | {"per_page", 15},
34 | {"status","created"}
35 | };
36 | Console.WriteLine("****批量提现列表查询****");
37 | Console.WriteLine(BatchWithdrawal.List(appId, listParams));
38 | Console.WriteLine();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Example/Example/CardInfoDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Pingpp;
3 | using Pingpp.Models;
4 | using System.Collections.Generic;
5 |
6 | namespace Example.Example
7 | {
8 | internal class CardInfoDemo
9 | {
10 | ///
11 | /// 本示例介绍银行卡信息查询
12 | ///
13 | ///
14 | public static void Example(String appId)
15 | {
16 | var createParams = new Dictionary
17 | {
18 | {"app",appId},
19 | {"bank_account", "6214888888888888"}
20 | };
21 |
22 | Console.WriteLine("**** 银行卡信息查询 ****");
23 | Console.WriteLine(CardInfo.Query(createParams));
24 | Console.WriteLine();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Example/Example/ChannelDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 |
8 | namespace Example.Example
9 | {
10 | ///
11 | /// 本示例介绍子商户应用支付渠道创建,更新,查询,删除
12 | ///
13 | class ChannelDemo
14 | {
15 | public static void Example(string appId, string subAppId)
16 | {
17 | Console.WriteLine("**** 创建sub_app channel 对象 ****");
18 | var param = new Dictionary {
19 | {"channel", "bfb"},
20 | {"banned", false},
21 | {"banned_msg", null},
22 | {"description", "The description for bfb"},
23 | {"params", new Dictionary{
24 | {"bfb_sp", "百度钱包合作密钥"},
25 | {"fee_rate", 30},
26 | {"bfb_key", "百度钱包合作密钥"}
27 | }}
28 |
29 | };
30 | Console.WriteLine(SubAppChannel.Create(appId, subAppId, param));
31 | Console.WriteLine();
32 |
33 | Console.WriteLine("****查询 sub_app channel ****");
34 | Console.WriteLine(SubAppChannel.Retrieve(appId, subAppId, "bfb"));
35 | Console.WriteLine();
36 |
37 | Console.WriteLine("**** 更新sub_app channel 对象 ****");
38 | var upParam = new Dictionary {
39 | {"banned", false},
40 | {"banned_msg", null},
41 | {"description", "The new description for bfb"},
42 | {"params", new Dictionary{
43 | {"bfb_sp", "百度钱包合作密钥"},
44 | {"fee_rate", 35},
45 | {"bfb_key", "百度钱包合作密钥"}
46 | }}
47 |
48 | };
49 | Console.WriteLine(SubAppChannel.Update(appId, subAppId, "bfb", upParam));
50 | Console.WriteLine();
51 |
52 | Console.WriteLine("**** 删除sub_app channel 对象 ****");
53 | Console.WriteLine(SubAppChannel.Delete(appId, subAppId, "bfb"));
54 | Console.WriteLine();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Example/Example/CouponDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Pingpp;
6 | using Pingpp.Models;
7 |
8 | namespace Example.Example
9 | {
10 | internal class CouponDemo
11 | {
12 | ///
13 | ///
14 | /// 本示例介绍优惠券模板创建、更新、删除;优惠券创建、批量创建、删除、查询、用户下列表查询、模板下列表查询
15 | /// 优惠券使用请查看 OrderDemo 示例
16 | /// 查看用户当前可用优惠券数量请使用查看 User 对象接口
17 | ///
18 | ///
19 | public static void Example(string appId)
20 | {
21 | var couTmplParams = new Dictionary
22 | {
23 | {"name", "20-percent-off"},
24 | {"type", 2}, // 1:现金券 2:折扣券
25 | {"percent_off", 20},
26 | {"amount_available", 50000}, // 满减属性:满 500 可用
27 | {"max_circulation", 100}, // 优惠券最大生成数量
28 | {"max_user_circulation", 2}, //单个用户优惠券最大生成数量,当已生成数量达到最大值时,不能再生成优惠券,删除优惠券不会影响该值;取值范围为 1 - 100,默认值为 1。
29 | {"expiration", new Dictionary
30 | {
31 | {"duration", 604800}
32 | }
33 | }
34 | };
35 |
36 | var couTmpl = CouponTemplate.Create(appId, couTmplParams);
37 | Console.WriteLine("****创建 Coupon Template 对象****");
38 | Console.WriteLine(couTmpl);
39 | Console.WriteLine();
40 |
41 | Console.WriteLine("****查询 Coupon Template 对象****");
42 | Console.WriteLine(CouponTemplate.Retrieve(appId, couTmpl.Id));
43 | Console.WriteLine();
44 |
45 | Console.WriteLine("****查询 Coupon Template 对象列表****");
46 | Console.WriteLine(CouponTemplate.List(appId));
47 | Console.WriteLine();
48 |
49 | Console.WriteLine("****查询 Coupon Template 对象的优惠券列表****");
50 | Console.WriteLine(CouponTemplate.List(appId));
51 | Console.WriteLine();
52 |
53 | Console.WriteLine("****更新 Coupon Template 对象****");
54 | Console.WriteLine(CouponTemplate.Update(appId, couTmpl.Id, new Dictionary { { "metadata", new Dictionary { { "品类", "数码家电类" } } } }));
55 | Console.WriteLine();
56 |
57 | Console.WriteLine("****删除 Coupon Template 对象****");
58 | Console.WriteLine(CouponTemplate.Delete(appId, couTmpl.Id));
59 | Console.WriteLine();
60 |
61 | var uid = "test_user_001";
62 | var uid2 = "test_user_002";
63 | var uid3 = "test_user_003";
64 | var cou = Coupon.Create(appId, uid, new Dictionary { { "coupon_template", couTmpl.Id } });
65 | Console.WriteLine("****创建 Coupon Template 对象****");
66 | Console.WriteLine(cou);
67 | Console.WriteLine();
68 |
69 | Console.WriteLine("****批量创建 Coupon 对象****");
70 | Console.WriteLine(Coupon.BatchCreate(appId, couTmpl.Id, new Dictionary { { "users", new ArrayList() { uid2, uid3 } } }));
71 | Console.WriteLine();
72 |
73 | Console.WriteLine("****更新 Coupon 对象****");
74 | Console.WriteLine(Coupon.Update(appId, uid, cou.Id, new Dictionary { { "metadata", new Dictionary { { "xxx", "xxx" } } } }));
75 | Console.WriteLine();
76 |
77 | Console.WriteLine("****查询 Coupon 对象****");
78 | Console.WriteLine(Coupon.Retrieve(appId, uid, cou.Id));
79 | Console.WriteLine();
80 |
81 | Console.WriteLine("****查询用户的 Coupon 对象列表****");
82 | Console.WriteLine(Coupon.List(appId, uid));
83 | Console.WriteLine();
84 |
85 | Console.WriteLine("****查询模板下的 Coupon 对象列表****");
86 | Console.WriteLine(Coupon.ListInTemplate(appId, cou.Id));
87 | Console.WriteLine();
88 |
89 | Console.WriteLine("****删除 Coupon 对象****");
90 | Console.WriteLine(Coupon.Delete(appId, uid, cou.Id));
91 | Console.WriteLine();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Example/Example/CustomsDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class CustomsDemo
9 | {
10 | ///
11 | /// 本示例介绍如何进行海关报关
12 | ///
13 | public static void Example(string appId, string chId)
14 | {
15 | var cuParams = new Dictionary
16 | {
17 | {"app", appId},
18 | {"charge", chId},
19 | {"channel", "upacp_pc"},
20 | {"trade_no", new Random().Next(1, 999999999).ToString()},
21 | {"customs_code", "GUANGZHOU"},
22 | {"amount", 1},
23 | {"is_split", true},
24 | {"sub_order_no", new Random().Next(1, 999999).ToString()},
25 | {"extra", new Dictionary{
26 | {"pay_account", "123456"},
27 | {"certif_type", "02"},
28 | {"customer_name", "customer name"},
29 | {"certif_id", "62148502"},
30 | {"tax_amount", 10}
31 | }}
32 | };
33 |
34 | Console.WriteLine("****发起海关报关请求****");
35 | var cu = Customs.Create(cuParams);
36 | Console.WriteLine(cu);
37 | Console.WriteLine();
38 |
39 |
40 | Console.WriteLine("****查询海关报关对象****");
41 | Console.WriteLine(Customs.Retrieve(cu.Id));
42 | Console.WriteLine();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Example/Example/EventDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | public class EventDemo
9 | {
10 | public static Event Example()
11 | {
12 | //查询指定的 event
13 | var evt = Event.Retrieve("evt_sATiFAMSU7Loda9uCWKUxmgo");
14 | Console.WriteLine("****查询指定 Event 对象****");
15 | Console.WriteLine(evt);
16 | Console.WriteLine();
17 |
18 | return evt;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Example/Example/IdentificationDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class IdentificationDemo
9 | {
10 | ///
11 | /// 本示例介绍如何进行身份认证
12 | ///
13 | public static void Example(string appId)
14 | {
15 | var iParams = new Dictionary
16 | {
17 | {"type", "bank_card"},
18 | {"app", appId},
19 | {"data", new Dictionary
20 | {
21 | {"id_name", "张三"}, // 姓名
22 | {"id_number", "310181198910107641"}, // 身份证号
23 | {"card_number", "6201111122223333"}, // 银行卡号
24 | {"phone_number", "18623234545"} // 银行预留手机号,不支持 178 号段
25 | }
26 | }
27 | };
28 |
29 | Console.WriteLine("****发起身份认证请求****");
30 | Console.WriteLine(Identification.Identify(iParams));
31 | Console.WriteLine();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Example/Example/OrderDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp.Models;
4 |
5 | namespace Example.Example
6 | {
7 | internal class OrderDemo
8 | {
9 | ///
10 | /// 本示例只介绍如何创建订单(Order 对象)、支付订单、取消订单以及如何查询指定 Order 对象和 Order 列表,
11 | /// 至于如何将 Order 对象传递给客户端需要接入者自行处理
12 | ///
13 | public static void Example(string appId)
14 | {
15 | var orParams = new Dictionary
16 | {
17 | {"app", appId},
18 | {"uid", "test_user_001"}, //uid为可选参数
19 | {"merchant_order_no", new Random().Next(1, 999999999).ToString()},
20 | {"amount", 10},
21 | {"currency", "cny"},
22 | {"client_ip", "127.0.0.1"},
23 | {"subject", "Your Subject"},
24 | {"body", "Your Body"},
25 | {"description", "Your description"},
26 | {"coupon", "300317040115550700088888"},
27 | {"receipt_app", appId}, //收款方应用
28 | {"service_app", appId}, //服务方应用
29 | {"royalty_users", new List>{ //分润的用户列表,默认为 [],不分润
30 | new Dictionary{
31 | {"user", "user_001"},
32 | {"amount",1}
33 | },
34 | new Dictionary{
35 | {"user", "user_002"},
36 | {"amount",1}
37 | }
38 | }},
39 | // 余额结算信息,支付成功时,将支付金额(扣除用户手续费后)自动结算到指定用户余额账户。仅对开通了 balance 渠道的应用有效。
40 | // {"balance_settlement", new Dictionary{
41 | // {"user", "user_001"},
42 | // {"user_fee", 0}
43 | // }}
44 | };
45 |
46 | var or = Order.Create(orParams);
47 | Console.WriteLine("****创建 Order 对象****");
48 | Console.WriteLine(or);
49 | Console.WriteLine();
50 | Console.WriteLine("****支付指定 Order 对象****");
51 | Console.WriteLine(Order.Pay(or.Id, new Dictionary {
52 | { "charge_amount",10},
53 | { "channel", "alipay" },
54 | {"charge_order_no", "20170808100000001"}
55 | }));
56 | Console.WriteLine();
57 | Console.WriteLine("****查询指定 Order 对象****");
58 | Console.WriteLine(Order.Retrieve(or.Id));
59 | Console.WriteLine();
60 | Console.WriteLine("***查询指定 Order Charge列表***");
61 | Console.WriteLine(Order.ChargeList(or.Id));
62 | Console.WriteLine();
63 | Console.WriteLine("***查询指定 Order Charge对象***");
64 | Console.WriteLine(Order.ChargeRetrieve("2011708140000074741", "ch_OanvTSaPOqjDT00CWLbfz54C"));
65 | Console.WriteLine();
66 |
67 | Console.WriteLine("****取消指定 Order 对象****");
68 | Console.WriteLine(Order.Cancel(or.Id, new Dictionary {
69 | {"user", or.Uid}
70 | }));
71 | Console.WriteLine();
72 |
73 | Console.WriteLine("****查询 Order 列表****");
74 | Console.WriteLine(Order.List(new Dictionary
75 | {
76 | {"app", appId},
77 | {"paid", true}
78 | }));
79 | Console.WriteLine();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Example/Example/OrderRefundDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp.Models;
4 |
5 | namespace Example.Example
6 | {
7 | public class OrderRefundDemo
8 | {
9 | ///
10 | /// 本示例介绍如何发起 Order 退款,以及如何查询指定 Order Refund 对象和 Refund 列表,
11 | ///
12 | public static void Example(string orId)
13 | {
14 | var reParams = new Dictionary
15 | {
16 | {"description", "Refund Reason"},
17 | {"refund_mode", "to_source"}, //退款模式。原路退回:to_source,退至余额:to_balance。默认为原路返回。
18 | //{"royalty_users", new List>{ //退分润的用户列表,默认为 [],不分润
19 | // new Dictionary{
20 | // {"user", "user_001"},
21 | // {"amount_refunded",1}
22 | // },
23 | // new Dictionary{
24 | // {"user", "user_002"},
25 | // {"amount_refunded",1}
26 | // }
27 | // }},
28 | };
29 |
30 | var re = OrderRefund.Create(orId, reParams);
31 | Console.WriteLine("****创建 order refund 对象****");
32 | Console.WriteLine(re);
33 | Console.WriteLine();
34 |
35 | Console.WriteLine("****查询指定 order refund 对象****");
36 | Console.WriteLine(OrderRefund.Retrieve(orId, "re_vjz1a1DCufb5n9erLK48SGC0"));
37 | Console.WriteLine();
38 |
39 | Console.WriteLine("****查询 order refund 列表****");
40 | Console.WriteLine(OrderRefund.List(orId));
41 | Console.WriteLine();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Example/Example/ProfitTransactionDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class ProfitTransactionDemo
9 | {
10 | public static void Example(string appId)
11 | {
12 | Console.WriteLine("****查询 profit_transaction 列表****");
13 | Dictionary listParams = new Dictionary {
14 | {"app", appId},
15 | {"page", 1}
16 | };
17 | Console.WriteLine(ProfitTransaction.List(listParams));
18 | Console.WriteLine();
19 |
20 | Console.WriteLine("****查询 profit_transaction ****");
21 | Console.WriteLine(ProfitTransaction.Retrieve("ptxn_1m3xtoBMRqu2qC"));
22 | Console.WriteLine();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Example/Example/RechargeDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | ///
10 | /// recharge 示例
11 | ///
12 | internal class RechargeDemo
13 | {
14 | public static void Example(string appId)
15 | {
16 | var createParams = new Dictionary
17 | {
18 | {"user", "user_test_01"}, //充值目标用户 ID。
19 | //{"user_fee", 0}, // 用户充值收取的手续费,单位分,不得大于 amount,不可和 balance_bonus[amount] 同时传,默认 0。
20 | {"description", "Your Recharge description"}, //描述。
21 | {"metadata", new Dictionary{}},
22 | {"balance_bonus", new Dictionary{
23 | {"amount",100} //充值额外赠送的余额,单位分,不可和 user_fee 同时传,默认 0。
24 | }},
25 | {"charge", new Dictionary{
26 | {"amount", 100}, //用户实际支付金额,单位分。
27 | {"channel", "alipay_qr"}, //支付使用的第三方支付渠道。
28 | {"order_no", new Random().Next(1, 999999999).ToString()}, //商户订单号,适配每个渠道对此参数的要求,必须在商户系统内唯一。
29 | {"subject", "Your subject"}, //充值标题,该参数最长为 32 个 Unicode 字符。银联全渠道( upacp / upacp_wap / upacp_pc)限制在 32 个字节。
30 | {"body", "Your body"}, //充值描述信息,该参数最长为 128 个 Unicode 字符,yeepay_wap 对于该参数长度限制为 100 个 Unicode 字符。
31 | {"time_expire", "1502766839"}, //支付失效时间,用 Unix 时间戳表示。时间范围在支付创建后的 5 分钟到 1 天,默认为 1 天,创建时间以 Ping++ 服务器时间为准。 微信对该参数的有效值限制为 2 小时内;银联对该参数的有效值限制为 1 小时内。
32 | {"client_ip", "127.0.0.1"}, //客户端的 IP,IPv4,默认 127.0.0.1。
33 | {"extra", new Dictionary{ }},
34 | }}
35 | };
36 |
37 | var recharge = Recharge.Create(appId, createParams);
38 | Console.WriteLine("****创建充值 Recharge 对象****");
39 | Console.WriteLine(recharge);
40 | Console.WriteLine();
41 |
42 | Console.WriteLine("**** 查询充值Recharge对象 ****");
43 | Console.WriteLine(Recharge.Retrieve(appId, "221170814443320238080000"));
44 | Console.WriteLine();
45 |
46 | Console.WriteLine("**** 查询充值Recharge对象列表 ****");
47 | Console.WriteLine(Recharge.List(appId, new Dictionary
48 | {
49 | {"page", 1},
50 | {"per_page", 10}
51 | }));
52 | Console.WriteLine();
53 |
54 |
55 | Console.WriteLine("**** 创建充值退款 ****");
56 | Console.WriteLine(RechargeRefund.Create(appId, "221170814443320238080000", new Dictionary
57 | {
58 | {"description", "Your Description"},
59 | {"metadata", new Dictionary{}}
60 | }));
61 |
62 |
63 | Console.WriteLine("**** 查询充值退款对象 ****");
64 | Console.WriteLine(RechargeRefund.Retrieve(appId, "221170814443320238080000", "re_Cuvnn9nnb104W5ebf9LevHOS"));
65 | Console.WriteLine();
66 |
67 | Console.WriteLine("**** 查询充值退款列表 ****");
68 | Console.WriteLine(RechargeRefund.List(appId, "221170814443320238080000"));
69 | Console.WriteLine();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Example/Example/RedEnvelopeDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp.Models;
4 |
5 | namespace Example.Example
6 | {
7 | internal class RedEnvelopeDemo
8 | {
9 | ///
10 | ///本示例只介绍如何发送红包请求,以及如何查询指定 RedEnvelope 对象和 RedEnvelope 列表,
11 | ///获取到了 RedEnvelope 对象后,不需要客户端做任何处理,指定的用户会在微信客户端收到红包消息
12 | ///
13 | public static RedEnvelope Example(string appId)
14 | {
15 | var redParams = new Dictionary
16 | {
17 | {"order_no", new Random().Next(1, 999999999)},
18 | {"amount", 100},
19 | {"channel", "wx_pub"},
20 | {"currency", "cny"},
21 | {"subject", "Your Subject"},
22 | {"body", "Your Body"},
23 | {"recipient", "Your Recipient Id"},
24 | {"description", "Description"},
25 | {"extra", new Dictionary {{"nick_name", "nick name"}, {"send_name", "send name"}}},
26 | {"app", new Dictionary {{"id", appId}}}
27 | };
28 |
29 | var red = RedEnvelope.Create(redParams);
30 | Console.WriteLine("****创建 RedEnvelope 对象****");
31 | Console.WriteLine(red);
32 | Console.WriteLine();
33 |
34 |
35 | Console.WriteLine("****查询指定 RedEnvelope 对象****");
36 | Console.WriteLine(RedEnvelope.Retrieve(red.Id));
37 | Console.WriteLine();
38 |
39 | Console.WriteLine("****查询 RedEnvelope 对象列表****");
40 | Console.WriteLine(RedEnvelope.List(new Dictionary {{"limit", 3}}));
41 | Console.WriteLine();
42 |
43 | return red;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Example/Example/RefundDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | public class RefundDemo
9 | {
10 | ///
11 | /// 本示例介绍如何发起退款,以及如何查询指定 Refund 对象和 Refund 列表
12 | ///
13 | public static Refund Example(string chId)
14 | {
15 | //退款请求参数,这里只列出必填参数,可选参数请参考 https://pingxx.com/document/api#api-r-new
16 | var reParams = new Dictionary
17 | {
18 | // 退款的金额, 单位为对应币种的最小货币单位,例如:人民币为分(如退款金额为 1 元,此处请填 100)。必须小于等于可退款金额,默认为全额退款
19 | {"amount", 100},
20 | {"description", "Refund Reason"}
21 | };
22 |
23 | var re = Refund.Create(chId, reParams);
24 | Console.WriteLine("****发起交易请求创建 refund 对象****");
25 | Console.WriteLine(re);
26 | Console.WriteLine();
27 |
28 | Console.WriteLine("****查询指定 refund 对象****");
29 | Console.WriteLine(Refund.Retrieve(chId, re.Id));
30 | Console.WriteLine();
31 |
32 | Console.WriteLine("****查询 refund 列表****");
33 | Console.WriteLine(Refund.List(chId, new Dictionary {{"limit", 3}}));
34 | Console.WriteLine();
35 |
36 | return re;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Example/Example/RoyaltyDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | ///
10 | /// 本示例介绍分润对象批量更新、查询、查询列表接口
11 | ///
12 | class RoyaltyDemo
13 | {
14 | public static void Example()
15 | {
16 | Console.WriteLine("**** 查询royalty 对象 ****");
17 | var listParams = new Dictionary{
18 | {"payer_app", "app_LibTW1n1SOq9Pin1"},
19 | {"source_app","app_LibTW1n1SOq9Pin1"},
20 | {"status", "created"}, //分润状态
21 | {"page", 1},
22 | {"per_page", 1}
23 | };
24 | Console.WriteLine(Royalty.List(listParams));
25 |
26 |
27 | Console.WriteLine("**** 查询royalty 列表 ****");
28 | Console.WriteLine(Royalty.Retrieve("421170321093600003"));
29 | Console.WriteLine();
30 |
31 | Console.WriteLine("**** 批量更新 royalty ****");
32 | var updateParam = new Dictionary {
33 | {"ids", new List{
34 | "170301124238000111",
35 | "170301124238000211"
36 | }},
37 | {"method", "manual"},
38 | {"description", "Your description"}
39 | };
40 | Console.WriteLine(Royalty.Update(updateParam));
41 | Console.WriteLine();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Example/Example/RoyaltySettlementDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | ///
10 | /// 本示例介绍分润结算对象创建、查询、更新、查询列表
11 | ///
12 | public class RoyaltySettlementDemo
13 | {
14 | public static void Example()
15 | {
16 | var createParam = new Dictionary {
17 | {"payer_app", "app_LibTW1n1SOq9Pin1"}, //分润发起方所在应用的 id
18 | {"method", "alipay"}, //分润的方式,余额 balance 或渠道名称,例如 alipay
19 | {"recipient_app", "app_1Gqj58ynP0mHeX1q"},//分润接收方的应用 id,即分润用户关联的应用 id。
20 | {"created", new Dictionary{
21 | {"gt" , 1488211200},
22 | {"lte" , 1488297600}
23 | }},
24 | //{"source_user", "user_001"}, //按分润用户
25 | //{"source_no", "2017080088888"}, // 关联对象的商户订单号
26 | //{"min_amount", 1000}, //最小分润金额,汇总后金额小于最小分润金额时不会进入分润
27 | {"metadata", new Dictionary{}}, //Metadata
28 | {"is_preview", false} ,//是否预览,选择预览不会真实创建分润结算对象,也不会修改分润对象的状态
29 | };
30 | Console.WriteLine("**** 创建royalty_settlement 对象 ****");
31 | Console.WriteLine(RoyaltySettlement.Create(createParam));
32 | Console.WriteLine();
33 |
34 | Console.WriteLine("**** 查询royalty_settlement 对象 ****");
35 | Console.WriteLine(RoyaltySettlement.Retrieve("431170321101800001"));
36 | Console.WriteLine();
37 |
38 | var updateParam = new Dictionary {
39 | {"status", "canceled"}
40 | };
41 | Console.WriteLine("**** 更新royalty_settlement 对象 ****");
42 | Console.WriteLine(RoyaltySettlement.Update("431170321101800001", updateParam));
43 | Console.WriteLine();
44 |
45 | var listParam = new Dictionary {
46 | {"payer_app", "app_LibTW1n1SOq9Pin1"}
47 | };
48 | Console.WriteLine("**** 查询royalty_settlement 对象列表 ****");
49 | Console.WriteLine(RoyaltySettlement.List(listParam));
50 | Console.WriteLine();
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Example/Example/RoyaltyTemplateDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | internal class RoyaltyTemplateDemo
10 | {
11 | ///
12 | /// 本示例介绍分润模板`创建,查询,删除,查询对象列表
13 | ///
14 | public static void Example(string appId)
15 | {
16 | var createParams = new Dictionary
17 | {
18 | {"app", appId},
19 | {"name", "Your Royalty Template Name"}, //模板名称,允许中英文等常用字符
20 | {"rule", new Dictionary{
21 | {"royalty_mode","rate"}, //分润模式。分为按订单金额(包含优惠券金额)的比例 rate 和固定金额 fixed
22 | {"refund_mode", "full_refund"}, //退分润模式。分为退款时不退分润 no_refund、按比例退分润 proportional 和一旦退款分润全退 full_refund
23 | {"allocation_mode", "receipt_reserved"}, //分配模式。指当订单确定的层级如果少于模板配置层级时,模板中多余的分润金额是归属于收款方 receipt_reserved 还是服务方 service_reserved。
24 | {"data", new List>{
25 | new Dictionary{
26 | {"level", 1}, //子商户层级值,0 表示平台, 1 表示一级子商户,取值范围 >=0
27 | {"value", 20} //分润数值。rate 下取值为 0 - 10000,单位为 0.01 %,fixed 下取值为 0 - 1000000,单位为分
28 | },
29 | new Dictionary{
30 | {"level", 2},
31 | {"value", 10}
32 | }
33 | }}
34 | }}
35 | };
36 | Console.WriteLine("**** 创建分润模板 ****");
37 | Console.WriteLine(RoyaltyTemplate.Create(createParams));
38 |
39 | Console.WriteLine("**** 查询分润模板列表 ****");
40 | Console.WriteLine(RoyaltyTemplate.List(new Dictionary {
41 | {"page", 1},
42 | {"per_page",10}
43 | }));
44 |
45 | Console.WriteLine("**** 查询分润模板 ****");
46 | Console.WriteLine(RoyaltyTemplate.Retrieve("451170814105500001"));
47 |
48 | var updateParams = new Dictionary
49 | {
50 | {"name", "Your New Royalty Template Name"},
51 | {"rule", new Dictionary{
52 | {"royalty_mode","fixed"},
53 | {"refund_mode", "no_refund"},
54 | {"allocation_mode", "service_reserved"},
55 | {"data", new List>{
56 | new Dictionary{
57 | {"level", 1},
58 | {"value", 21}
59 | },
60 | new Dictionary{
61 | {"level", 2},
62 | {"value", 11}
63 | }
64 | }}
65 | }}
66 | };
67 | Console.WriteLine("**** 更新分润模板 ****");
68 | Console.WriteLine(RoyaltyTemplate.Update("451170814105500001", updateParams));
69 | Console.WriteLine("**** 删除分润模板 ****");
70 | Console.WriteLine(RoyaltyTemplate.Delete("451170814105500001"));
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Example/Example/RoyaltyTransactionDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 |
8 | namespace Example.Example
9 | {
10 | ///
11 | /// 本示例介绍查询分润结算明细对象列表查询和列表查询接口
12 | ///
13 | class RoyaltyTransactionDemo
14 | {
15 | public static void Example()
16 | {
17 |
18 | var listParam = new Dictionary {
19 | {"page", 1},
20 | {"per_page", 10}
21 | };
22 | Console.WriteLine("**** 查询royalty_transaction 对象 ****");
23 | Console.WriteLine(RoyaltyTransaction.List(listParam));
24 |
25 | Console.WriteLine("**** 查询royalty_transaction 列表 ****");
26 | Console.WriteLine(RoyaltyTransaction.Retrieve("441170321101800003"));
27 | Console.WriteLine();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Example/Example/SettleAccountDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 |
8 | namespace Example.Example
9 | {
10 | ///
11 | /// 本示例介绍结算账号创建、查询、删除、查询列表
12 | ///
13 | class SettleAccountDemo
14 | {
15 | public static void Example(string appId)
16 | {
17 | Console.WriteLine("****查询 settle_account 列表****");
18 | Console.WriteLine(SettleAccount.List(appId, "test_user_002"));
19 | Console.WriteLine();
20 |
21 |
22 | var paramBankAccount = new Dictionary {
23 | {"channel","bank_account"},
24 | {"recipient", new Dictionary{
25 | {"account", "6214666666666666"}, //接收者银行卡账号。
26 | {"name", "张三"}, //接收者姓名。
27 | {"type", "b2c"}, //转账类型。b2c:企业向个人付款,b2b:企业向企业付款。
28 | {"open_bank", "招商银行"}, //开户银行。
29 | {"open_bank_code", "0308"}, //业务代码,根据通联业务人员提供,不填使用通联提供默认值 09900。
30 | {"business_code","09900"}, //业务代码,根据通联业务人员提供,不填使用通联提供默认值 09900。
31 | {"card_type", 0}, //银行卡号类型,0:银行卡;1:存折。
32 | {"prov", "上海市"}, //开户银行所在省份。
33 | {"city", "上海市"}, //开户银行所在城市。
34 | {"term_type", "07"}, //代付业务使用场景, 07: 互联网, 08: 移动端。
35 | {"sub_bank", "陆家嘴支行"} //开户支行名称。
36 | }}
37 | };
38 | Console.WriteLine("**** 创建 settle_account-bank_account 渠道 对象 ****");
39 | Console.WriteLine(SettleAccount.Create(appId, "test_user_002", paramBankAccount));
40 | Console.WriteLine();
41 |
42 | var paramAlipay = new Dictionary {
43 | {"channel","alipay"},
44 | {"recipient", new Dictionary{
45 | {"account", "13166666666"},
46 | {"name", "接收者姓名"},
47 | {"type", "b2c"},
48 | }}
49 | };
50 | Console.WriteLine("**** 创建 settle_account 对象-alipay渠道 ****");
51 | Console.WriteLine(SettleAccount.Create(appId, "test_user_002", paramAlipay));
52 | Console.WriteLine();
53 |
54 | var paramWxpub = new Dictionary {
55 | {"channel","wx_pub"},
56 | {"recipient", new Dictionary{
57 | {"account", "接收者open_id"},
58 | {"name", "王五"}, //收款人姓名。当该参数为空,则不校验收款人姓名。
59 | {"type", "b2c"}, //转账类型。b2c:企业向个人付款,b2b:企业向企业付款。
60 | {"force_check", false}, //是否强制校验收款人姓名。仅当 name 参数不为空时该参数生效。
61 | }}
62 | };
63 | Console.WriteLine("**** 创建 settle_account 对象-wx_pub渠道 ****");
64 | Console.WriteLine(SettleAccount.Create(appId, "test_user_002", paramWxpub));
65 | Console.WriteLine();
66 |
67 | Console.WriteLine("**** 查询 settle_account 对象 ****");
68 | Console.WriteLine(SettleAccount.Retrieve(appId, "test_user_002", "320217032111554400000901"));
69 |
70 | Console.WriteLine("**** 删除settle_account 对象 ****");
71 | Console.WriteLine(SettleAccount.Delete(appId, "test_user_002", "320217032111554400000901"));
72 | Console.WriteLine();
73 |
74 | Console.WriteLine("****查询 settle_account 列表****");
75 | Console.WriteLine(SettleAccount.List(appId, "test_user_002"));
76 | Console.WriteLine();
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Example/Example/SplitProfitDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class SplitProfitDemo
9 | {
10 | public static void Example(string appId)
11 | {
12 | Console.WriteLine("****创建 split_profit 分账示例 ****");
13 | Dictionary createParams = new Dictionary {
14 | {"app", appId},
15 | {"charge", "ch_DqfvDSTSif1SjnTiP41KqbrH"},
16 | {"order_no", "190001001"},
17 | {"type", "split_normal"},
18 | {"recipients", new List>{
19 | new Dictionary{
20 | {"split_receiver", "recv_1fRbIszZftTGPa"}, //只有type为 split_normal 时支持填写
21 | {"amount", 6},
22 | //{"name", "示例商户全称"}, //可选参数;只有type为split_normal时支持填写;如果商家传递该字段则 Pingxx 需校验 name 与 split_receiver 是否对应
23 | {"description", "Your Description"}
24 | }
25 | }}
26 | };
27 | Console.WriteLine(SplitProfit.Create(createParams));
28 | Console.WriteLine();
29 |
30 | Console.WriteLine("****查询 split_profit 列表****");
31 | Dictionary listParams = new Dictionary {
32 | {"app", appId},
33 | {"page", 1}
34 | };
35 | Console.WriteLine(SplitProfit.List(listParams));
36 | Console.WriteLine();
37 |
38 | Console.WriteLine("****查询 split_profit ****");
39 | Console.WriteLine(SplitProfit.Retrieve("recv_1fRbIszF3tAuPy"));
40 | Console.WriteLine();
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Example/Example/SplitReceiverDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class SplitReceiverDemo
9 | {
10 | public static void Example(string appId)
11 | {
12 | Console.WriteLine("****创建 split_receiver ****");
13 | Dictionary createParams = new Dictionary {
14 | {"app", appId},
15 | {"type", "MERCHANT_ID"},
16 | {"account", "190001001"},
17 | {"name", "示例商户全称"},
18 | {"channel", "wx_pub_qr"}
19 | };
20 | Console.WriteLine(SplitReceiver.Create(createParams));
21 | Console.WriteLine();
22 |
23 | Console.WriteLine("****查询 split_receiver 列表****");
24 | Dictionary listParams = new Dictionary {
25 | {"app", appId},
26 | {"page", 1}
27 | };
28 | Console.WriteLine(SplitReceiver.List(listParams));
29 | Console.WriteLine();
30 |
31 | Console.WriteLine("****查询 split_receiver ****");
32 | Console.WriteLine(SplitReceiver.Retrieve("recv_1fRbIszF3tAuPy"));
33 | Console.WriteLine();
34 |
35 | Console.WriteLine("****删除 split_receiver ****");
36 | Console.WriteLine(SplitReceiver.Delete("recv_1fRbIszF3tAuPy"));
37 | Console.WriteLine();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Example/Example/SubAppDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Pingpp;
5 | using Pingpp.Models;
6 |
7 | namespace Example.Example
8 | {
9 | ///
10 | /// 本示例介绍子商户创建、更新、删除,查询列表;
11 | ///
12 | public class SubAppDemo
13 | {
14 | public static void Example(string appId)
15 | {
16 | Console.WriteLine("****查询 sub_app 列表****");
17 | Console.WriteLine(SubApp.List(appId));
18 | Console.WriteLine();
19 |
20 | Console.WriteLine("**** 创建sub_app 对象 ****");
21 | var param = new Dictionary {
22 | {"display_name", "sub_app_display_name"},
23 | {"user", "user_0003"},
24 | {"metadata", new Dictionary{
25 | {"key", "value"}
26 | }},
27 | {"description", "Your description"},
28 | //{"parent_app", "app_HC4yrTP44OGGLOyL"}
29 | };
30 | var subApp = SubApp.Create(appId, param);
31 | Console.WriteLine(subApp);
32 | Console.WriteLine();
33 |
34 | Console.WriteLine("**** 查询sub_app 对象 ****");
35 | Console.WriteLine(SubApp.Retrieve(appId, subApp.Id));
36 |
37 | Console.WriteLine("**** 更新sub_app 对象 ****");
38 | var upParam = new Dictionary {
39 | {"display_name", "sub_app_display_name2"},
40 | {"metadata", new Dictionary{
41 | {"key", "value2"}
42 | }},
43 | {"description", "Your description2"},
44 | //{"parent_app", "app_HC4yrTP44OGGLOyL"}
45 | };
46 |
47 | Console.WriteLine(SubApp.Update(appId, subApp.Id, upParam));
48 | Console.WriteLine();
49 |
50 | Console.WriteLine("**** 删除sub_app 对象 ****");
51 | Console.WriteLine(SubApp.Delete(appId, subApp.Id));
52 | Console.WriteLine();
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Example/Example/SubBankDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Pingpp;
3 | using Pingpp.Models;
4 | using System.Collections.Generic;
5 |
6 | namespace Example.Example
7 | {
8 | internal class SubBankDemo
9 | {
10 | public static void Example(string appId)
11 | {
12 | var listParams = new Dictionary {
13 | {"app", appId},
14 | {"channel", "chanpay"},
15 | {"open_bank_code", "0308"},
16 | {"prov", "浙江省"},
17 | {"city","宁波市"}
18 | };
19 |
20 | Console.WriteLine("**** 银行支行列表查询 ****");
21 | Console.WriteLine(SubBank.List(listParams));
22 | Console.WriteLine();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Example/Example/UserDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp;
4 | using Pingpp.Models;
5 |
6 | namespace Example.Example
7 | {
8 | internal class UserDemo
9 | {
10 | ///
11 | /// 本示例介绍如何创建用户(User 对象)、更新 User 对象、禁用/启用 User 对象、查询指定 User 对象和 User 列表
12 | ///
13 | public static User Example(string appId)
14 | {
15 | var uParams = new Dictionary
16 | {
17 | {"id", "test_user_001"}, // 如果 ID 已使用,可以换成别的 ID,注意测试模式下最大用户数量限制
18 | {"email", "test_user@test.com"},
19 | {"gender", "MALE"},
20 | {"name", "Test Name"},
21 | };
22 |
23 | var user = User.Create(appId, uParams);
24 | Console.WriteLine("****发起交易请求创建 User 对象****");
25 | Console.WriteLine(user);
26 | Console.WriteLine();
27 |
28 | Console.WriteLine("****查询指定 User 对象****");
29 | Console.WriteLine(User.Retrieve(appId, user.Id));
30 | Console.WriteLine();
31 |
32 | Console.WriteLine("****更新指定 User 对象****");
33 | Console.WriteLine(User.Update(appId, user.Id, new Dictionary { { "email", "test_user_001@test.com" } }));
34 | Console.WriteLine();
35 |
36 | Console.WriteLine("****禁用指定 User 对象****");
37 | Console.WriteLine(User.Disable(appId, user.Id));
38 | Console.WriteLine();
39 |
40 | Console.WriteLine("****启用指定 User 对象****");
41 | Console.WriteLine(User.Enable(appId, user.Id));
42 | Console.WriteLine();
43 |
44 | Console.WriteLine("****查询 User 列表****");
45 | Console.WriteLine(User.List(appId));
46 | Console.WriteLine();
47 |
48 | return null;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Example/Example/VerifyDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Security.Cryptography;
4 | using System.Text;
5 |
6 | namespace Example.Example
7 | {
8 | public class VerifyDemo
9 | {
10 | ///
11 | /// 本示例介绍如何验证 webhooks 签名。
12 | /// 需要注意的是 requestBody 必须是接收到的原始数据;
13 | /// 签名在 header 里的 x-pingplusplus-signature 字段里;
14 | /// 公钥在管理平台里面,需要登陆去获取。
15 | ///
16 |
17 | public static bool Example()
18 | {
19 | const string sig = "BX5sToHUzPSJvAfXqhtJicsuPjt3yvq804PguzLnMruCSvZ4C7xYS4trdg1blJPh26eeK/P2QfCCHpWKedsRS3bPKkjAvugnMKs+3Zs1k+PshAiZsET4sWPGNnf1E89Kh7/2XMa1mgbXtHt7zPNC4kamTqUL/QmEVI8LJNq7C9P3LR03kK2szJDhPzkWPgRyY2YpD2eq1aCJm0bkX9mBWTZdSYFhKt3vuM1Qjp5PWXk0tN5h9dNFqpisihK7XboB81poER2SmnZ8PIslzWu2iULM7VWxmEDA70JKBJFweqLCFBHRszA8Nt3AXF0z5qe61oH1oSUmtPwNhdQQ2G5X3g==";
20 | const string dataPath = @"../../data.txt";
21 | const string path = @"../../key.pem";
22 |
23 | var verified = VerifySignedHash(ReadFileToString(dataPath), sig, path);
24 | Console.WriteLine(verified ? "Verify Succeed" : "Verify Failed");
25 |
26 | return verified;
27 | }
28 |
29 | public static string ReadFileToString(string path)
30 | {
31 | using (var sr = new StreamReader(path))
32 | {
33 | return sr.ReadToEnd();
34 | }
35 | }
36 |
37 | public static bool VerifySignedHash(string strDataToVerify, string strSignedData, string strPublicKeyFilePath)
38 | {
39 | var signedData = Convert.FromBase64String(strSignedData);
40 |
41 | var byteConverter = new UTF8Encoding();
42 | var dataToVerify = byteConverter.GetBytes(strDataToVerify);
43 | try
44 | {
45 | var sPublicKeyPem = File.ReadAllText(strPublicKeyFilePath);
46 | var rsa = new RSACryptoServiceProvider { PersistKeyInCsp = false };
47 |
48 | rsa.LoadPublicKeyPem(sPublicKeyPem);
49 |
50 | return rsa.VerifyData(dataToVerify, "SHA256", signedData);
51 | }
52 | catch (CryptographicException e)
53 | {
54 | Console.WriteLine(e.Message);
55 |
56 | return false;
57 | }
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Example/Example/WebhooksDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Pingpp.Models;
6 | using System.IO;
7 |
8 | namespace Example.Example
9 | {
10 | public class WebhooksDemo
11 | {
12 | public static Event Example()
13 | {
14 | var data = ReadFileToString(@"../../data.txt");
15 | var evt = Webhooks.ParseWebhook(data);
16 | Console.WriteLine(evt);
17 |
18 | return evt;
19 | }
20 |
21 | public static string ReadFileToString(string path)
22 | {
23 | using (var sr = new StreamReader(path))
24 | {
25 | return sr.ReadToEnd();
26 | }
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Example/Example/data.txt:
--------------------------------------------------------------------------------
1 | {"id":"evt_eYa58Wd44Glerl8AgfYfd1sL","created":1434368075,"livemode":true,"type":"charge.succeeded","data":{"object":{"id":"ch_bq9IHKnn6GnLzsS0swOujr4x","object":"charge","created":1434368069,"livemode":true,"paid":true,"refunded":false,"app":"app_vcPcqDeS88ixrPlu","channel":"wx","order_no":"2015d019f7cf6c0d","client_ip":"140.227.22.72","amount":100,"amount_settle":0,"currency":"cny","subject":"An Apple","body":"A Big Red Apple","extra":{},"time_paid":1434368074,"time_expire":1434455469,"time_settle":null,"transaction_no":"1014400031201506150354653857","refunds":{"object":"list","url":"/v1/charges/ch_bq9IHKnn6GnLzsS0swOujr4x/refunds","has_more":false,"data":[]},"amount_refunded":0,"failure_code":null,"failure_msg":null,"metadata":{},"credential":{},"description":null}},"object":"event","pending_webhooks":0,"request":"iar_Xc2SGjrbdmT0eeKWeCsvLhbL"}
--------------------------------------------------------------------------------
/Example/Example/key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0d0QxZFYeHXGeWWneib
3 | 4Q0jUFjj4ro7bMnIJ8DjZ4w2NtLJi8p1mcFMbrIS5g95U5FUBCfAZXFb2QIaJfft
4 | BByCQRbon7Jb97XoTP6kfk65tLz8Q9Cank1Ah/qivPIY0aNwvq8stedq9rcuJ6OQ
5 | ncbfQ1217/Za50vKotYa+MEcFo9Y65biEmzq7BZeNYzuU4dGrPaCi917cfwNa8ey
6 | ZSpoIOBe8e5JGOtZKCfgsgfecbXxdh6jq8Qn6mmrJILapEdxlj4xfzBzAuM3snqt
7 | 5XnDzzFWlI5Z+4lhyZr7eFVmnQSqn1HWt4VPzz/EWvxP8Rkvy89XuRXBAiO3/7Ur
8 | 8wIDAQAB
9 | -----END PUBLIC KEY-----
--------------------------------------------------------------------------------
/Example/InAppExample/InAppChargeDemo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Pingpp.Models;
4 |
5 | namespace Example.InAppExample
6 | {
7 | public class InAppChargeDemo
8 | {
9 | ///
10 | /// 本示例只介绍如何请求支付凭据(charge 对象),以及如何查询指定 charge 对象和 charge 列表,
11 | /// 至于如何将 charge 对象传递给客户端需要接入者自行处理
12 | ///
13 | public static void Example(string appId)
14 | {
15 | //交易请求参数,这里之列出必填参数,可选参数请参考 https://pingxx.com/document/api#api-c-new
16 | var chargeParam = new Dictionary
17 | {
18 | {"order_no", new Random().Next(1, 999999999)},
19 | {"amount", 1},
20 | {"channel", "cnp_u"},
21 | {"currency", "cny"},
22 | {"subject", "Your Subject"},
23 | {"body", "Your Body"},
24 | {"client_ip", "127.0.0.1"},
25 | {"app", new Dictionary {{"id", appId}}},
26 | {
27 | "extra", new Dictionary
28 | {
29 | {"sms_code", new Dictionary {{"code", "123456"}, {"id", "123456"}}},
30 | {"source", "tok_Ca1GS4Ha9aL01i5ubHHC8CaP"}
31 | }
32 | }
33 | };
34 | var ch = Charge.Create(chargeParam);
35 | Console.WriteLine("****发起交易请求创建 charge 对象****");
36 | Console.WriteLine(ch);
37 | Console.WriteLine();
38 |
39 | Console.WriteLine("****查询指定 charge 对象****");
40 | Console.WriteLine(Charge.Retrieve(ch.Id));
41 | Console.WriteLine();
42 |
43 | Console.WriteLine("****查询 charge 列表****");
44 | Dictionary listParams = new Dictionary{
45 | {"app", new Dictionary {{"id", appId}}},
46 | {"limit", 3},
47 | {"paid", true}
48 | };
49 | Console.WriteLine();
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Example/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Example")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Example")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ae40acb8-70f2-4af3-8ea7-2c36d61e739d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Example/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Example/your_rsa_private_key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEowIBAAKCAQEAx2MktxcKBEqdYRi2IgYcupPQIN5cxgiBL5udCCBJBNBbXPaq
3 | uOE1qspfhB1KUzHXATnCONiSzubLcBTnwi2tz0ErRCeJZSERRCpbKx4eu6b1neUT
4 | Wkga7xpZxWONEvkmZo5Nlhf4fXRPUYnO/bdGCNGpQ/HSJfWLtzmhCqO1aJwVhcDm
5 | DMYz4bTkZavhFBdVyXf/8n7UKylk03eymlKJ1swQpeFcxaKfzsk1mJU7mc93mCWj
6 | aR+VWkNbw4AQHDyHgbzH+zYARzCluiy5hXdixGEP+iO4ZBk48rEs1hKTvGz1k+jh
7 | LCdkdpBRjq0pK/htjA3Ce8pF2AJs+fgN6ZUumQIDAQABAoIBAFa4MEfRpXGoYjrQ
8 | 3KZ/sg8UKvmgvQkEuetS60GViSym0pXkUuyGRyk5S8HSW3lDvBe0X10KFRAYIXNm
9 | JEa4R1hVJ9REveVWNIRJR83BE+zZ+QnrkDc8FTrZYyIO4lTWOHVyfxxA4Lrv02/L
10 | WFPRWoyLY+tBSf1ohpPyZLCT81rDglT1Z4svX020y8tXvnQqQiOjl4q7Zu4b26HU
11 | TQ463ntMEhM5u7y9MFcxGRaOpF/gARlMGqDu6T8h/oYMiOSLoXOuTR7B80yaX/Mj
12 | RZfUBoZMb5thX9qBLQ7dYnTkwaxwerYPrYvQrW9vtsswZ5NeIbEmCZyorUe8DOmQ
13 | hT1+HmECgYEA/iQERHhZKHXnP0gvhl/uEOGOvLjD5H1D6zClzOHMmOcIF5OuEQb0
14 | VcSMV+8emN7SCp/b/LVgKa27Mla9eXm+EXABRFcI7qGYsYXfbCD7EYX3TaJSp/30
15 | jyLBy+MsHCTEiLeylSh7kHqgTR8tKND8UIzXo9aM7JqwFqleeXGyh7MCgYEAyNiU
16 | EUzyBAv9sui3ZgVYRiVvTilk2HVTY6u61/mMOLsTrX3eYQaqb4GRJJShJO9mmsxX
17 | RHBEZQJvUqqF9PapOsyv8HKuF5+UP6svHnJo7sn9gCvV/h1HTHqzFcYSvUaXnrym
18 | D/0Tthf8CDeuGp5UFWMoFZF14HTr1oQROGAASoMCgYA0bZmzxmAeSLR8CZhEUGX8
19 | dYvMwxEmgfERA+gwbCSZJpA0zPKL8LNXPkT1nw7g2pbaOkBX0dMUxhJoQBy2grcD
20 | QegBATOGhy/I76U32VXyN4DdMy96GJnrLXBtb2AaLjudOMhOnRtgouuO/W+DjBmB
21 | RIz377sC1KafBjHHO/1ooQKBgDQqfJrZv2ppquVTKH9pF/pwMq68daL7JkOXERqT
22 | iGYbwQqozJ+q2Y3Iu2gi6o/rVl0SggAWoM0TitKP0+dCQcYx7+imAK3GFv1KexyP
23 | Xs3WzO8Dc7ti42fr3qPjJG7g7PSfzwoME5iSNjX0MFZdlT1Q2dJwS4uXEsJO3yIj
24 | XS/9AoGBALRApgtUA7Odw4tjCLGvxXuLFnyRkg6hFqoXAP2j8H9bJDOlSSVwQTFd
25 | ahbcIDtQJS57vXUGK2uspbFKLm1WCFzPVyuxDIW6oue/kO+YxxU3NA58zk8oaORq
26 | eA3YvHc7ZmRjVnVkxnXjKofrL6jF5A+lXSXnXchrv2ZYI+1pOsIV
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/Example/your_rsa_public_key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2MktxcKBEqdYRi2IgYc
3 | upPQIN5cxgiBL5udCCBJBNBbXPaquOE1qspfhB1KUzHXATnCONiSzubLcBTnwi2t
4 | z0ErRCeJZSERRCpbKx4eu6b1neUTWkga7xpZxWONEvkmZo5Nlhf4fXRPUYnO/bdG
5 | CNGpQ/HSJfWLtzmhCqO1aJwVhcDmDMYz4bTkZavhFBdVyXf/8n7UKylk03eymlKJ
6 | 1swQpeFcxaKfzsk1mJU7mc93mCWjaR+VWkNbw4AQHDyHgbzH+zYARzCluiy5hXdi
7 | xGEP+iO4ZBk48rEs1hKTvGz1k+jhLCdkdpBRjq0pK/htjA3Ce8pF2AJs+fgN6ZUu
8 | mQIDAQAB
9 | -----END PUBLIC KEY-----
10 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 1.6.0
--------------------------------------------------------------------------------
/libs/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PingPlusPlus/pingpp-csharp/eaa9e8f192d9ac16f33b265beb82bc9175ab5720/libs/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/libs/pingpp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PingPlusPlus/pingpp-csharp/eaa9e8f192d9ac16f33b265beb82bc9175ab5720/libs/pingpp.dll
--------------------------------------------------------------------------------
/pingpp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pingpp", "pingpp\pingpp.csproj", "{AA23DD84-E82D-4D6F-8034-D35C8083F24A}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{83ED053C-C339-46A2-A8E3-3B8E9264E468}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {AA23DD84-E82D-4D6F-8034-D35C8083F24A} = {AA23DD84-E82D-4D6F-8034-D35C8083F24A}
11 | EndProjectSection
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{59CDF32A-AADA-4D70-94C0-EDE828616914}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {AA23DD84-E82D-4D6F-8034-D35C8083F24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {AA23DD84-E82D-4D6F-8034-D35C8083F24A}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {AA23DD84-E82D-4D6F-8034-D35C8083F24A}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {AA23DD84-E82D-4D6F-8034-D35C8083F24A}.Release|Any CPU.Build.0 = Release|Any CPU
25 | {83ED053C-C339-46A2-A8E3-3B8E9264E468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {83ED053C-C339-46A2-A8E3-3B8E9264E468}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {83ED053C-C339-46A2-A8E3-3B8E9264E468}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {83ED053C-C339-46A2-A8E3-3B8E9264E468}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {59CDF32A-AADA-4D70-94C0-EDE828616914}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {59CDF32A-AADA-4D70-94C0-EDE828616914}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {59CDF32A-AADA-4D70-94C0-EDE828616914}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {59CDF32A-AADA-4D70-94C0-EDE828616914}.Release|Any CPU.Build.0 = Release|Any CPU
33 | EndGlobalSection
34 | GlobalSection(SolutionProperties) = preSolution
35 | HideSolutionNode = FALSE
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/pingpp/Exception/PingppException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using Pingpp.Models;
4 |
5 | namespace Pingpp.Exception
6 | {
7 | [Serializable]
8 | public class PingppException : ApplicationException
9 | {
10 | public HttpStatusCode HttpStatusCode { get; set; }
11 | public Error Error { get; set; }
12 |
13 | public PingppException()
14 | {
15 | }
16 |
17 | public PingppException(string message)
18 | : base(message)
19 | {
20 | }
21 |
22 | public PingppException(Error pingppError, HttpStatusCode httpStatusCode, string type = null, string message = null)
23 | : base(message)
24 | {
25 | HttpStatusCode = httpStatusCode;
26 | Error = pingppError;
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/pingpp/Models/Agreement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 | using Pingpp.Exception;
6 |
7 | namespace Pingpp.Models
8 | {
9 | ///
10 | /// 签约对象
11 | ///
12 | public class Agreement :Pingpp
13 | {
14 | [JsonProperty("id")]
15 | public string Id { get; set; }
16 | [JsonProperty("object")]
17 | public string Object { get; set; }
18 | [JsonProperty("livemode")]
19 | public bool Livemode { get; set; }
20 | [JsonProperty("app")]
21 | public string App { get; set; }
22 | [JsonProperty("created")]
23 | public int? Created { get; set; }
24 | [JsonProperty("channel")]
25 | public string Channel { get; set; }
26 | [JsonProperty("contract_no")]
27 | public string ContractNo { get; set; }
28 | [JsonProperty("contract_id")]
29 | public string ContractId { get; set; }
30 | [JsonProperty("credential")]
31 | public Dictionary Credential { get; set; }
32 | [JsonProperty("status")]
33 | public string Status { get; set; }
34 | [JsonProperty("time_succeeded")]
35 | public int? TimeSucceeded { get; set; }
36 | [JsonProperty("time_canceled")]
37 | public int? TImeCanceled { get; set; }
38 | [JsonProperty("failure_code")]
39 | public string FailureCode { get; set; }
40 | [JsonProperty("failure_msg")]
41 | public string FailureMsg { get; set; }
42 | [JsonProperty("metadata")]
43 | public Dictionary Metadata { get; set; }
44 | [JsonProperty("extra")]
45 | public Dictionary Extra { get; set; }
46 |
47 | private const string BaseUrl = "/v1/agreements";
48 |
49 | ///
50 | /// 创建签约接口
51 | ///
52 | ///
53 | ///
54 | public static Agreement Create(Dictionary param)
55 | {
56 | var agreement = Requestor.DoRequest(BaseUrl, "POST", param);
57 | return Mapper.MapFromJson(agreement);
58 | }
59 |
60 | ///
61 | /// 查询签约对象
62 | ///
63 | ///
64 | ///
65 | public static Agreement Retrieve(string Id)
66 | {
67 | var agreement = Requestor.DoRequest(string.Format("{0}/{1}", BaseUrl, Id), "GET");
68 | return Mapper.MapFromJson(agreement);
69 | }
70 |
71 | ///
72 | /// 解除签约
73 | ///
74 | ///
75 | ///
76 | public static Agreement Cancel(string Id)
77 | {
78 | Dictionary param = new Dictionary {{ "status", "canceled" }};
79 | var agreement = Requestor.DoRequest(string.Format("{0}/{1}", BaseUrl, Id), "PUT", param);
80 | return Mapper.MapFromJson(agreement);
81 | }
82 |
83 | ///
84 | /// 查询签约对象列表
85 | ///
86 | ///
87 | ///
88 | public static AgreementList List(Dictionary listParams)
89 | {
90 | var agreementList = Requestor.DoRequest(Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(listParams)), "GET");
91 | return Mapper.MapFromJson(agreementList);
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/pingpp/Models/AgreementList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class AgreementList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceBonus.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 | using Pingpp.Exception;
6 |
7 | namespace Pingpp.Models
8 | {
9 | public class BalanceBonus : Pingpp
10 | {
11 | [JsonProperty("id")]
12 | public string Id { get; set; }
13 | [JsonProperty("object")]
14 | public string Object { get; set; }
15 | [JsonProperty("app")]
16 | public string App { get; set; }
17 | [JsonProperty("created")]
18 | public int Created { get; set; }
19 |
20 | [JsonProperty("livemode")]
21 | public bool Livemode { get; set; }
22 | [JsonProperty("paid")]
23 | public bool Paid { get; set; }
24 |
25 | [JsonProperty("refunded")]
26 | public bool Refunded { get; set; }
27 | [JsonProperty("amount")]
28 | public int Amount { get; set; }
29 | [JsonProperty("amount_refunded")]
30 | public int AmountRefunded { get; set; }
31 | [JsonProperty("order_no")]
32 | public string OrderNo { get; set; }
33 | [JsonProperty("time_paid")]
34 | public int? TimePaid { get; set; }
35 | [JsonProperty("user")]
36 | public string User { get; set; }
37 | [JsonProperty("balance_transaction")]
38 | public string BalanceTransaction { get; set; }
39 | [JsonProperty("description")]
40 | public string Description { get; set; }
41 | [JsonProperty("metadata")]
42 | public Dictionary Metadata { get; set; }
43 |
44 | private const string BaseUrl = "/v1/apps/{0}/balance_bonuses";
45 |
46 | ///
47 | /// 创建余额赠送
48 | ///
49 | ///
50 | ///
51 | ///
52 | public static BalanceBonus Create(string appId, Dictionary bonusParams)
53 | {
54 | var balanceBonus = Requestor.DoRequest(string.Format(BaseUrl, appId), "POST", bonusParams);
55 | return Mapper.MapFromJson(balanceBonus);
56 | }
57 |
58 | ///
59 | /// 查询余额赠送
60 | ///
61 | ///
62 | ///
63 | ///
64 | public static BalanceBonus Retrieve(string appId, string balanceBonusId)
65 | {
66 | var balanceBonus = Requestor.DoRequest(string.Format("{0}/{1}",string.Format(BaseUrl,appId),balanceBonusId), "GET");
67 | return Mapper.MapFromJson(balanceBonus);
68 | }
69 |
70 | ///
71 | /// 查询余额赠送列表
72 | ///
73 | ///
74 | ///
75 | ///
76 | public static BalanceBonusList List(string appId, Dictionary listParams = null)
77 | {
78 | var balanceBonusList = Requestor.DoRequest(Requestor.FormatUrl(String.Format(BaseUrl,appId), Requestor.CreateQuery(listParams)),"GET");
79 | return Mapper.MapFromJson(balanceBonusList);
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceBonusList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using Pingpp.Net;
6 |
7 | namespace Pingpp.Models
8 | {
9 | public class BalanceBonusList : Pingpp
10 | {
11 | [JsonProperty("object")]
12 | public string Object { set; get; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { set; get; }
15 | [JsonProperty("url")]
16 | public string Url { set; get; }
17 | [JsonProperty("data")]
18 | public IEnumerable Data { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceSettlement.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 | using Pingpp.Net;
4 |
5 |
6 | namespace Pingpp.Models
7 | {
8 | ///
9 | /// balance_settlement 余额结算对象
10 | ///
11 | public class BalanceSettlement : Pingpp
12 | {
13 | [JsonProperty("id")]
14 | public string Id { get; set; }
15 |
16 | [JsonProperty("object")]
17 | public string Object { get; set; }
18 |
19 | [JsonProperty("app")]
20 | public string App { get; set; }
21 |
22 | [JsonProperty("amount")]
23 | public int Amount { get; set; }
24 |
25 | [JsonProperty("amount_refunded")]
26 | public int AmountRefunded { get; set; }
27 |
28 | [JsonProperty("created")]
29 | public int Created { get; set; }
30 |
31 | [JsonProperty("charge")]
32 | public string Charge { get; set; }
33 |
34 | [JsonProperty("livemode")]
35 | public bool Livemode { get; set; }
36 |
37 | [JsonProperty("failure_msg")]
38 | public string FailureMsg { get; set; }
39 |
40 | [JsonProperty("refunded")]
41 | public bool Refunded { get; set; }
42 |
43 | [JsonProperty("order_no")]
44 | public string OrderNo { get; set; }
45 |
46 | [JsonProperty("status")]
47 | public string Status { get; set; }
48 |
49 | [JsonProperty("time_credited")]
50 | public int TimeCredited { get; set; }
51 |
52 | [JsonProperty("time_succeeded")]
53 | public int TimeSucceeded { get; set; }
54 |
55 | [JsonProperty("transaction_no")]
56 | public string TransactionNo { get; set; }
57 |
58 | [JsonProperty("user")]
59 | public string User { get; set; }
60 |
61 | [JsonProperty("user_fee")]
62 | public int UserFee { get; set; }
63 | private const string BaseUrl = "/v1/apps/{0}/balance_settlements";
64 |
65 | ///
66 | /// 查询余额结算对象
67 | ///
68 | ///
69 | ///
70 | ///
71 | public static BalanceSettlement Retrieve(string appId, string balanceSettlementId)
72 | {
73 |
74 | var balanceSettlement = Requestor.DoRequest(string.Format("{0}/{1}", string.Format(BaseUrl, appId), balanceSettlementId), "GET");
75 | return Mapper.MapFromJson(balanceSettlement);
76 | }
77 |
78 | ///
79 | /// 查询余额结算对象列表
80 | ///
81 | ///
82 | ///
83 | ///
84 | public static BalanceSettlementList List (string appId, Dictionary listParams = null)
85 | {
86 | var balanceTransferList = Requestor.DoRequest(Requestor.FormatUrl(string.Format(BaseUrl, appId), Requestor.CreateQuery(listParams)), "GET");
87 | return Mapper.MapFromJson(balanceTransferList);
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceSettlementList.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Pingpp.Models
8 | {
9 | public class BalanceSettlementList :Pingpp
10 | {
11 | [JsonProperty("object")]
12 | public string Object { set; get; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { set; get; }
15 | [JsonProperty("url")]
16 | public string Url { set; get; }
17 | [JsonProperty("data")]
18 | public IEnumerable Data { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceTransaction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class BalanceTransaction : Pingpp
9 | {
10 | [JsonProperty("id")]
11 | public string Id { get; set; }
12 |
13 | [JsonProperty("object")]
14 | public string Object { get; set; }
15 |
16 | [JsonProperty("app")]
17 | public string App { get; set; }
18 |
19 | [JsonProperty("amount")]
20 | public int? Amount { get; set; }
21 |
22 | [JsonProperty("available_balance")]
23 | public int? AvailableBalance { get; set; }
24 |
25 | [JsonProperty("created")]
26 | public int? Created { get; set; }
27 |
28 | [JsonProperty("description")]
29 | public string Description { get; set; }
30 |
31 | [JsonProperty("livemode")]
32 | public bool Livemode { get; set; }
33 |
34 | [JsonProperty("source")]
35 | public string Source { get; set; }
36 |
37 | [JsonProperty("type")]
38 | public string Type { get; set; }
39 |
40 | [JsonProperty("user")]
41 | public string User { get; set; }
42 |
43 | private const string BaseUrl = "/v1/apps";
44 |
45 | ///
46 | /// 企业清算账户交易明细-查询
47 | ///
48 | ///
49 | ///
50 | ///
51 | public static BalanceTransaction Retrieve(string appId, string txnId)
52 | {
53 | var url = string.Format("{0}/{1}/balance_transactions/{2}", BaseUrl, appId, txnId);
54 | var txn = Requestor.DoRequest(url, "GET");
55 | return Mapper.MapFromJson(txn);
56 | }
57 |
58 | ///
59 | /// 企业清算账户交易明细-查询列表
60 | ///
61 | ///
62 | ///
63 | ///
64 | public static BalanceTransactionList List(string appId, Dictionary listParams = null)
65 | {
66 | var url = Requestor.FormatUrl(string.Format("{0}/{1}/balance_transactions", BaseUrl, appId), Requestor.CreateQuery(listParams));
67 | var txnList = Requestor.DoRequest(url, "GET");
68 | return Mapper.MapFromJson(txnList);
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceTransactionList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class BalanceTransactionList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceTransfer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 | using Pingpp.Exception;
6 |
7 | namespace Pingpp.Models
8 | {
9 | public class BalanceTransfer : Pingpp
10 | {
11 | [JsonProperty("id")]
12 | public string Id { get; set; }
13 | [JsonProperty("object")]
14 | public string Object { get; set; }
15 | [JsonProperty("app")]
16 | public string App { get; set; }
17 | [JsonProperty("created")]
18 | public int Created { get; set; }
19 | [JsonProperty("livemode")]
20 | public bool Livemode { get; set; }
21 | [JsonProperty("status")]
22 | public string Status { get; set; }
23 | [JsonProperty("amount")]
24 | public int Amount { get; set; }
25 | [JsonProperty("user")]
26 | public string User { get; set; }
27 | [JsonProperty("user_fee")]
28 | public int UserFee { get; set; }
29 | [JsonProperty("recipient")]
30 | public string Recipient { get; set; }
31 | [JsonProperty("user_balance_transaction")]
32 | public string UserBalanceTransaction { get; set; }
33 | [JsonProperty("recipient_balance_transaction")]
34 | public string RecipientBalanceTransaction { get; set; }
35 | [JsonProperty("description")]
36 | public string Description { get; set; }
37 | [JsonProperty("metadata")]
38 | public Dictionary Metadata { get; set; }
39 | private const string BaseUrl = "/v1/apps/{0}/balance_transfers";
40 |
41 | ///
42 | /// 创建余额转账
43 | ///
44 | ///
45 | ///
46 | ///
47 | public static BalanceTransfer Create(string appId, Dictionary btParams)
48 | {
49 | var balanceTransfer = Requestor.DoRequest(string.Format(BaseUrl, appId), "POST", btParams);
50 | return Mapper.MapFromJson(balanceTransfer);
51 | }
52 | ///
53 | /// 查询余额转账对象
54 | ///
55 | ///
56 | ///
57 | ///
58 | public static BalanceTransfer Retrieve(string appId, string balanceTransferId)
59 | {
60 | var balanceTransfer = Requestor.DoRequest(string.Format("{0}/{1}", string.Format(BaseUrl, appId), balanceTransferId), "GET");
61 | return Mapper.MapFromJson(balanceTransfer);
62 | }
63 | ///
64 | /// 查询余额转账对象列表
65 | ///
66 | ///
67 | ///
68 | ///
69 | public static BalanceTransferList List(string appId, Dictionary listParams = null)
70 | {
71 | var balanceTransferList = Requestor.DoRequest(Requestor.FormatUrl(String.Format(BaseUrl, appId), Requestor.CreateQuery(listParams)), "GET");
72 | return Mapper.MapFromJson(balanceTransferList);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/pingpp/Models/BalanceTransferList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using Pingpp.Net;
6 |
7 | namespace Pingpp.Models
8 | {
9 | public class BalanceTransferList : Pingpp
10 | {
11 | [JsonProperty("object")]
12 | public string Object { set; get; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { set; get; }
15 | [JsonProperty("url")]
16 | public string Url { set; get; }
17 | [JsonProperty("data")]
18 | public IEnumerable Data { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/pingpp/Models/BatchRefund.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 |
7 | namespace Pingpp.Models
8 | {
9 | ///
10 | /// batch_refunds Batch refund批量退款
11 | ///
12 | public class BatchRefund : Pingpp
13 | {
14 | [JsonProperty("id")]
15 | public string Id { get; set; }
16 |
17 | [JsonProperty("app")]
18 | public string App { get; set; }
19 |
20 | [JsonProperty("object")]
21 | public string Object { get; set; }
22 |
23 | [JsonProperty("batch_no")]
24 | public string BatchNo { get; set; }
25 |
26 | [JsonProperty("created")]
27 | public int? Created { get; set; }
28 |
29 | [JsonProperty("description")]
30 | public string Description { get; set; }
31 |
32 | [JsonProperty("metadata")]
33 | public Dictionary Metadata { get; set; }
34 |
35 | [JsonProperty("charges")]
36 | public List BatchRefundCharge { get; set; }
37 |
38 | [JsonProperty("refunds")]
39 | public RefundList Refunds { get; set; }
40 |
41 | [JsonProperty("refund_url")]
42 | public string RefundUrl { get; set; }
43 | [JsonProperty("status")]
44 | public string Status { get; set; }
45 | [JsonProperty("time_succeeded")]
46 | public string TimeSucceeded { get; set; }
47 | [JsonProperty("livemode")]
48 | public bool Livemode { get; set; }
49 |
50 | private const string BaseUrl = "/v1/batch_refunds";
51 | public static BatchRefund Create(Dictionary bfParams)
52 | {
53 | var re = Requestor.DoRequest(BaseUrl, "POST", bfParams);
54 | return Mapper.MapFromJson(re);
55 | }
56 |
57 | public static BatchRefund Retrieve(string batchRefundId)
58 | {
59 | var url = string.Format("{0}/{1}", BaseUrl, batchRefundId);
60 | var re = Requestor.DoRequest(url, "GET");
61 | return Mapper.MapFromJson(re);
62 | }
63 |
64 | public static BatchRefundList List(Dictionary listParams = null)
65 | {
66 | var url = Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(listParams));
67 | var re = Requestor.DoRequest(url, "GET");
68 | return Mapper.MapFromJson(re);
69 | }
70 | }
71 |
72 | public class BatchRefundCharge
73 | {
74 | [JsonProperty("charge")]
75 | public string Charge { get; set; }
76 | [JsonProperty("amount")]
77 | public int Amount { get; set; }
78 | [JsonProperty("description")]
79 | public string Description { get; set; }
80 | [JsonProperty("status")]
81 | public string Status { get; set; }
82 | [JsonProperty("funding_source", NullValueHandling = NullValueHandling.Ignore)]
83 | public string FundingSource { get; set; }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/pingpp/Models/BatchRefundList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class BatchRefundList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/pingpp/Models/BatchTransfer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 |
7 | namespace Pingpp.Models
8 | {
9 | ///
10 | /// batch_transfer
11 | ///
12 | public class BatchTransfer : Pingpp
13 | {
14 | [JsonProperty("id")]
15 | public string Id{ set; get; }
16 | [JsonProperty("object")]
17 | public string Object{ set; get; }
18 | [JsonProperty("app")]
19 | public string App{ set; get; }
20 | [JsonProperty("amount")]
21 | public int? Amount{ set; get; }
22 | [JsonProperty("batch_no")]
23 | public string BatchNo{ set; get; }
24 | [JsonProperty("channel")]
25 | public string Channel{ set; get; }
26 | [JsonProperty("currency")]
27 | public string Currency { set; get; }
28 | [JsonProperty("created")]
29 | public int? Created{ set; get; }
30 | [JsonProperty("description")]
31 | public string Description { set; get; }
32 | [JsonProperty("extra")]
33 | public Dictionary Extra { set; get; }
34 | [JsonProperty("failure_msg")]
35 | public string FailureMsg;
36 | [JsonProperty("fee")]
37 | public int Fee { set; get; }
38 | [JsonProperty("livemode")]
39 | public bool Livemode { set; get; }
40 | [JsonProperty("metadata")]
41 | public Dictionary MetaData { set; get; }
42 | [JsonProperty("recipients")]
43 | public List> RecipientsList { set; get; }
44 | [JsonProperty("status")]
45 | public string Status { set; get; }
46 | [JsonProperty("time_succeeded")]
47 | public string TimeSucceeded;
48 | [JsonProperty("type")]
49 | public string Type { set; get; }
50 |
51 | private const string BaseUrl = "/v1/batch_transfers";
52 | ///
53 | /// 创建批量付款Object
54 | ///
55 | ///
56 | ///
57 | public static BatchTransfer Create(Dictionary btParams)
58 | {
59 | var batchTranster = Requestor.DoRequest(BaseUrl, "POST", btParams);
60 | return Mapper.MapFromJson(batchTranster);
61 | }
62 |
63 | ///
64 | /// 查询批量付款明细 Object
65 | ///
66 | ///
67 | ///
68 | public static BatchTransfer Retrieve(string batchTransferNo)
69 | {
70 | var url = string.Format("{0}/{1}", BaseUrl, batchTransferNo);
71 | var batchTranster = Requestor.DoRequest(url, "GET");
72 | return Mapper.MapFromJson(batchTranster);
73 | }
74 |
75 | ///
76 | /// 查询批量付款列表
77 | ///
78 | ///
79 | ///
80 | public static BatchTransferList List(Dictionary btParams)
81 | {
82 | var url = Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(btParams));
83 | var batchTranster = Requestor.DoRequest(url, "GET");
84 | return Mapper.MapFromJson(batchTranster);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/pingpp/Models/BatchTransferList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class BatchTransferList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/BatchWithdrawal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using Pingpp.Net;
6 |
7 |
8 | namespace Pingpp.Models
9 | {
10 | ///
11 | /// 批量提现确认
12 | ///
13 | public class BatchWithdrawal : Pingpp
14 | {
15 | [JsonProperty("id")]
16 | public string Id { set; get; }
17 | [JsonProperty("object")]
18 | public string Object { set; get; }
19 | [JsonProperty("app")]
20 | public string App { set; get; }
21 | [JsonProperty("created")]
22 | public int? Created { set; get; }
23 | [JsonProperty("livemode")]
24 | public bool Livemode { set; get; }
25 | [JsonProperty("amount")]
26 | public int? Amount { set; get; }
27 | [JsonProperty("amount_succeeded")]
28 | public int? AmountSucceeded { set; get; }
29 | [JsonProperty("amount_failed")]
30 | public int? AmountFailed { set; get; }
31 | [JsonProperty("amount_canceled")]
32 | public int? AmountCanceled { set; get; }
33 | public int Count { set; get; }
34 | [JsonProperty("count_succeeded")]
35 | public int CountSucceeded { set; get; }
36 | [JsonProperty("count_failed")]
37 | public int CountFailed { set; get; }
38 | [JsonProperty("count_canceled")]
39 | public int CountCanceled { set; get; }
40 | [JsonProperty("fee")]
41 | public int? Fee { set; get; }
42 | [JsonProperty("metadata")]
43 | public Dictionary Metadata { set; get; }
44 | [JsonProperty("operation_url")]
45 | public string OperationUrl { set; get; }
46 | [JsonProperty("source")]
47 | public string Source { set; get; }
48 | [JsonProperty("status")]
49 | public string Status { set; get; }
50 | [JsonProperty("user_fee")]
51 | public int? UserFee { set; get; }
52 | [JsonProperty("withdrawals")]
53 | public WithdrawalList Withdrawals { set; get; }
54 | [JsonProperty("time_finished")]
55 | public string TimeFinished { set; get; }
56 |
57 | private const string BaseUrl = "/v1/apps";
58 |
59 | ///
60 | /// 创建批量提现确认
61 | ///
62 | ///
63 | ///
64 | ///
65 | public static BatchWithdrawal Create(string appId, Dictionary batchwrParams)
66 | {
67 | var url = string.Format("{0}/{1}/batch_withdrawals", BaseUrl, appId);
68 | var batchWithdrawal = Requestor.DoRequest(url, "POST", batchwrParams);
69 | return Mapper.MapFromJson(batchWithdrawal);
70 | }
71 |
72 | ///
73 | /// 批量提现查询
74 | ///
75 | ///
76 | ///
77 | ///
78 | public static BatchWithdrawal Retrieve(string appId, string batchWithdrawalId)
79 | {
80 | var url = string.Format("{0}/{1}/batch_withdrawals/{2}", BaseUrl, appId, batchWithdrawalId);
81 | var batchWithdrawal = Requestor.DoRequest(url, "GET");
82 | return Mapper.MapFromJson(batchWithdrawal);
83 | }
84 |
85 | ///
86 | /// 批量提现列表查询
87 | ///
88 | ///
89 | ///
90 | ///
91 | public static BatchWithdrawalList List(string appId, Dictionary listParams = null)
92 | {
93 | var url = Requestor.FormatUrl(string.Format("{0}/{1}/batch_withdrawals", BaseUrl, appId), Requestor.CreateQuery(listParams));
94 | var batchWithdrawalList = Requestor.DoRequest(url, "GET", listParams);
95 | return Mapper.MapFromJson(batchWithdrawalList);
96 | }
97 | }
98 | }
--------------------------------------------------------------------------------
/pingpp/Models/BatchWithdrawalList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class BatchWithdrawalList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Card.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using Pingpp.Net;
6 |
7 |
8 | namespace Pingpp.Models
9 | {
10 | public class Card : Pingpp
11 | {
12 | [JsonProperty("id")]
13 | public string Id { get; set; }
14 |
15 | [JsonProperty("object")]
16 | public string Object { get; set; }
17 |
18 | [JsonProperty("created")]
19 | public int? Created { get; set; }
20 |
21 | [JsonProperty("last4")]
22 | public string Last4 { get; set; }
23 |
24 | [JsonProperty("funding")]
25 | public string Funding { get; set; }
26 |
27 | [JsonProperty("brand")]
28 | public string Brand { get; set; }
29 |
30 | [JsonProperty("bank")]
31 | public string Bank { get; set; }
32 |
33 | [JsonProperty("customer")]
34 | public string Customer { get; set; }
35 |
36 | private const string BaseUrl = "/v1/customers";
37 |
38 | public static Card Create(string cusId, Dictionary cardParams)
39 | {
40 | var url = string.Format("{0}/{1}/sources", BaseUrl, cusId);
41 | var card = Requestor.DoRequest(url, "POST", cardParams);
42 | return Mapper.MapFromJson(card);
43 | }
44 |
45 | public static Card Retrieve(string cusId, string cardId)
46 | {
47 | var url = string.Format("{0}/{1}/sources/{2}", BaseUrl, cusId, cardId);
48 | var card = Requestor.DoRequest(url, "GET");
49 | return Mapper.MapFromJson(card);
50 | }
51 |
52 | public static CardList List(string cusId, Dictionary listParams = null)
53 | {
54 | var url = Requestor.FormatUrl(string.Format("{0}/{1}/sources", BaseUrl, cusId), Requestor.CreateQuery(listParams));
55 | var card = Requestor.DoRequest(url, "GET");
56 | return Mapper.MapFromJson(card);
57 | }
58 |
59 | public static object Delete(string cusId, string cardId)
60 | {
61 | var url = string.Format("{0}/{1}/sources/{2}", BaseUrl, cusId, cardId);
62 | var card = Requestor.DoRequest(url, "DELETE");
63 | return JObject.Parse(card);
64 | }
65 | }
66 |
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/pingpp/Models/CardInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class CardInfo : Pingpp
9 | {
10 | [JsonProperty("app")]
11 | public string App { get; set; }
12 |
13 | [JsonProperty("card_bin")]
14 | public string CardBin { get; set; }
15 |
16 | [JsonProperty("card_type")]
17 | public int CardType { get; set; }
18 |
19 | [JsonProperty("open_bank_code")]
20 | public string OpenBankCode { get; set; }
21 |
22 | [JsonProperty("open_bank")]
23 | public string OpenBank { get; set; }
24 |
25 | [JsonProperty("support_channels")]
26 | public List SupportChannels { get; set; }
27 |
28 | private const string BaseUrl = "/v1/card_info";
29 |
30 | ///
31 | /// 银行卡信息查询
32 | ///
33 | ///
34 | ///
35 | public static CardInfo Query(Dictionary Params)
36 | {
37 | var cardInfo = Requestor.DoRequest(BaseUrl, "POST", Params);
38 | return Mapper.MapFromJson(cardInfo);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/pingpp/Models/CardList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class CardList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/pingpp/Models/ChargeList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class ChargeList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/CouponList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class CouponList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/CouponTemplate.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 | using Pingpp.Net;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class CouponTemplate : Pingpp
8 | {
9 | [JsonProperty("id")]
10 | public string Id { get; set; }
11 |
12 | [JsonProperty("object")]
13 | public string Object { get; set; }
14 |
15 | [JsonProperty("app")]
16 | public string App { get; set; }
17 |
18 | [JsonProperty("amount_available")]
19 | public int? AmountAvailable { get; set; }
20 |
21 | [JsonProperty("amount_off")]
22 | public int? AmountOff { get; set; }
23 |
24 | [JsonProperty("created")]
25 | public int? Created { get; set; }
26 |
27 | [JsonProperty("expiration")]
28 | public object Expiration { get; set; }
29 |
30 | [JsonProperty("livemode")]
31 | public bool Livemode { get; set; }
32 |
33 | [JsonProperty("max_circulation")]
34 | public int? MaxCirculation { get; set; }
35 | [JsonProperty("max_user_circulation")]
36 | public int MaxUserCirculation { get; set; }
37 |
38 | [JsonProperty("metadata")]
39 | public Dictionary Metadata { get; set; }
40 |
41 | [JsonProperty("name")]
42 | public string Name { get; set; }
43 |
44 | [JsonProperty("percent_off")]
45 | public int? PercentOff { get; set; }
46 | [JsonProperty("refundable")]
47 | public bool Refundable{ get; set;}
48 |
49 | [JsonProperty("times_circulated")]
50 | public int? TimesCirculated { get; set; }
51 |
52 | [JsonProperty("times_redeemed")]
53 | public int? TimesRedeemed { get; set; }
54 |
55 | [JsonProperty("type")]
56 | public int? Type { get; set; }
57 |
58 |
59 | private const string BaseUrl = "/v1/apps";
60 |
61 | public static CouponTemplate Create(string appId, Dictionary couTmplParams)
62 | {
63 | var url = string.Format("{0}/{1}/coupon_templates", BaseUrl, appId);
64 | var couTmpl = Requestor.DoRequest(url, "POST", couTmplParams);
65 | return Mapper.MapFromJson(couTmpl);
66 | }
67 |
68 | public static CouponTemplate Retrieve(string appId, string couTmplId)
69 | {
70 | var url = string.Format("{0}/{1}/coupon_templates/{2}", BaseUrl, appId, couTmplId);
71 | var couTmpl = Requestor.DoRequest(url, "GET");
72 | return Mapper.MapFromJson(couTmpl);
73 | }
74 |
75 | public static CouponTemplate Update(string appId, string couTmplId, Dictionary couTmplParams)
76 | {
77 | var url = string.Format("{0}/{1}/coupon_templates/{2}", BaseUrl, appId, couTmplId);
78 | var couTmpl = Requestor.DoRequest(url, "PUT", couTmplParams);
79 | return Mapper.MapFromJson(couTmpl);
80 | }
81 |
82 | public static Deleted Delete(string appId, string couTmplId)
83 | {
84 | var url = string.Format("{0}/{1}/coupon_templates/{2}", BaseUrl, appId, couTmplId);
85 | var deletedMsg = Requestor.DoRequest(url, "DELETE");
86 | return Mapper.MapFromJson(deletedMsg);
87 | }
88 |
89 | public static CouponTemplateList List(string appId, Dictionary listParams = null)
90 | {
91 | var url = Requestor.FormatUrl(string.Format("{0}/{1}/coupon_templates", BaseUrl, appId), Requestor.CreateQuery(listParams));
92 | var couTmplList = Requestor.DoRequest(url, "GET");
93 | return Mapper.MapFromJson(couTmplList);
94 | }
95 |
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/pingpp/Models/CouponTemplateList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class CouponTemplateList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Customs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class Customs : Pingpp
9 | {
10 | [JsonProperty("id")]
11 | public string Id { get; set; }
12 |
13 | [JsonProperty("app")]
14 | public string App { get; set; }
15 |
16 | [JsonProperty("channel")]
17 | public string Channel { get; set; }
18 |
19 | [JsonProperty("trade_no")]
20 | public string TradeNo { get; set; }
21 |
22 | [JsonProperty("customs_code")]
23 | public string CustomsCode { get; set; }
24 |
25 | [JsonProperty("amount")]
26 | public int? Amount { get; set; }
27 |
28 | [JsonProperty("charge")]
29 | public string Charge { get; set; }
30 |
31 | [JsonProperty("transport_amount")]
32 | public int? TransportAmount { get; set; }
33 |
34 | [JsonProperty("is_split")]
35 | public bool IsSplit { get; set; }
36 |
37 | [JsonProperty("sub_order_no")]
38 | public string SubOrderNo { get; set; }
39 |
40 | [JsonProperty("extra")]
41 | public Dictionary Extra { get; set; }
42 |
43 | [JsonProperty("object")]
44 | public string Object { get; set; }
45 |
46 | [JsonProperty("created")]
47 | public int? Created { get; set; }
48 |
49 | [JsonProperty("time_succeeded")]
50 | public int? TimeSucceeded { get; set; }
51 |
52 | [JsonProperty("status")]
53 | public string Status { get; set; }
54 |
55 | [JsonProperty("failure_code")]
56 | public string FailureCode { get; set; }
57 |
58 | [JsonProperty("failure_msg")]
59 | public string FailureMsg { get; set; }
60 |
61 | [JsonProperty("transaction_no")]
62 | public string TransactionNo { get; set; }
63 |
64 | private const string BaseUrl = "/v1/customs";
65 |
66 | public static Customs Create(Dictionary cuParams)
67 | {
68 | var customs = Requestor.DoRequest(BaseUrl, "POST", cuParams);
69 | return Mapper.MapFromJson(customs);
70 | }
71 |
72 | public static Customs Retrieve(string cuId)
73 | {
74 | var url = string.Format("{0}/{1}", BaseUrl, cuId);
75 | var customs = Requestor.DoRequest(url, "GET");
76 | return Mapper.MapFromJson(customs);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/pingpp/Models/Deleted.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace Pingpp.Models
5 | {
6 | public class Deleted : Pingpp
7 | {
8 | [JsonProperty("deleted")]
9 | public bool IsDeleted { get; set; }
10 |
11 | [JsonProperty("id")]
12 | public string Id { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/pingpp/Models/DeletedSubAppChannel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace Pingpp.Models
5 | {
6 | ///
7 | /// 删除子商户应用支付渠道对象
8 | ///
9 | public class DeletedSubAppChannel : Pingpp
10 | {
11 | [JsonProperty("deleted")]
12 | public bool IsDeleted { get; set; }
13 |
14 | [JsonProperty("channel")]
15 | public string Channel { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/pingpp/Models/Error.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace Pingpp.Models
5 | {
6 | public class Error
7 | {
8 | [JsonProperty("type")]
9 | public string ErrorType { get; set; }
10 |
11 | [JsonProperty("message")]
12 | public string Message { get; set; }
13 |
14 | [JsonProperty("code")]
15 | public string Code { get; set; }
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Event.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class Event : Pingpp
9 | {
10 | [JsonProperty("id")]
11 | public string Id { get; set; }
12 |
13 | [JsonProperty("object")]
14 | public string Object { get; set; }
15 |
16 | [JsonProperty("livemode")]
17 | public bool Livemode { get; set; }
18 |
19 | [JsonProperty("created")]
20 | public int? Created { get; set; }
21 |
22 | [JsonProperty("data")]
23 | public Dictionary Data { get; set; }
24 |
25 | [JsonProperty("pending_webhooks")]
26 | public int? PendingWebhooks { get; set; }
27 |
28 | [JsonProperty("type")]
29 | public string Type { get; set; }
30 |
31 | [JsonProperty("request")]
32 | public string Request { get; set; }
33 |
34 | private const string BaseUrl = "/v1/events";
35 |
36 | public static Event Retrieve(string id)
37 | {
38 | var url = string.Format("{0}/{1}", BaseUrl, id);
39 | var evt = Requestor.DoRequest(url, "Get");
40 | return Mapper.MapFromJson(evt);
41 | }
42 |
43 | }
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/pingpp/Models/EventList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class EventList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Identification.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class Identification : Pingpp
9 | {
10 | [JsonProperty("type")]
11 | public string Type { get; set; }
12 |
13 | [JsonProperty("app")]
14 | public string App { get; set; }
15 |
16 | [JsonProperty("result_code")]
17 | public string ResultCode { get; set; }
18 |
19 | [JsonProperty("message")]
20 | public string Message { get; set; }
21 |
22 | [JsonProperty("paid")]
23 | public bool Paid { get; set; }
24 |
25 | [JsonProperty("data")]
26 | public Dictionary Data { get; set; }
27 |
28 | private const string BaseUrl = "/v1/identification";
29 |
30 | public static Identification Identify(Dictionary iParams)
31 | {
32 | var identified = Requestor.DoRequest(BaseUrl, "POST", iParams);
33 | return Mapper.MapFromJson(identified);
34 | }
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/pingpp/Models/OrderList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class OrderList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/OrderRefund.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 | using Pingpp.Net;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class OrderRefund : Pingpp
8 | {
9 | private const string BaseUrl = "/v1/orders";
10 |
11 | ///
12 | /// 创建订单退款
13 | ///
14 | ///
15 | ///
16 | ///
17 | public static RefundList Create(string id, Dictionary reParams)
18 | {
19 | var url = string.Format("{0}/{1}/order_refunds", BaseUrl, id);
20 | var re = Requestor.DoRequest(url, "POST", reParams);
21 | return Mapper.MapFromJson(re);
22 | }
23 |
24 | ///
25 | /// 查询订单退款
26 | ///
27 | ///
28 | ///
29 | ///
30 | public static Refund Retrieve(string orId, string reId)
31 | {
32 | var url = string.Format("/v1/orders/{0}/order_refunds/{1}", orId, reId);
33 | var re = Requestor.DoRequest(url, "Get");
34 | return Mapper.MapFromJson(re);
35 | }
36 |
37 | ///
38 | /// 查询订单退款列表
39 | ///
40 | ///
41 | ///
42 | ///
43 | public static RefundList List(string orId, Dictionary listParams = null)
44 | {
45 | var refundList = Requestor.DoRequest(Requestor.FormatUrl(string.Format("/v1/orders/{0}/order_refunds", orId), Requestor.CreateQuery(listParams)), "Get");
46 | return Mapper.MapFromJson(refundList);
47 | }
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/pingpp/Models/OrderRefundList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class OrderRefundList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/ProfitTransaction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 | using Pingpp.Exception;
6 |
7 | namespace Pingpp.Models
8 | {
9 | ///
10 | /// 分账明细
11 | ///
12 | public class ProfitTransaction:Pingpp
13 | {
14 | [JsonProperty("id")]
15 | public string Id { get; set; }
16 | [JsonProperty("object")]
17 | public string Object { get; set; }
18 | [JsonProperty("livemode")]
19 | public bool Livemode { get; set; }
20 | [JsonProperty("app")]
21 | public string App { get; set; }
22 | [JsonProperty("amount")]
23 | public int? Amount { get; set; }
24 | [JsonProperty("name")]
25 | public string Name { get; set; }
26 | [JsonProperty("status")]
27 | public string Status { get; set; }
28 | [JsonProperty("description")]
29 | public string Description { get; set; }
30 | [JsonProperty("split_receiver")]
31 | public string SplitReceiver { get; set; }
32 | [JsonProperty("split_profit")]
33 | public string SplitProfit { get; set; }
34 | [JsonProperty("created")]
35 | public int? Created { get; set; }
36 | [JsonProperty("time_finished")]
37 | public int? TimeFinished { get; set; }
38 | [JsonProperty("failure_msg")]
39 | public string FailureMsg { get; set; }
40 |
41 | [JsonProperty("currency")]
42 | public string Currency { get; set; }
43 |
44 | private const string BaseUrl = "/v1/profit_transactions";
45 | ///
46 | /// 分账明细查询
47 | ///
48 | ///
49 | ///
50 | public static ProfitTransaction Retrieve(string ptxnId)
51 | {
52 | var ptxn = Requestor.DoRequest(string.Format("{0}/{1}", BaseUrl, ptxnId), "GET");
53 | return Mapper.MapFromJson(ptxn);
54 | }
55 |
56 | ///
57 | /// 分账明细列表查询
58 | ///
59 | ///
60 | ///
61 | public static ProfitTransactionList List(Dictionary listParams)
62 | {
63 | var ptxns = Requestor.DoRequest(Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(listParams)), "GET");
64 | return Mapper.MapFromJson(ptxns);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/pingpp/Models/ProfitTransactionList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class ProfitTransactionList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Recharge.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using Pingpp.Net;
6 | using Pingpp.Models;
7 |
8 |
9 | namespace Pingpp.Models
10 | {
11 | ///
12 | /// 用户余额充值 接口
13 | ///
14 | public class Recharge : Pingpp
15 | {
16 | [JsonProperty("id")]
17 | public string Id { get; set; }
18 | [JsonProperty("object")]
19 | public string Object { get; set; }
20 | [JsonProperty("app")]
21 | public string App { get; set; }
22 | [JsonProperty("created")]
23 | public int Created { get; set; }
24 | [JsonProperty("livemode")]
25 | public bool Livemode { get; set; }
26 | [JsonProperty("amount")]
27 | public int Amount { get; set; }
28 | [JsonProperty("succeeded")]
29 | public bool Succeeded { get; set; }
30 | [JsonProperty("time_succeeded")]
31 | public int? TimeSucceeded { get; set; }
32 | [JsonProperty("refunded")]
33 | public bool Refunded { get; set; }
34 | [JsonProperty("user")]
35 | public string User { get; set; }
36 | [JsonProperty("from_user")]
37 | public string FromUser { get; set; }
38 | [JsonProperty("user_fee")]
39 | public int UserFee { get; set; }
40 | [JsonProperty("charge")]
41 | public Charge Charge { get; set; }
42 | [JsonProperty("balance_bonus")]
43 | public BalanceBonus BalanceBonus { get; set; }
44 | [JsonProperty("balance_transaction")]
45 | public string BalanceTransaction { get; set; }
46 | [JsonProperty("description")]
47 | public string Description { get; set; }
48 | [JsonProperty("metadata")]
49 | public Dictionary Metadata { get; set; }
50 |
51 | private const string BaseUrl = "/v1/apps/{0}/recharges";
52 |
53 | ///
54 | /// 创建 recharge
55 | ///
56 | ///
57 | public static Recharge Create(string appId, Dictionary createParams)
58 | {
59 | var recharge = Requestor.DoRequest(string.Format(BaseUrl, appId), "POST", createParams);
60 | return Mapper.MapFromJson(recharge);
61 | }
62 |
63 | public static Recharge Retrieve(string appId, string id)
64 | {
65 | var recharge = Requestor.DoRequest(string.Format("{0}/{1}", string.Format(BaseUrl, appId), id), "GET");
66 | return Mapper.MapFromJson(recharge);
67 | }
68 | public static RechargeList List(string appId, Dictionary listParams = null)
69 | {
70 | var rechargeList = Requestor.DoRequest(Requestor.FormatUrl(string.Format(BaseUrl, appId), Requestor.CreateQuery(listParams)), "GET");
71 | return Mapper.MapFromJson(rechargeList);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/pingpp/Models/RechargeList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class RechargeList:Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/RechargeRefund.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using Pingpp.Net;
6 | using Pingpp.Models;
7 |
8 | namespace Pingpp.Models
9 | {
10 | ///
11 | /// 充值退款
12 | ///
13 | public class RechargeRefund:Pingpp
14 | {
15 | private const string BaseUrl = "/v1/apps/{0}/recharges/{1}/refunds";
16 |
17 | ///
18 | /// 创建充值退款
19 | ///
20 | ///
21 | ///
22 | ///
23 | ///
24 | public static Refund Create(string appId, string id, Dictionary refundParams = null)
25 | {
26 | var refund = Requestor.DoRequest(string.Format(BaseUrl, appId, id), "POST", refundParams);
27 | return Mapper.MapFromJson(refund);
28 | }
29 |
30 | ///
31 | /// 查询充值退款对象
32 | ///
33 | ///
34 | ///
35 | ///
36 | ///
37 | public static Refund Retrieve(string appId,string id, string refunId)
38 | {
39 | var refund = Requestor.DoRequest(string.Format("{0}/{1}", string.Format(BaseUrl, appId, id), refunId), "GET");
40 | return Mapper.MapFromJson(refund);
41 | }
42 |
43 | ///
44 | /// 查询充值退款列表
45 | ///
46 | ///
47 | ///
48 | ///
49 | ///
50 | public static RefundList List(string appId, string id, Dictionary listParams = null)
51 | {
52 | var refundList = Requestor.DoRequest(Requestor.FormatUrl(string.Format(BaseUrl, appId, id), Requestor.CreateQuery(listParams)), "GET");
53 | return Mapper.MapFromJson(refundList);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/pingpp/Models/RedEnvelope.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class RedEnvelope : Pingpp
9 | {
10 | [JsonProperty("id")]
11 | public string Id { get; set; }
12 |
13 | [JsonProperty("object")]
14 | public string Object { get; set; }
15 |
16 | [JsonProperty("created")]
17 | public int? Created { get; set; }
18 |
19 | [JsonProperty("received")]
20 | public int? Received { get; set; }
21 |
22 | [JsonProperty("livemode")]
23 | public bool Livemode { get; set; }
24 |
25 | [JsonProperty("status")]
26 | public string Status { get; set; }
27 |
28 | [JsonProperty("app")]
29 | public string App { get; set; }
30 |
31 | [JsonProperty("channel")]
32 | public string Channel { get; set; }
33 |
34 | [JsonProperty("order_no")]
35 | public string OrderNo { get; set; }
36 |
37 | [JsonProperty("transaction_no")]
38 | public string TransactionNo { get; set; }
39 |
40 | [JsonProperty("amount")]
41 | public int? Amount { get; set; }
42 |
43 | [JsonProperty("currency")]
44 | public string Currency { get; set; }
45 |
46 | [JsonProperty("recipient")]
47 | public string Recipient { get; set; }
48 |
49 | [JsonProperty("subject")]
50 | public string Subject { get; set; }
51 |
52 | [JsonProperty("body")]
53 | public string Body { get; set; }
54 |
55 | [JsonProperty("description")]
56 | public string Description { get; set; }
57 |
58 | [JsonProperty("extra")]
59 | public Dictionary Extra { get; set; }
60 |
61 | [JsonProperty("failure_code")]
62 | public string FailureCode { get; set; }
63 |
64 | [JsonProperty("failure_msg")]
65 | public string FailureMsg { get; set; }
66 |
67 | [JsonProperty("metadata")]
68 | public Dictionary Metadata { get; set; }
69 |
70 | private const string BaseUrl = "/v1/red_envelopes";
71 |
72 | public static RedEnvelope Create(Dictionary redParams)
73 | {
74 | var red = Requestor.DoRequest(BaseUrl, "POST", redParams);
75 | return Mapper.MapFromJson(red);
76 | }
77 |
78 | public static RedEnvelope Retrieve(string redId)
79 | {
80 | var url = string.Format("{0}/{1}", BaseUrl, redId);
81 | var red = Requestor.DoRequest(url, "GET");
82 | return Mapper.MapFromJson(red);
83 | }
84 |
85 | public static RedEnvelopeList List(Dictionary listParams = null)
86 | {
87 | var url = Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(listParams));
88 | var reList = Requestor.DoRequest(url, "GET");
89 | return Mapper.MapFromJson(reList);
90 | }
91 |
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/pingpp/Models/RedEnvelopeList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class RedEnvelopeList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Refund.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class Refund : Pingpp
9 | {
10 | [JsonProperty("id")]
11 | public string Id { get; set; }
12 |
13 | [JsonProperty("object")]
14 | public string Object { get; set; }
15 |
16 | [JsonProperty("order_no")]
17 | public string OrderNo { get; set; }
18 |
19 | [JsonProperty("amount")]
20 | public int? Amount { get; set; }
21 |
22 | [JsonProperty("succeed")]
23 | public bool Succeed { get; set; }
24 |
25 | [JsonProperty("status")]
26 | public string Status { get; set; }
27 |
28 | [JsonProperty("created")]
29 | public int? Created { get; set; }
30 |
31 | [JsonProperty("time_succeed")]
32 | public int? TimeSucceed { get; set; }
33 |
34 | [JsonProperty("description")]
35 | public string Description { get; set; }
36 |
37 | [JsonProperty("failure_code")]
38 | public string FailureCode { get; set; }
39 |
40 | [JsonProperty("failure_msg")]
41 | public string FailureMsg { get; set; }
42 |
43 | [JsonProperty("metadata")]
44 | public Dictionary Metadata { get; set; }
45 |
46 | [JsonProperty("charge")]
47 | public string Charge { get; set; }
48 |
49 | [JsonProperty("charge_order_no")]
50 | public string ChargeOrderNo { get; set; }
51 | [JsonProperty("transaction_no")]
52 | public string TransactionNo { get; set; }
53 | [JsonProperty("extra")]
54 | public Dictionary Extra { get; set; }
55 |
56 | private const string BaseUrl = "/v1/charges";
57 |
58 | public static Refund Create(string id, Dictionary reParams)
59 | {
60 | var url = string.Format("{0}/{1}/refunds", BaseUrl, id);
61 | var re = Requestor.DoRequest(url, "POST", reParams);
62 | return Mapper.MapFromJson(re);
63 | }
64 |
65 | public static Refund Retrieve(string chId, string reId)
66 | {
67 | var url = string.Format("/v1/charges/{0}/refunds/{1}", chId, reId);
68 | var re = Requestor.DoRequest(url, "Get");
69 | return Mapper.MapFromJson(re);
70 | }
71 |
72 | public static RefundList List(string id, Dictionary listParams = null)
73 | {
74 | var url = Requestor.FormatUrl(string.Format("/v1/charges/{0}/refunds", id), Requestor.CreateQuery(listParams));
75 | var refundList = Requestor.DoRequest(url, "Get");
76 | return Mapper.MapFromJson(refundList);
77 | }
78 |
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/pingpp/Models/RefundList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | public class RefundList : Pingpp
8 | {
9 | [JsonProperty("object")]
10 | public string Object { get; set; }
11 | [JsonProperty("url")]
12 | public string Url { get; set; }
13 | [JsonProperty("has_more")]
14 | public bool HasMore { get; set; }
15 | [JsonProperty("data")]
16 | public IEnumerable Data { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pingpp/Models/Royalty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | ///
9 | /// 分润对象
10 | ///
11 | public class Royalty :Pingpp
12 | {
13 | [JsonProperty("id")]
14 | public string Id { get; set; }
15 | [JsonProperty("object")]
16 | public string Object { get; set; }
17 | [JsonProperty("payer_app")]
18 | public string PayerApp { get; set; }
19 | [JsonProperty("amount")]
20 | public int Amount { get; set; }
21 | [JsonProperty("created")]
22 | public int Created { get; set; }
23 | [JsonProperty("livemode")]
24 | public bool Livemode { get; set; }
25 | [JsonProperty("status")]
26 | public string Status { get; set; }
27 | [JsonProperty("method")]
28 | public string Method { get; set; }
29 | [JsonProperty("recipient_app")]
30 | public string RecipientApp { get; set; }
31 | [JsonProperty("royalty_transaction")]
32 | public string RoyaltyTransaction { get; set; }
33 | [JsonProperty("time_settled")]
34 | public int? TimeSettled { get; set; }
35 | [JsonProperty("settle_account")]
36 | public string SettleAccount { get; set; }
37 | [JsonProperty("source_app")]
38 | public string SourceApp { get; set; }
39 | [JsonProperty("source_url")]
40 | public string SourceUrl { get; set; }
41 | [JsonProperty("source_no")]
42 | public string SourceNo { get; set; }
43 | [JsonProperty("source_user")]
44 | public string SourceUser { get; set; }
45 | [JsonProperty("description")]
46 | public string Description { get; set; }
47 | [JsonProperty("metadata")]
48 | public Dictionary Metadata { get; set; }
49 | [JsonProperty("royalty_settlement")]
50 | public string RoyaltySettlement { get; set; }
51 |
52 | public const string BaseUrl = "/v1/royalties";
53 |
54 | ///
55 | /// 批量更新分润对象
56 | ///
57 | ///
58 | ///
59 | public static RoyaltyList Update(Dictionary param)
60 | {
61 | var royalty = Requestor.DoRequest(BaseUrl, "PUT", param);
62 | return Mapper.MapFromJson(royalty);
63 | }
64 |
65 | ///
66 | /// 查询分润对象列表
67 | ///
68 | ///
69 | ///
70 | public static RoyaltyList List(Dictionary listParam = null)
71 | {
72 | var url = Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(listParam));
73 | var royalty = Requestor.DoRequest(url, "GET");
74 | return Mapper.MapFromJson(royalty);
75 | }
76 |
77 | ///
78 | /// 查询分润对象
79 | ///
80 | ///
81 | ///
82 | public static Royalty Retrieve(string royaltyId)
83 | {
84 | var url = string.Format("{0}/{1}", BaseUrl, royaltyId);
85 | var royalty = Requestor.DoRequest(url, "GET");
86 | return Mapper.MapFromJson(royalty);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/pingpp/Models/RoyaltyList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 |
5 | namespace Pingpp.Models
6 | {
7 | ///
8 | /// 分润对象列表对象
9 | ///
10 | public class RoyaltyList :Pingpp
11 | {
12 | [JsonProperty("object")]
13 | public string Object { get; set; }
14 | [JsonProperty("url")]
15 | public string Url { get; set; }
16 | [JsonProperty("has_more")]
17 | public bool HasMore { get; set; }
18 | [JsonProperty("data")]
19 | public IEnumerable Data { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/pingpp/Models/RoyaltySettlementList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 |
7 | namespace Pingpp.Models
8 | {
9 | ///
10 | /// 分润结算对象列表
11 | ///
12 | public class RoyaltySettlementList : Pingpp
13 | {
14 | [JsonProperty("object")]
15 | public string Object { get; set; }
16 | [JsonProperty("url")]
17 | public string Url { get; set; }
18 | [JsonProperty("has_more")]
19 | public bool HasMore { get; set; }
20 | [JsonProperty("data")]
21 | public IEnumerable Data { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/pingpp/Models/RoyaltyTemplate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Pingpp.Net;
5 |
6 | namespace Pingpp.Models
7 | {
8 | public class RoyaltyTemplate : Pingpp
9 | {
10 | [JsonProperty("id")]
11 | public string Id { get; set; }
12 | [JsonProperty("app")]
13 | public string App { get; set; }
14 | [JsonProperty("name")]
15 | public string Name { get; set; }
16 | [JsonProperty("created")]
17 | public int Created { get; set; }
18 | [JsonProperty("rule")]
19 | public Dictionary Rule { get; set; }
20 | [JsonProperty("description")]
21 | public string Description { get; set; }
22 | [JsonProperty("object")]
23 | public string Object { get; set; }
24 |
25 | private const string BaseUrl = "/v1/royalty_templates";
26 |
27 | ///