【问题标题】:How to know if Delete method was successful in PayPal Web API using PayPal.Net SDK如何使用 PayPal.Net SDK 在 PayPal Web API 中知道 Delete 方法是否成功
【发布时间】:2016-09-21 03:13:33
【问题描述】:

以下是 .Net 的 PayPal 示例中的一些代码,其中正在删除发票。我从:https://github.com/paypal/PayPal-NET-SDK/tree/master/Samples/Source 下载了这个。删除发票的代码通过以下调用 createdInvoice.Delete 来执行此操作,该调用返回 void。

问题:由于此方法返回 void,如何知道删除成功?

使用 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

【问题讨论】:

    标签: c# asp.net webforms paypal


    【解决方案1】:

    经过大量研究,我发现如果删除失败,Delete 方法会抛出异常。因此,可以有把握地假设,如果在调用Delete 方法时没有抛出异常,则发票删除成功。

    【讨论】:

      猜你喜欢
      • 2018-09-11
      • 1970-01-01
      • 1970-01-01
      • 2011-08-10
      • 2010-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多