簡體   English   中英

如何知道使用PayPal.Net SDK在PayPal Web API中刪除方法是否成功

[英]How to know if Delete method was successful in PayPal Web API using PayPal.Net SDK

以下是PayPal Samples for .Net的一些代碼,其中發票已被刪除。 我從以下網址下載了此文件: https : //github.com/paypal/PayPal-NET-SDK/tree/master/Samples/Source 刪除發票的代碼通過進行以下調用createdInvoice.Delete調用來實現,該調用返回一個空值。

問題 :如何知道刪除成功,因為此方法返回空值?

使用NET SDK for PayPal刪除創建的發票的PayPal代碼

// ^ Ignore workflow code segment
#region Track Workflow
this.flow.AddNewRequest("Create the invoice", invoice);
#endregion

// Create the invoice
var createdInvoice = invoice.Create(apiContext);

// ^ Ignore workflow code segment
#region Track Workflow
this.flow.RecordResponse(createdInvoice);
this.flow.AddNewRequest("Delete the invoice");
#endregion

createdInvoice.Delete(apiContext);//This method returns a void, so how we   
                                  //know it succeeded?????

// ^ Ignore workflow code segment
#region Track Workflow
this.flow.RecordActionSuccess("Invoice deleted successfully.");
#endregion

經過大量研究,我發現如果刪除失敗,則Delete方法將引發異常。 因此,可以放心地假設,如果在調用Delete方法時沒有引發異常,則發票刪除成功。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM