用于 POS 信用卡刷卡的 Windows 窗体应用程序中的贝宝沙盒测试帐户
Posted
技术标签:
【中文标题】用于 POS 信用卡刷卡的 Windows 窗体应用程序中的贝宝沙盒测试帐户【英文标题】:paypal sandbox test account in windows form application in C# for POS credit card swipe 【发布时间】:2015-07-09 23:09:23 【问题描述】:-
我创建了一个 Windows 窗体应用程序示例。
我在 Visual Studio 中下载了 pay pal sdk。
我创建了paypal沙盒测试账号
在哪里添加凭据详细信息?
我们放置应用程序 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
-
Parsing a PayPal REST Credit Card Transaction Response (JSON),
C# PayPal REST API Checkout with Credit Card
请通过win form申请向我解释POS(销售点)信用卡交易的任何其他方式。
【问题讨论】:
【参考方案1】:PayPal .NET SDK 适用于以安全方式存储应用程序凭据的服务器应用程序(例如 ASP.NET)。直接从在 POS 系统上运行的 WinForms 应用程序使用 SDK 存在安全风险,因为您的商家帐户凭据未以安全方式存储。理想情况下,POS 系统应该与某处执行处理的安全服务器进行通信。
话虽如此,这个用例正是 PayPal Here 的设计目的。
【讨论】:
以上是关于用于 POS 信用卡刷卡的 Windows 窗体应用程序中的贝宝沙盒测试帐户的主要内容,如果未能解决你的问题,请参考以下文章
我试图捕捉刷卡的输入,但我被困在使用 C# Windows 窗体