The company that I work for has a legacy WinForms application used by Sales and Customer Service to help customers create orders as opposed to the customer creating an order on the website. We are wanting to convert our CC Payment gateway to Braintree, but I cannot figure out how to create a Payment Nonce so that I can create a payment method with the CC information. Has anyone successfully integrated the Braintree SDK into a WinForms project?
I attempted to create a transaction request but without the PaymentNonce. I used just the customer Id which used the default payment method for that customer. That works great if
- There is a customer
- There is a default payment method
However, if I want to create a transaction for a customer that doesn't exist or the customer does not have a payment method for the credit card the user has provided, then I am stumped. I don't know how to provide the CC info and in what object to pass the card data (number, exp. date, CVV) the Braintree.CreditCard object is inaccessible due to its protection level, so that is not how to pass it. ???♂?
below is the transaction where I tried to pass the credit card information:
transaction = new TransactionRequest()
{
Amount = paymentData.Amount,
CustomerId = customerId,
DiscountAmount = paymentData.CouponDiscount + paymentData.DiscAmount,
ShippingAmount = paymentData.ShipCharge,
LineItems = lineItems.ToArray(),
TaxAmount = paymentData.Taxes,
TaxExempt = paymentData.Taxes == 0 ? true : false,
BillingAddress = new AddressRequest()
{
Company = address.Company,
FirstName = paymentData.FirstName,
LastName = paymentData.LastName,
Locality = address.City,
Region = address.State,
PostalCode = address.Zip,
StreetAddress = address.Address1,
ExtendedAddress = address.Address2,
CountryCodeAlpha2 = address.CountryCode
},
Options = new TransactionOptionsRequest()
{
SubmitForSettlement = paymentData.TransType == "A" ? false : true
},
Braintree.CreditCard = new Braintree.CreditCard()
{
CardholderName = paymentData.AccountName,
Cvv = paymentData.CVV,
ExpirationMonth = paymentData.ExpMonth,
ExpirationYear = paymentData.ExpYear,
UniqueNumberIdentifier = paymentData.AccountNumber
},
};
var customFields = new Dictionary<string, string>();
customFields.Add("cartid", paymentData.IsCart ? paymentData.Id.ToString() : "0");
customFields.Add("orderid", paymentData.IsCart ? "0" : paymentData.Id.ToString());
customFields.Add("userid", paymentData.CustId);
transaction.CustomFields = customFields;
Result<Braintree.Transaction> result = GetGateway().Transaction.Sale(transaction);
question from:
https://stackoverflow.com/questions/65851748/in-braintree-net-how-do-i-generate-a-paymentnonce 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…