Exemplo n.º 1
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoAuthorizationRequestType request =
                new DoAuthorizationRequestType();

            request.TransactionID = transactionId.Value;
            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);

            request.Amount = new BasicAmountType(currency, amount.Value);

            // Invoke the API
            DoAuthorizationReq wrapper = new DoAuthorizationReq();

            wrapper.DoAuthorizationRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            DoAuthorizationResponseType      doAuthorizationResponse =
                service.DoAuthorization(wrapper);


            // Check for API return status
            setKeyResponseObjects(service, doAuthorizationResponse);
        }
Exemplo n.º 2
0
        /**
         *
         */
        public DoAuthorizationResponseType DoAuthorization(DoAuthorizationReq DoAuthorizationReq, string apiUsername)
        {
            setStandardParams(DoAuthorizationReq.DoAuthorizationRequest);
            string resp = call("DoAuthorization", DoAuthorizationReq.toXMLString(), apiUsername);

            return(new DoAuthorizationResponseType(resp));
        }
        /**
         * AUTO_GENERATED
         */
        public DoAuthorizationResponseType DoAuthorization(DoAuthorizationReq doAuthorizationReq, string apiUserName)
        {
            setStandardParams(doAuthorizationReq.DoAuthorizationRequest);
            string      response    = Call("DoAuthorization", doAuthorizationReq.ToXMLString(), apiUserName);
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(response);
            XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='DoAuthorizationResponse']");

            return(new DoAuthorizationResponseType(xmlNode));
        }
Exemplo n.º 4
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoAuthorizationRequestType request =
                new DoAuthorizationRequestType();

            // (Required) Value of the order's transaction identification number returned by PayPal.
            request.TransactionID = transactionId.Value;
            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);

            // (Required) Amount to authorize.
            request.Amount = new BasicAmountType(currency, amount.Value);

            // Invoke the API
            DoAuthorizationReq wrapper = new DoAuthorizationReq();

            wrapper.DoAuthorizationRequest = request;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // # API call
            // Invoke the DoAuthorization method in service wrapper object
            DoAuthorizationResponseType doAuthorizationResponse =
                service.DoAuthorization(wrapper);


            // Check for API return status
            setKeyResponseObjects(service, doAuthorizationResponse);
        }
Exemplo n.º 5
0
 /// <remarks/>
 public void DoAuthorizationAsync(DoAuthorizationReq DoAuthorizationReq, object userState) {
     if ((this.DoAuthorizationOperationCompleted == null)) {
         this.DoAuthorizationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDoAuthorizationOperationCompleted);
     }
     this.InvokeAsync("DoAuthorization", new object[] {
                 DoAuthorizationReq}, this.DoAuthorizationOperationCompleted, userState);
 }
Exemplo n.º 6
0
 /// <remarks/>
 public void DoAuthorizationAsync(DoAuthorizationReq DoAuthorizationReq) {
     this.DoAuthorizationAsync(DoAuthorizationReq, null);
 }
Exemplo n.º 7
0
 public DoAuthorizationResponseType DoAuthorization(DoAuthorizationReq DoAuthorizationReq)
 {
     return(DoAuthorization(DoAuthorizationReq, null));
 }
Exemplo n.º 8
0
    //# DoAuthorization API Operation
    //Authorize a payment.
    public DoAuthorizationResponseType DoAuthorizationAPIOperation()
    {
        // Create the DoAuthorizationResponseType object
        DoAuthorizationResponseType responseDoAuthorizationResponseType = new DoAuthorizationResponseType();

        try
        {
            // Create the DoAuthorizationReq object
            DoAuthorizationReq doAuthorization = new DoAuthorizationReq();

            // `Amount` which takes mandatory params:
            //
            // * `currencyCode`
            // * `amount`
            BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "4.00");

            // `DoAuthorizationRequest` which takes mandatory params:
            //
            // * `Transaction ID` - Value of the order's transaction identification
            // number returned by PayPal.
            // * `Amount` - Amount to authorize.
            DoAuthorizationRequestType doAuthorizationRequest = new DoAuthorizationRequestType("O-4VR15106P7416533H", amount);
            doAuthorization.DoAuthorizationRequest = doAuthorizationRequest;

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

            // # API call
            // Invoke the DoAuthorization method in service wrapper object
            responseDoAuthorizationResponseType = service.DoAuthorization(doAuthorization);

            if (responseDoAuthorizationResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "DoAuthorization API Operation - ";
                acknowledgement += responseDoAuthorizationResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseDoAuthorizationResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Authorization identification number
                    logger.Info("Transaction ID : " + responseDoAuthorizationResponseType.TransactionID + "\n");
                    Console.WriteLine("Transaction ID : " + responseDoAuthorizationResponseType.TransactionID + "\n");
                }
                // # Error Values
                else
                {
                    // Access error values from error list using getter methods
                    List <ErrorType> errorMessages = responseDoAuthorizationResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log
        catch (System.Exception ex)
        {
            // Log the exception message
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return(responseDoAuthorizationResponseType);
    }