Пример #1
0
        /// <summary>
        /// API call example for GetInvoiceDetails
        /// </summary>
        /// <param name="context"></param>
        private void GetInvoiceDetails(HttpContext context)
        {
            // Collect input params
            String invoiceId = context.Request.Params["invoiceId"];
            GetInvoiceDetailsRequest request =
                new GetInvoiceDetailsRequest(new RequestEnvelope(ERROR_LANGUAGE), invoiceId);

            // Create service object and make the API call
            InvoiceService service;
            GetInvoiceDetailsResponse response;
            try
            {
                service = getService(context);
                response = service.GetInvoiceDetails(request);
            }
            catch (Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary<string, string> keyResponseParams = new Dictionary<string, string>();
            keyResponseParams.Add("API status", response.responseEnvelope.ack.ToString());
            keyResponseParams.Add("correlationId", response.responseEnvelope.correlationId);
            if (response.invoice != null)
            {
                keyResponseParams.Add("invoice date", response.invoice.invoiceDate);
                keyResponseParams.Add("due date", response.invoice.dueDate);
                keyResponseParams.Add("merchant email", response.invoice.merchantEmail);
                keyResponseParams.Add("payer email", response.invoice.payerEmail);
            }
            if (response.invoiceDetails != null)
            {
                keyResponseParams.Add("totalAmount", response.invoiceDetails.totalAmount.ToString());
            }
            displayResponse(context, "GetInvoiceDetails", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), response.error, null);
        }
Пример #2
0
 /// <summary> 
 /// 
 /// </summary>
 ///<param name="getInvoiceDetailsRequest"></param>
 public GetInvoiceDetailsResponse GetInvoiceDetails(GetInvoiceDetailsRequest getInvoiceDetailsRequest)
 {
     return GetInvoiceDetails(getInvoiceDetailsRequest,(string) null);
 }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        ///<param name="getInvoiceDetailsRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public GetInvoiceDetailsResponse GetInvoiceDetails(GetInvoiceDetailsRequest getInvoiceDetailsRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, getInvoiceDetailsRequest.ToNVPString(string.Empty), ServiceName, "GetInvoiceDetails", credential);
               	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "Invoice";

            NVPUtil util = new NVPUtil();
            return GetInvoiceDetailsResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1);
        }
Пример #4
0
 /**
   *AUTO_GENERATED
  	  */
 public GetInvoiceDetailsResponse GetInvoiceDetails(GetInvoiceDetailsRequest GetInvoiceDetailsRequest, string apiUsername)
 {
     string resp = call("GetInvoiceDetails", GetInvoiceDetailsRequest.toNVPString(""), apiUsername);
     NVPUtil util = new NVPUtil();
     return new GetInvoiceDetailsResponse(util.parseNVPString(resp), "");
 }
