基本信息
源码名称:winform 生成支付宝二维码
源码大小:2.07M
文件格式:.zip
开发语言:C#
更新时间:2019-01-07
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Alipay;
using System.Threading;

namespace ZFB
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        Payment PAy = new Payment();
        //生成二维码
        private void button1_Click(object sender, EventArgs e)
        {
            string order_no = "18162359905_014";
            string order_amount = "0.01";
            string order_subject = "就诊卡充值";
            string Error = string.Empty;
            Bitmap image = PAy.Alipay(order_no, order_amount, order_subject, ref Error);
            if (image == null)
            {
                MessageBox.Show(Error);
            }
            else
            {
                pbx_QRcode.Image = image;
                //轮询订单结果
                //根据业务需要,选择是否新起线程进行轮询
                ParameterizedThreadStart ParStart = new ParameterizedThreadStart(LoopQuery);
                Thread myThread = new Thread(ParStart);
                object o = order_no;
                myThread.Start(o);
            }
        }
        //判断是否支付成功 轮询
        public void LoopQuery(object o)
        {
            int count = 10;       //轮询次数
            int interval = 2000;  //轮询间隔时间
            int Results = PAy.PaymentResults(o.ToString(), count, interval);
            if (Results == 0)
            {
                MessageBox.Show("支付成功");
            }
            else
            {
                MessageBox.Show("支付失败");
            }
        }
        //查询订单
        private void button2_Click(object sender, EventArgs e)
        {
            string order_no="18162359905_013";
            string result = string.Empty;
            PAy.Query(order_no,ref result);           
            MessageBox.Show(result);
        }
        //订单退款
        private void button3_Click(object sender, EventArgs e)
        {
           string order_no="18162359905_004";
           string request_no="";
           string refund_amount = "0.01";
           string result = string.Empty;
           PAy.Refund(order_no, request_no, refund_amount, ref  result);
           if (result.Trim() == "0")
           {
               result = "退款成功";
           }
           if (result.Trim() == "1")
           {
               result = "退款失败";
           }
           MessageBox.Show(result);
        }
    }
}