The request object for SendInvoice.
Exemplo n.º 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        ///<param name="sendInvoiceRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public SendInvoiceResponse SendInvoice(SendInvoiceRequest sendInvoiceRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, sendInvoiceRequest.ToNVPString(string.Empty), ServiceName, "SendInvoice", credential);
               	 	((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);
        }
Exemplo n.º 3
0
        public void sendInvoiceRequestSerialization()
        {
            SendInvoiceRequest sir = new SendInvoiceRequest();
            sir.invoiceID = "INV-123456";
            sir.requestEnvelope = new RequestEnvelope("en_US");

            string expectedNVPString = "requestEnvelope.errorLanguage=en_US&invoiceID=INV-123456&";
            Assert.AreEqual(expectedNVPString, sir.ToNVPString(""));

            sir = new SendInvoiceRequest(new RequestEnvelope("en_US"), "INV-123456");
            Assert.AreEqual(expectedNVPString, sir.ToNVPString(""));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 /// <summary> 
 /// 
 /// </summary>
 ///<param name="sendInvoiceRequest"></param>
 public SendInvoiceResponse SendInvoice(SendInvoiceRequest sendInvoiceRequest)
 {
     return SendInvoice(sendInvoiceRequest,(string) null);
 }
Exemplo n.º 6
0
 /**
   *AUTO_GENERATED
  	  */
 public SendInvoiceResponse SendInvoice(SendInvoiceRequest SendInvoiceRequest, string apiUsername)
 {
     string resp = call("SendInvoice", SendInvoiceRequest.toNVPString(""), apiUsername);
     NVPUtil util = new NVPUtil();
     return new SendInvoiceResponse(util.parseNVPString(resp), "");
 }
Exemplo n.º 7
0
 /**
   *AUTO_GENERATED
  	  */
 public SendInvoiceResponse SendInvoice(SendInvoiceRequest SendInvoiceRequest)
 {
     return SendInvoice(SendInvoiceRequest, null);
 }
        private void SendInvoice(HttpContext context)
        {
            // (Required) ID of the invoice to send.
            string invoiceId = context.Request.Params["invoiceId"];

            InvoiceModelAlias.SendInvoiceRequest sr = new InvoiceModelAlias.SendInvoiceRequest();
            sr.invoiceID = invoiceId;
            sr.requestEnvelope = new InvoiceModelAlias.RequestEnvelope();

            // (Required) RFC 3066 language in which error messages are returned;
            // by default it is en_US, which is the only language currently supported.
            sr.requestEnvelope.errorLanguage = ERROR_LANGUAGE;

            InvoiceAlias.InvoiceService service;
            InvoiceModelAlias.SendInvoiceResponse sir = null;
            SignatureCredential cred = SetThirdPartyAuthorization(context);
            try
            {
                service = GetService(context);
                if (cred != null)
                {
                    sir = service.SendInvoice(sr, cred);
                }
                else
                {
                    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>();

            //Acknowledgement code. It is one of the following values:
            //Success – The operation completed successfully.
            //Failure – The operation failed.
            //SuccessWithWarning – The operation completed successfully; however, there is a warning message.
            //FailureWithWarning – The operation failed with a warning message.
            keyResponseParams.Add("API status", sir.responseEnvelope.ack.ToString());

            // Correlation identifier. It is a 13-character,
            // alphanumeric string (for example, db87c705a910e) that is used
            // only by PayPal Merchant Technical Support.
            // Note: You must log and store this data for every response you receive.
            // PayPal Technical Support uses the information to assist with reported issues.
            keyResponseParams.Add("correlationId", sir.responseEnvelope.correlationId);

            // ID of the created invoice.
            keyResponseParams.Add("invoiceId", sir.invoiceID);

            // URL location where merchants view the invoice details.
            keyResponseParams.Add("invoiceUrl", sir.invoiceURL);
            displayResponse(context, "SendInvoice", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), sir.error, null);
        }
Exemplo n.º 9
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);
 }
    // # 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;
    }
Exemplo n.º 11
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);

            SendInvoiceResponse sir = null;

            try
            {
                InvoiceService service = getService(context);
                sir = service.SendInvoice(sr);
                context.Response.Write("<html><body><textarea rows=30 cols=80>");
                ObjectDumper.Write(sir, 5, context.Response.Output);
                context.Response.Write("</textarea></body></html>");
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
            }
        }
 /**
   *AUTO_GENERATED
  	  */
 public SendInvoiceResponse SendInvoice(SendInvoiceRequest sendInvoiceRequest, string apiUserName)
 {
     IAPICallPreHandler apiCallPreHandler = null;
     apiCallPreHandler = new PlatformAPICallPreHandler(sendInvoiceRequest.ToNVPString(string.Empty), ServiceName, "SendInvoice", apiUserName, getAccessToken(), getAccessTokenSecret());
        	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     string response = Call(apiCallPreHandler);
     NVPUtil util = new NVPUtil();
     return SendInvoiceResponse.CreateInstance(util.ParseNVPString(response), string.Empty, -1);
 }