繁体   English   中英

C#中用于POS信用卡刷卡的Windows窗体应用程序中的Paypal沙箱测试帐户

[英]paypal sandbox test account in windows form application in C# for POS credit card swipe

  1. 我创建一个Windows窗体应用程序示例。
  2. 我在Visual Studio中下载pay pal sdk。
  3. 我创建贝宝沙箱测试帐户

在此处输入图片说明 需要添加凭证详细信息吗? 在此处输入图片说明

我们在其中放置应用ID:

沙盒测试AppID:

APP-80W284485P519543T

单击按钮后,我已经为winform应用程序复制了一些代码。

 Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
            sdkConfig.Add("mode", "sandbox");
            accessToken = new OAuthTokenCredential("AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd", "EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX", sdkConfig).GetAccessToken();
HttpContext CurrContext = HttpContext.Current;
            APIContext apiContext = new APIContext(accessToken);
            Item item = new Item();
            item.name = _ItemDescription;
            item.currency = "USD";
            item.price = _Amount;
            item.quantity = "1";
            item.sku = _UPC;

            List<Item> itms = new List<Item>();
            itms.Add(item);
            ItemList itemList = new ItemList();
            itemList.items = itms;

            Address billingAddress = new Address();
            billingAddress.city = "Chennai";
            billingAddress.country_code = "US";
            billingAddress.line1 = "11/12";
            billingAddress.line2 = "Andavar nager main street";
            billingAddress.postal_code = "600089";
            billingAddress.state = "Tamil nadu";

            CreditCard crdtCard = new CreditCard();
            crdtCard.billing_address = billingAddress;
            crdtCard.cvv2 = 2222;
            crdtCard.expire_month = 4;
            crdtCard.expire_year = 2020;
            crdtCard.first_name = "Arul";
            crdtCard.last_name = "Murugan";
            crdtCard.number = "4032039053301695";
            crdtCard.type = "visa";

            Details details = new Details();
            details.tax = "0";
            details.shipping = "0";
            details.subtotal = _Amount;

            Amount amont = new Amount();
            amont.currency = "USD";
            amont.total = _Amount;
            amont.details = details;

            Transaction tran = new Transaction();
            tran.amount = amont;
            tran.description = _ItemDescription;
            tran.item_list = itemList;

            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(tran);

            FundingInstrument fundInstrument = new FundingInstrument();
            fundInstrument.credit_card = crdtCard;

            List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
            fundingInstrumentList.Add(fundInstrument);

            PayerInfo pi = new PayerInfo();
            pi.email = "sysumurugan-facilitator@gmail.com";
            pi.first_name = "Arul";
            pi.last_name = "Murugan";


            Payer payr = new Payer();
            payr.funding_instruments = fundingInstrumentList;
            payr.payment_method = "credit_card";
            payr.payer_info = pi;

            pi.shipping_address = new ShippingAddress
            {
                city = "San Mateo",
                country_code = "US",
                line1 = "SO TEST",
                line2 = "",
                postal_code = "94002",
                state = "CA",
            }; 

            Payment paymnt = new Payment();
            paymnt.intent = "sale";
            paymnt.payer = payr;
            paymnt.transactions = transactions;
            try
            {
                Payment createdPayment = paymnt.Create(apiContext);
                CurrContext.Items.Add("ResponseJson", JObject.Parse(createdPayment.ConvertToJson()).ToString(Formatting.Indented));
            }
            catch (PayPal.Exception.PayPalException ex)
            {
                if (ex.InnerException is PayPal.Exception.ConnectionException)
                {
                    CurrContext.Response.Write(((PayPal.Exception.ConnectionException)ex.InnerException).Response);
                }
                else
                {
                    CurrContext.Response.Write(ex.Message);
                }
            }
            catch (Exception es)
            {
                MessageBox.Show( es.ToString());
            }
            CurrContext.Items.Add("RequestJson", JObject.Parse(paymnt.ConvertToJson()).ToString(Formatting.Indented));

我的参考链接是

http://pastebin.com/H7VuPQs4
  1. 解析PayPal REST信用卡交易响应(JSON)
  2. 使用信用卡进行C#PayPal REST API结帐

请通过获奖表格申请以其他任何方式向我解释POS(销售点)的信用卡交易。

PayPal .NET SDK适用于以安全方式存储应用程序凭据的服务器应用程序(例如ASP.NET)。 直接从在POS系统上运行的WinForms应用程序使用SDK会带来安全风险,因为您的商家帐户凭据不是以安全方式存储的。 理想情况下,POS系统应该与执行该处理的位置处的安全服务器进行通讯。

话虽如此,这是PayPal Here设计的用例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM