我設法使用Strip.net DLL的一個版本創建付款方式,但即時通訊有問題處理錯誤。我得到了這個。Stripe C#錯誤處理
try
{
StripeCustomer current = GetCustomer();
// int? days = getaTraildays();
//if (days != null)
//{
int chargetotal = 300; //Convert.ToInt32((3.33*Convert.ToInt32(days)*100));
var mycharge = new StripeChargeCreateOptions();
mycharge.AmountInCents = chargetotal;
mycharge.Currency = "USD";
mycharge.CustomerId = current.Id;
string key = "sk_test_XXX";
var chargeservice = new StripeChargeService(key);
StripeCharge currentcharge = chargeservice.Create(mycharge);
//}
}
catch (StripeException)
{
lblerror.Text = "Please check your card information and try again";
}
會趕上錯誤,讓用戶知道有這個問題,但即時通訊新的理解,爲什麼它仍然顯示錯誤,如果過程的工作。我知道它是如何編寫漁獲物的問題,但我不確定如何處理,以及我曾經如此努力的一切都失敗了。我想要做的就是重定向到另一個頁面。任何想法
++更新
與奧利維爾Jacot-Descombes一些幫助我改變了我的代碼
catch (StripeException ex)
{
lblerror.Text = (ex.Message);
}
,並能夠取得更好的效果
您的'嘗試'塊中的代碼是否有可能拋出一個不同的異常?否則(從提供的小代碼),StripeException應該被捕獲和壓制。 – jsirr13
你的問題似乎是關於第三方API拋出的異常。我建議你查看那裏的錯誤。我們不是該API的開發者。 – tnw
在輸入try-block之前,你是否清除了'lblerror.Text'? –