public SendInvoice ( |
||
sendInvoiceRequest | ||
리턴 |
public void SendInvoiceTest() { SendInvoiceRequest sr = new SendInvoiceRequest(); sr.requestEnvelope = new RequestEnvelope(); sr.requestEnvelope.errorLanguage = "en_US"; sr.requestEnvelope.detailLevel = DetailLevelCode.RETURNALL; SendInvoiceResponse sir = null; CreateInvoiceResponse cir = null; try { InvoiceService service = new InvoiceService(); cir = service.CreateInvoice(this.cr); Assert.AreEqual(AckCode.SUCCESS, cir.responseEnvelope.ack); sr.invoiceID = cir.invoiceID; sir = service.SendInvoice(sr); } catch (System.Exception e) { Console.Write(e.Message); Assert.Fail(e.Message); } Assert.AreEqual(AckCode.SUCCESS, sir.responseEnvelope.ack); Assert.AreEqual(cir.invoiceID, sir.invoiceID); }
// # SendInvoice API Operation // Use the SendInvoice API operation to send an invoice to a payer, and notify the payer of the pending invoice. public SendInvoiceResponse SendInvoiceAPIOperation() { // Create the SendInvoiceResponse object SendInvoiceResponse responseSendInvoice = new SendInvoiceResponse(); try { // # SendInvoiceRequest // Use the SendInvoiceRequest message to send an invoice to a payer, and // notify the payer of the pending invoice. // The code for the language in which errors are returned, which must be // en_US. RequestEnvelope envelopeRequest = new RequestEnvelope(); envelopeRequest.errorLanguage = "en_US"; // SendInvoiceRequest which takes mandatory params: // // * `Request Envelope` - Information common to each API operation, such // as the language in which an error message is returned. // * `Invoice ID` - ID of the invoice to send. SendInvoiceRequest requestSendInvoice = new SendInvoiceRequest(envelopeRequest, "INV2-ZC9R-X6MS-RK8H-4VKJ"); // Create the service wrapper object to make the API call InvoiceService service = new InvoiceService(); // # API call // Invoke the SendInvoice method in service responseSendInvoice = service.SendInvoice(requestSendInvoice); if (responseSendInvoice != null) { // Response envelope acknowledgement string acknowledgement = "SendInvoice API Operation - "; acknowledgement += responseSendInvoice.responseEnvelope.ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseSendInvoice.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // ID of the created invoice. logger.Info("Invoice ID : " + responseSendInvoice.invoiceID + "\n"); Console.WriteLine("Invoice ID : " + responseSendInvoice.invoiceID + "\n"); } // # Error Values else { List<ErrorData> errorMessages = responseSendInvoice.error; foreach (ErrorData error in errorMessages) { logger.Debug("API Error Message : " + error.message); Console.WriteLine("API Error Message : " + error.message + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return responseSendInvoice; }