Пример #5
0
 /**
   *AUTO_GENERATED
  	  */
 public GetInvoiceDetailsResponse GetInvoiceDetails(GetInvoiceDetailsRequest GetInvoiceDetailsRequest)
 {
     return GetInvoiceDetails(GetInvoiceDetailsRequest, null);
 }
    // # GetInvoiceDetails API Operation
    // Use the GetInvoiceDetails API operation to get detailed information about an invoice.
    public GetInvoiceDetailsResponse GetInvoiceDetailsAPIOperation()
    {
        // Create the GetInvoiceDetailsResponse object;
        GetInvoiceDetailsResponse responseGetInvoiceDetails = new GetInvoiceDetailsResponse();

        try
        {
            // # GetInvoiceDetailsRequest
            // Use the GetInvoiceDetailsRequest message to get detailed information
            // about an invoice.

            // The code for the language in which errors are returned, which must be
            // en_US.
            RequestEnvelope envelopeRequest = new RequestEnvelope();
            envelopeRequest.errorLanguage = "en_US";

            // GetInvoiceDetailsRequest 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 retrieve.
            GetInvoiceDetailsRequest getInvoiceDetailsRequest = new GetInvoiceDetailsRequest(envelopeRequest, "INV2-ZC9R-X6MS-RK8H-4VKJ");

            // Create the service wrapper object to make the API call
            InvoiceService service = new InvoiceService();

            // # API call  
            // Invoke the GetInvoiceDetails method
            responseGetInvoiceDetails = service.GetInvoiceDetails(getInvoiceDetailsRequest);

            if (responseGetInvoiceDetails != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "GetInvoiceDetails API Operation - ";
                acknowledgement += responseGetInvoiceDetails.responseEnvelope.ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseGetInvoiceDetails.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Status of the invoice searched.
                    logger.Info("Status : " + responseGetInvoiceDetails.invoiceDetails.status + "\n");
                    Console.WriteLine("Status : " + responseGetInvoiceDetails.invoiceDetails.status + "\n");

                }
                // # Error Values                
                else
                {
                    List<ErrorData> errorMessages = responseGetInvoiceDetails.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 responseGetInvoiceDetails;
    }
        /// <summary>
        /// API call example for GetInvoiceDetails
        /// </summary>
        /// <param name="context"></param>
        private void GetInvoiceDetails(HttpContext context)
        {
            // Collect input params
            // (Required) ID of the invoice to retrieve.
            string invoiceId = context.Request.Params["invoiceId"];
            InvoiceModelAlias.RequestEnvelope env = 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.
            env.errorLanguage = ERROR_LANGUAGE;
            InvoiceModelAlias.GetInvoiceDetailsRequest request = new InvoiceModelAlias.GetInvoiceDetailsRequest(env);
            request.invoiceID = invoiceId;

            // Create service object and make the API call
            InvoiceAlias.InvoiceService service;
            InvoiceModelAlias.GetInvoiceDetailsResponse response;
            SignatureCredential cred = SetThirdPartyAuthorization(context);
            try
            {
                service = GetService(context);
                if (cred != null)
                {
                    response = service.GetInvoiceDetails(request, cred);
                }
                else
                {
                    response = service.GetInvoiceDetails(request);
                }

            }
            catch (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", response.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", response.responseEnvelope.correlationId);
            if (response.invoice != null)
            {
                // Date on which the invoice is enabled.
                keyResponseParams.Add("invoice date", response.invoice.invoiceDate);

                //  Date on which the invoice payment is due.
                keyResponseParams.Add("due date", response.invoice.dueDate);

                // Merchant email address.
                keyResponseParams.Add("merchant email", response.invoice.merchantEmail);

                // Payer email address.
                keyResponseParams.Add("payer email", response.invoice.payerEmail);
            }
            if (response.invoiceDetails != null)
            {
                keyResponseParams.Add("totalAmount", response.invoiceDetails.totalAmount.ToString());
            }
            displayResponse(context, "GetInvoiceDetails", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), response.error, null);
        }
Пример #8
0
 /**
   *AUTO_GENERATED
  	  */
 public GetInvoiceDetailsResponse GetInvoiceDetails(GetInvoiceDetailsRequest getInvoiceDetailsRequest, string apiUserName)
 {
     string response = Call("GetInvoiceDetails", getInvoiceDetailsRequest.ToNVPString(""), apiUserName);
     NVPUtil util = new NVPUtil();
     return GetInvoiceDetailsResponse.CreateInstance(util.ParseNVPString(response), "", -1);
 }
Пример #9
0
        /// <summary>
        /// API call example for GetInvoiceDetails
        /// </summary>
        /// <param name="context"></param>
        private void GetInvoiceDetails(HttpContext context)
        {
            // Collect input params
            String invoiceId = context.Request.Params["invoiceId"];
            GetInvoiceDetailsRequest request =
                new GetInvoiceDetailsRequest(new RequestEnvelope(ERROR_LANGUAGE), invoiceId);

            // Create service object and make the API call
            InvoiceService service = getService(context);
            GetInvoiceDetailsResponse response = service.GetInvoiceDetails(request);

            // Process response
            context.Response.Write("<html><body><textarea rows=30 cols=80>");
            ObjectDumper.Write(response, 5, context.Response.Output);
            context.Response.Write("</textarea></body></html>");
        }
 /**
   *AUTO_GENERATED
  	  */
 public GetInvoiceDetailsResponse GetInvoiceDetails(GetInvoiceDetailsRequest getInvoiceDetailsRequest, string apiUserName)
 {
     IAPICallPreHandler apiCallPreHandler = null;
     apiCallPreHandler = new PlatformAPICallPreHandler(getInvoiceDetailsRequest.ToNVPString(string.Empty), ServiceName, "GetInvoiceDetails", apiUserName, getAccessToken(), getAccessTokenSecret());
        	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     string response = Call(apiCallPreHandler);
     NVPUtil util = new NVPUtil();
     return GetInvoiceDetailsResponse.CreateInstance(util.ParseNVPString(response), string.Empty, -1);
 }