Example #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);
        }
Example #2
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);
        }
Example #3
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);
    }