简体   繁体   English

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

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

  1. I create sample a windows form application. 我创建一个Windows窗体应用程序示例。
  2. I download pay pal sdk in visual studio. 我在Visual Studio中下载pay pal sdk。
  3. I create paypal sandbox test account 我创建贝宝沙箱测试帐户

在此处输入图片说明 whre to add the credential details? 需要添加凭证详细信息吗? 在此处输入图片说明

where we put app id: 我们在其中放置应用ID:

Sandbox test AppID: 沙盒测试AppID:

APP-80W284485P519543T APP-80W284485P519543T

I have copy some code for winform app while click a button that is. 单击按钮后,我已经为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));

my reference link is 我的参考链接是

http://pastebin.com/H7VuPQs4
  1. Parsing a PayPal REST Credit Card Transaction Response (JSON) , 解析PayPal REST信用卡交易响应(JSON)
  2. C# PayPal REST API Checkout with Credit Card 使用信用卡进行C#PayPal REST API结帐

please explian to me any other way for credit card transaction for POS(Point Of Sale) through win form application. 请通过获奖表格申请以其他任何方式向我解释POS(销售点)的信用卡交易。

The PayPal .NET SDK is meant for server applications (eg ASP.NET) where application credentials are stored in a secure manner. PayPal .NET SDK适用于以安全方式存储应用程序凭据的服务器应用程序(例如ASP.NET)。 Using the SDK directly from a WinForms application running on a POS system presents a security risk because your merchant account credentials are not stored in a secure manner. 直接从在POS系统上运行的WinForms应用程序使用SDK会带来安全风险,因为您的商家帐户凭据不是以安全方式存储的。 Ideally, the POS system should be communicating back to a secure server somewhere that performs the processing. 理想情况下,POS系统应该与执行该处理的位置处的安全服务器进行通讯。

With that said, this use case is what PayPal Here is designed for. 话虽如此,这是PayPal Here设计的用例。

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

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