예제 #1
0
        private void SendInvoice(HttpContext context)
        {
            String invoiceId = context.Request.Params["invoiceId"];

            SendInvoiceRequest sr = new SendInvoiceRequest();

            sr.invoiceID       = invoiceId;
            sr.requestEnvelope = new RequestEnvelope(ERROR_LANGUAGE);

            InvoiceService      service;
            SendInvoiceResponse sir = null;

            try
            {
                service = getService(context);
                sir     = service.SendInvoice(sr);
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary <string, string> keyResponseParams = new Dictionary <string, string>();

            keyResponseParams.Add("API status", sir.responseEnvelope.ack.ToString());
            keyResponseParams.Add("correlationId", sir.responseEnvelope.correlationId);
            keyResponseParams.Add("invoiceId", sir.invoiceID);
            keyResponseParams.Add("invoiceUrl", sir.invoiceURL);
            displayResponse(context, "SendInvoice", keyResponseParams, service.getLastRequest(),
                            service.getLastResponse(), sir.error, null);
        }
예제 #2
0
        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);
        }
예제 #3
0
        /**
         * AUTO_GENERATED
         */
        public SendInvoiceResponse SendInvoice(SendInvoiceRequest sendInvoiceRequest, string apiUserName)
        {
            string  response = Call("SendInvoice", sendInvoiceRequest.ToNVPString(""), apiUserName);
            NVPUtil util     = new NVPUtil();

            return(SendInvoiceResponse.CreateInstance(util.ParseNVPString(response), "", -1));
        }
    public void SendInvoice()
    {
        SendInvoiceSample   sample = new SendInvoiceSample();
        SendInvoiceResponse responseSendInvoice = sample.SendInvoiceAPIOperation();

        Assert.IsNotNull(responseSendInvoice);
        // Please change the sample inputs according to the documentation in the sample for the following assertion:
        // Assert.AreEqual(responseSendInvoice.responseEnvelope.ack.ToString().Trim().ToUpper(), "SUCCESS");
    }
예제 #5
0
        public void sendInvoiceResponseConstruction()
        {
            SendInvoiceResponse cir = SendInvoiceResponse.CreateInstance(validSendInvoiceResponse, "", -1);

            Assert.AreEqual("INV2-PCWG-P78G-7EYV-94QY", cir.invoiceID);
            Assert.AreEqual(AckCode.SUCCESS, cir.responseEnvelope.ack);
            Assert.AreEqual("1917403", cir.responseEnvelope.build);
            Assert.AreEqual("9b3bb0a44d852", cir.responseEnvelope.correlationId);
            Assert.AreEqual("2011-05-30T03:31:18.988-07:00", cir.responseEnvelope.timestamp);
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        ///<param name="sendInvoiceRequest"></param>
        ///<param name="apiUserName">API Username that you want to authenticate this call against. This username and the corresponding 3-token/certificate credentials must be available in Web.Config/App.Config</param>
        public SendInvoiceResponse SendInvoice(SendInvoiceRequest sendInvoiceRequest, string apiUserName)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, sendInvoiceRequest.ToNVPString(string.Empty), ServiceName, "SendInvoice", apiUserName, getAccessToken(), getAccessTokenSecret());

            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName    = SDKName;
            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler)apiCallPreHandler).PortName   = "Invoice";

            NVPUtil util = new NVPUtil();

            return(SendInvoiceResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
예제 #7
0
    // # 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);
    }