コード例 #1
0
        /// <summary>
        ///
        /// 本示例介绍对余额提现和查看用户余额明细对象/对象列表
        /// 余额的消费、退款请查看 OrderDemo 示例
        /// 查看用户当前余额请使用查看 User 对象接口
        ///
        /// </summary>
        public static void Example(string appId)
        {
            var uid      = "test_user_001";
            var orParams = new Dictionary <string, object>
            {
                { "app", appId },
                { "uid", uid },
                { "merchant_order_no", new Random().Next(1, 999999999) },
                { "channel", "wx" }, // 充值接口需要设置支付渠道
                { "amount", 1 },
                { "currency", "cny" },
                { "client_ip", "127.0.0.1" },
                { "subject", "Your Subject" },
                { "body", "Your Body" },
                { "description", "Your description" },
            };

            var wdParams = new Dictionary <string, object>
            {
                { "amount", 1 },
                { "order_no", "20160829133002" },
                { "description", "withdraw request" },
                { "extra", new Dictionary <string, object>
                  {
                      { "card_number", "6225210207073918" },
                      { "user_name", "姓名" },
                      { "open_bank_code", "0102" },
                      { "prov", "上海" },
                      { "city", "上海" }
                  } },
            };

            Console.WriteLine("****创建提现 Withdrawal 对象(发起提现申请)****");
            var wd = Withdrawal.Request(appId, wdParams);

            Console.WriteLine(wd);
            Console.WriteLine();

            Console.WriteLine("****提现完成 Withdrawal 对象****");
            Console.WriteLine(Withdrawal.Confirm(appId, wd.Id));
            Console.WriteLine();

            Console.WriteLine("****查看用户交易明细 Balance Transaction 对象列表****");
            var balanceList = BalanceTransaction.List(appId);

            Console.WriteLine(balanceList);
            Console.WriteLine();

            Console.WriteLine("****查看用户交易明细 Balance Transaction 对象****");
            Console.WriteLine(BalanceTransaction.Retrieve(appId, balanceList.Data.First().Id));
            Console.WriteLine();
        }
コード例 #2
0
        /// <summary>
        /// 本示例介绍如何创余额提现申请(Userwithdrawals 对象)、更新 Userwithdrawals 对象 获取列表和明细
        /// </summary>
        /// <param name="appId"></param>
        public static void Example(string appId)
        {
            Console.WriteLine("****发起余额提现请求创建余额体现 withdrawals对象-unionpay渠道****");
            var withDrawal = unionpayWithdrawal(appId);

            Console.WriteLine(withDrawal);
            Console.WriteLine();

            Console.WriteLine("****发起余额提现请求创建余额体现 withdrawals对象-alipay渠道****");
            Console.WriteLine(alipayWithdrawal(appId));
            Console.WriteLine();

            Console.WriteLine("****发起余额提现请求创建余额体现 withdrawals对象-wx_pub渠道****");
            Console.WriteLine(wxPubWithdrawal(appId));
            Console.WriteLine();

            Console.WriteLine("****发起余额提现请求创建余额体现 withdrawals对象-allinpay渠道****");
            Console.WriteLine(allinpayWithdrawal(appId));
            Console.WriteLine();

            Console.WriteLine("****发起余额提现请求创建余额体现 withdrawals对象-jdpay渠道****");
            Console.WriteLine(jdpayWithdrawal(appId));
            Console.WriteLine();

            var listParams = new Dictionary <string, object> {
                { "page", 1 },
                { "per_page", 10 },
                { "status", "created" },
                { "channel", "alipay" }   //提现使用渠道。银联:unionpay,支付宝:alipay,微信:wx_pub。
            };

            Console.WriteLine("****发起余额提现列表查询 Userwithdrawals 对象****");
            Console.WriteLine(Withdrawal.List(appId, listParams));

            Console.WriteLine("****余额提现对象查询 Userwithdrawals 对象****");
            Console.WriteLine(Withdrawal.Retrieve(appId, withDrawal.Id));

            Console.WriteLine("****发起余额提现请求确认 Userwithdrawals 对象****");
            Console.WriteLine(Withdrawal.Confirm(appId, withDrawal.Id));
            Console.WriteLine();

            Console.WriteLine("****发起余额提现请求取消 Userwithdrawals 对象****");
            Console.WriteLine(Withdrawal.Cancel(appId, withDrawal.Id));
            Console.WriteLine();
        }