Paypal移动支付验证在.Net错误java.lang.NullPointerException中失败
本文关键字:lang java NullPointerException 失败 错误 Net 移动 验证 Paypal | 更新日期: 2023-09-27 18:00:43
我需要验证使用移动设备完成的贝宝支付,但它总是返回java.lang.NullPointerException错误
C#代码
// Get a reference to the config
var config = ConfigManager.Instance.GetProperties();
// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var PayID = "PAY-6PU626847B294848Y6KEWXHY";
var payment = Payment.Get(apiContext, PayID);
远程服务器返回错误:(404)找不到。
我得到了解决方案,头信息缺少
var apiContext = new APIContext(accessToken);
if (apiContext.HTTPHeaders == null)
{
apiContext.HTTPHeaders = new Dictionary<string, string>();
apiContext.HTTPHeaders.Add("Content-Type", "application/json");
apiContext.HTTPHeaders.Add("Authorization", accessToken);
}
感谢