[英]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.