QuickBooks Online SDK 支付信用卡问题
QuickBooks Online SDK Payment Credit Card Issue
我正在尝试使用 QuickBooks Online SDK 提交信用卡付款,但是当我 运行 我的代码出现以下错误时:
Raw Credit Card Number not supported. Tokenized Credit Card Number
Required
这是我的资料。谁能解释一下我如何在以这种方式使用之前使用 sdk 对卡号进行标记?
public Payment PaymentCreditCard(Order order, ServiceContext qboContextoAuth)
{
Payment payment = new Payment();
payment.TxnDate = Convert.ToDateTime(order.DateCreated);
payment.TxnDateSpecified = true;
Account depositAccount = Helper.FindOrAddAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset);
payment.DepositToAccountRef = new ReferenceType()
{
name = depositAccount.Name,
Value = depositAccount.Id
};
PaymentMethod paymentMethod = Helper.FindOrAdd<PaymentMethod>(qboContextoAuth, new PaymentMethod());
payment.PaymentMethodRef = new ReferenceType()
{
name = paymentMethod.Name,
Value = paymentMethod.Id
};
Customer customer = Helper.FindOrAdd<Customer>(qboContextoAuth, new Customer());
payment.CustomerRef = new ReferenceType()
{
name = customer.DisplayName,
Value = customer.Id
};
payment.PaymentType = PaymentTypeEnum.CreditCard;
CreditCardPayment creditCardPayment = new CreditCardPayment();
CreditChargeInfo creditChargeInfo = new CreditChargeInfo();
creditChargeInfo.BillAddrStreet = order.BillingAddress;
creditChargeInfo.CcExpiryMonth = Convert.ToInt32(order.CCExpMonth);
creditChargeInfo.CcExpiryMonthSpecified = true;
creditChargeInfo.CcExpiryYear = Convert.ToInt32(order.CCExpYear);
creditChargeInfo.CcExpiryYearSpecified = true;
creditChargeInfo.CCTxnMode = CCTxnModeEnum.CardNotPresent;
creditChargeInfo.CCTxnModeSpecified = true;
creditChargeInfo.CCTxnType = CCTxnTypeEnum.Charge;
creditChargeInfo.CCTxnTypeSpecified = true;
//reditChargeInfo.CommercialCardCode = "Cardcode" + Helper.GetGuid().Substring(0, 5);
creditChargeInfo.NameOnAcct = order.BillingName;
creditChargeInfo.Number = order.CCNum;
creditChargeInfo.PostalCode = order.BillingZip;
creditCardPayment.CreditChargeInfo = creditChargeInfo;
payment.AnyIntuitObject = creditCardPayment;
payment.TotalAmt = Convert.ToDecimal(order.TotalAmount);
payment.TotalAmtSpecified = true;
payment.UnappliedAmt = Convert.ToDecimal(order.TotalAmount);
payment.UnappliedAmtSpecified = true;
//Adding the Payment
Payment added = Helper.Add<Payment>(qboContextoAuth, payment);
return added;
}
根据我从原始 API 收集的信息,这是我需要的:
https://developer.intuit.com/app/developer/qbpayments/docs/api/resources/all-entities/tokens
但是我好像在SDK中找不到这样的功能。有没有人有这方面的经验?
这是截至今天 (03/14/19) 此问题的解决方案:
public string getCardToken()
{
string cardToken="";
JObject jsonDecodedResponse;
string cardTokenJson = "";
string cardTokenEndpoint = "quickbooks/v4/payments/tokens";
string uri= paymentsBaseUrl + cardTokenEndpoint;
string cardTokenRequestBody = "{\"card\":{\"expYear\":\"2020\",\"expMonth\":\"02\",\"address\":{\"region\":\"CA\",\"postalCode\":\"94086\",\"streetAddress\":\"1130 Kifer Rd\",\"country\":\"US\",\"city\":\"Sunnyvale\"},\"name\":\"emulate=0\",\"cvc\":\"123\",\"number\":\"4111111111111111\"}}";
// send the request (token api call does not requires Authorization header, rest all payments call do)
HttpWebRequest cardTokenRequest = (HttpWebRequest)WebRequest.Create(uri);
cardTokenRequest.Method = "POST";
cardTokenRequest.ContentType = "application/json";
cardTokenRequest.Headers.Add("Request-Id", Guid.NewGuid().ToString());//assign guid
byte[] _byteVersion = Encoding.ASCII.GetBytes(cardTokenRequestBody);
cardTokenRequest.ContentLength = _byteVersion.Length;
Stream stream = cardTokenRequest.GetRequestStream();
stream.Write(_byteVersion, 0, _byteVersion.Length);
stream.Close();
// get the response
HttpWebResponse cardTokenResponse = (HttpWebResponse)cardTokenRequest.GetResponse();
using (Stream data = cardTokenResponse.GetResponseStream())
{
cardTokenJson= new StreamReader(data).ReadToEnd();
jsonDecodedResponse = JObject.Parse(cardTokenJson);
if (!string.IsNullOrEmpty(jsonDecodedResponse.TryGetString("value")))
{
cardToken = jsonDecodedResponse["value"].ToString();
}
}
return cardToken;
}
他们有一天可能会添加一个 SDK 选项来做同样的事情,但它到今天还不可用!
我正在尝试使用 QuickBooks Online SDK 提交信用卡付款,但是当我 运行 我的代码出现以下错误时:
Raw Credit Card Number not supported. Tokenized Credit Card Number Required
这是我的资料。谁能解释一下我如何在以这种方式使用之前使用 sdk 对卡号进行标记?
public Payment PaymentCreditCard(Order order, ServiceContext qboContextoAuth)
{
Payment payment = new Payment();
payment.TxnDate = Convert.ToDateTime(order.DateCreated);
payment.TxnDateSpecified = true;
Account depositAccount = Helper.FindOrAddAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset);
payment.DepositToAccountRef = new ReferenceType()
{
name = depositAccount.Name,
Value = depositAccount.Id
};
PaymentMethod paymentMethod = Helper.FindOrAdd<PaymentMethod>(qboContextoAuth, new PaymentMethod());
payment.PaymentMethodRef = new ReferenceType()
{
name = paymentMethod.Name,
Value = paymentMethod.Id
};
Customer customer = Helper.FindOrAdd<Customer>(qboContextoAuth, new Customer());
payment.CustomerRef = new ReferenceType()
{
name = customer.DisplayName,
Value = customer.Id
};
payment.PaymentType = PaymentTypeEnum.CreditCard;
CreditCardPayment creditCardPayment = new CreditCardPayment();
CreditChargeInfo creditChargeInfo = new CreditChargeInfo();
creditChargeInfo.BillAddrStreet = order.BillingAddress;
creditChargeInfo.CcExpiryMonth = Convert.ToInt32(order.CCExpMonth);
creditChargeInfo.CcExpiryMonthSpecified = true;
creditChargeInfo.CcExpiryYear = Convert.ToInt32(order.CCExpYear);
creditChargeInfo.CcExpiryYearSpecified = true;
creditChargeInfo.CCTxnMode = CCTxnModeEnum.CardNotPresent;
creditChargeInfo.CCTxnModeSpecified = true;
creditChargeInfo.CCTxnType = CCTxnTypeEnum.Charge;
creditChargeInfo.CCTxnTypeSpecified = true;
//reditChargeInfo.CommercialCardCode = "Cardcode" + Helper.GetGuid().Substring(0, 5);
creditChargeInfo.NameOnAcct = order.BillingName;
creditChargeInfo.Number = order.CCNum;
creditChargeInfo.PostalCode = order.BillingZip;
creditCardPayment.CreditChargeInfo = creditChargeInfo;
payment.AnyIntuitObject = creditCardPayment;
payment.TotalAmt = Convert.ToDecimal(order.TotalAmount);
payment.TotalAmtSpecified = true;
payment.UnappliedAmt = Convert.ToDecimal(order.TotalAmount);
payment.UnappliedAmtSpecified = true;
//Adding the Payment
Payment added = Helper.Add<Payment>(qboContextoAuth, payment);
return added;
}
根据我从原始 API 收集的信息,这是我需要的:
https://developer.intuit.com/app/developer/qbpayments/docs/api/resources/all-entities/tokens
但是我好像在SDK中找不到这样的功能。有没有人有这方面的经验?
这是截至今天 (03/14/19) 此问题的解决方案:
public string getCardToken()
{
string cardToken="";
JObject jsonDecodedResponse;
string cardTokenJson = "";
string cardTokenEndpoint = "quickbooks/v4/payments/tokens";
string uri= paymentsBaseUrl + cardTokenEndpoint;
string cardTokenRequestBody = "{\"card\":{\"expYear\":\"2020\",\"expMonth\":\"02\",\"address\":{\"region\":\"CA\",\"postalCode\":\"94086\",\"streetAddress\":\"1130 Kifer Rd\",\"country\":\"US\",\"city\":\"Sunnyvale\"},\"name\":\"emulate=0\",\"cvc\":\"123\",\"number\":\"4111111111111111\"}}";
// send the request (token api call does not requires Authorization header, rest all payments call do)
HttpWebRequest cardTokenRequest = (HttpWebRequest)WebRequest.Create(uri);
cardTokenRequest.Method = "POST";
cardTokenRequest.ContentType = "application/json";
cardTokenRequest.Headers.Add("Request-Id", Guid.NewGuid().ToString());//assign guid
byte[] _byteVersion = Encoding.ASCII.GetBytes(cardTokenRequestBody);
cardTokenRequest.ContentLength = _byteVersion.Length;
Stream stream = cardTokenRequest.GetRequestStream();
stream.Write(_byteVersion, 0, _byteVersion.Length);
stream.Close();
// get the response
HttpWebResponse cardTokenResponse = (HttpWebResponse)cardTokenRequest.GetResponse();
using (Stream data = cardTokenResponse.GetResponseStream())
{
cardTokenJson= new StreamReader(data).ReadToEnd();
jsonDecodedResponse = JObject.Parse(cardTokenJson);
if (!string.IsNullOrEmpty(jsonDecodedResponse.TryGetString("value")))
{
cardToken = jsonDecodedResponse["value"].ToString();
}
}
return cardToken;
}
他们有一天可能会添加一个 SDK 选项来做同样的事情,但它到今天还不可用!