DoReauthorization() public method

public DoReauthorization ( DoReauthorizationReq doReauthorizationReq ) : DoReauthorizationResponseType
doReauthorizationReq PayPal.PayPalAPIInterfaceService.Model.DoReauthorizationReq
return PayPal.PayPalAPIInterfaceService.Model.DoReauthorizationResponseType
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoReauthorizationRequestType request =
                new DoReauthorizationRequestType();

            // (Required) Value of a previously authorized transaction identification number returned by PayPal.
            request.AuthorizationID = authorizationId.Value;

            // (Required) Amount to reauthorize.
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
            request.Amount = new BasicAmountType(currency, amount.Value);

            // Invoke the API
            DoReauthorizationReq wrapper = new DoReauthorizationReq();
            wrapper.DoReauthorizationRequest = 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 DoReauthorization method in service wrapper object
            DoReauthorizationResponseType doReauthorizationResponse =
                    service.DoReauthorization(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, doReauthorizationResponse);
        }
Ejemplo n.º 2
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoReauthorizationRequestType request =
                new DoReauthorizationRequestType();

            request.AuthorizationID = authorizationId.Value;
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
            request.Amount = new BasicAmountType(currency, amount.Value);

            // Invoke the API
            DoReauthorizationReq wrapper = new DoReauthorizationReq();
            wrapper.DoReauthorizationRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            DoReauthorizationResponseType doReauthorizationResponse =
                    service.DoReauthorization(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, doReauthorizationResponse);
        }
    // # DoReauthorization API Operation
    // Authorize a payment
    public DoReauthorizationResponseType DoReauthorizationAPIOperation()
    {
        // Create the DoReauthorizationResponseType object
        DoReauthorizationResponseType responseDoReauthorizationResponseType = new DoReauthorizationResponseType();

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

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

            // `DoReauthorizationRequest` which takes mandatory params:
            //
            // * `Authorization Id` - Value of a previously authorized transaction
            // identification number returned by PayPal.
            // * `amount`
            DoReauthorizationRequestType doReauthorizationRequest = new DoReauthorizationRequestType("9B2288061E685550E", amount);
            requestDoReauthorization.DoReauthorizationRequest = doReauthorizationRequest;

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

            // # API call
            // Invoke the DoReauthorization method in service wrapper object
            responseDoReauthorizationResponseType = service.DoReauthorization(requestDoReauthorization);

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

                // # Success values
                if (responseDoReauthorizationResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Authorization identification number
                    logger.Info("Authorization ID : " + responseDoReauthorizationResponseType.AuthorizationID + "\n");
                    Console.WriteLine("Authorization ID : " + responseDoReauthorizationResponseType.AuthorizationID + "\n");
                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoReauthorizationResponseType.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 responseDoReauthorizationResponseType;
    }