Below is some code from PayPal Samples for .Net where an invoice is being deleted. I downloaded this from : https://github.com/paypal/PayPal-NET-SDK/tree/master/Samples/Source . The code that deletes an invoice does so by making the following call createdInvoice.Delete
which returns a void.
Question : How does one know that delete was successful since this method returns a void?
PayPal code to Delete a created invoice using NET SDK for 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
After much research, I found that the Delete
method throws an exception if delete fails. Hence, one can safely assume that if there was no exception thrown when call to Delete
method was made, then the delete of invoice succeeded.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.