/**
   *AUTO_GENERATED
  	  */
 public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest requestPermissionsRequest)
 {
     return RequestPermissions(requestPermissionsRequest,(string) null);
 }
 /**
   *AUTO_GENERATED
  	  */
 public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest requestPermissionsRequest, ICredential credential)
 {
     IAPICallPreHandler apiCallPreHandler = null;
     apiCallPreHandler = new PlatformAPICallPreHandler(requestPermissionsRequest.ToNVPString(string.Empty), ServiceName, "RequestPermissions", credential);
        	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     string response = Call(apiCallPreHandler);
     NVPUtil util = new NVPUtil();
     return RequestPermissionsResponse.CreateInstance(util.ParseNVPString(response), string.Empty, -1);
 }
Ejemplo n.º 3
0
 /**
   *AUTO_GENERATED
  	  */
 public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest RequestPermissionsRequest, string apiUsername)
 {
     string resp = call("RequestPermissions", RequestPermissionsRequest.toNVPString(""), apiUsername);
     NVPUtil util = new NVPUtil();
     return new RequestPermissionsResponse(util.parseNVPString(resp), "");
 }
Ejemplo n.º 4
0
 /**
   *AUTO_GENERATED
  	  */
 public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest RequestPermissionsRequest)
 {
     return RequestPermissions(RequestPermissionsRequest, null);
 }
        private void RequestPermissions(HttpContext context)
        {
            RequestPermissionsRequest rp = new RequestPermissionsRequest();
            rp.scope = new List<string>();

            // (Required) At least 1 of the following permission categories:
            //EXPRESS_CHECKOUT - Express Checkout
            //DIRECT_PAYMENT - Direct payment by debit or credit card
            //SETTLEMENT_CONSOLIDATION - Settlement consolidation
            //SETTLEMENT_REPORTING - Settlement reporting
            //AUTH_CAPTURE - Payment authorization and capture
            //MOBILE_CHECKOUT - Mobile checkout
            //BILLING_AGREEMENT - Billing agreements
            //REFERENCE_TRANSACTION - Reference transactions
            //AIR_TRAVEL - Express Checkout for UTAP
            //MASS_PAY - Mass pay
            //TRANSACTION_DETAILS - Transaction details
            //TRANSACTION_SEARCH - Transaction search
            //RECURRING_PAYMENTS - Recurring payments
            //ACCOUNT_BALANCE - Account balance
            //ENCRYPTED_WEBSITE_PAYMENTS - Encrypted website payments
            //REFUND - Refunds
            //NON_REFERENCED_CREDIT - Non-referenced credit
            //BUTTON_MANAGER - Button Manager
            //MANAGE_PENDING_TRANSACTION_STATUS includes ManagePendingTransactionStatus
            //RECURRING_PAYMENT_REPORT - Reporting for recurring payments
            //EXTENDED_PRO_PROCESSING_REPORT - Extended Pro processing
            //EXCEPTION_PROCESSING_REPORT - Exception processing
            //ACCOUNT_MANAGEMENT_PERMISSION - Account Management Permission (MAM)
            //ACCESS_BASIC_PERSONAL_DATA - User attributes
            //ACCESS_ADVANCED_PERSONAL_DATA - User attributes
            //INVOICING - Invoicing
            string[] scopes = context.Request.Form.GetValues("api");

            for (int i = 0; i < scopes.Length; i++)
                rp.scope.Add(scopes[i]);

            //(Required) Your callback function that specifies actions to
            // take after the account holder grants or denies the request.
            rp.callback = context.Request.Params["callback"];

            // (Required) RFC 3066 language in which error messages are returned;
            // by default it is en_US, which is the only language currently supported.
            rp.requestEnvelope = new RequestEnvelope("en_US");
            RequestPermissionsResponse rpr = null;

            try
            {
                // ## Creating service wrapper object
                // Creating service wrapper object to make API call
                // 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]
                PermissionsService service = new PermissionsService(Configuration.GetAcctAndConfig());

                rpr = service.RequestPermissions(rp);
                context.Response.Write("<html><body><textarea rows=30 cols=80>");
                ObjectDumper.Write(rpr, 5, context.Response.Output);
                context.Response.Write("</textarea></body></html>");

                string red = "<br>";
                red = red + "<a href=";
                red = red + ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + "_grant-permission&request_token=" + rpr.token;
                red = red + ">Redirect URL (Click to redirect)</a><br>";
                context.Response.Write(red);
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
            }
        }
        /// <summary>
        /// Invokes the GetAccessToken API that requests third party permissions
        /// from another PayPal user for the API caller
        /// </summary>
        /// <param name="context"></param>
        private void RequestPermissions(HttpContext context)
        {
            // Restrict permissioning scope to "INVOICING"
            // This will allow the API caller to invoke any invoicing related API
            // on behalf of the permission granter
            string requestperm = "INVOICING";
            PermissionsModelAlias.RequestPermissionsRequest rp = new PermissionsModelAlias.RequestPermissionsRequest();
            rp.scope = new List<string>();
            //(Required) At least 1 of the following permission categories:
            //   EXPRESS_CHECKOUT - Express Checkout
            //   DIRECT_PAYMENT - Direct payment by debit or credit card
            //   SETTLEMENT_CONSOLIDATION - Settlement consolidation
            //   SETTLEMENT_REPORTING - Settlement reporting
            //   AUTH_CAPTURE - Payment authorization and capture
            //   MOBILE_CHECKOUT - Mobile checkout
            //   BILLING_AGREEMENT - Billing agreements
            //   REFERENCE_TRANSACTION - Reference transactions
            //   AIR_TRAVEL - Express Checkout for UTAP
            //   MASS_PAY - Mass pay
            //   TRANSACTION_DETAILS - Transaction details
            //   TRANSACTION_SEARCH - Transaction search
            //   RECURRING_PAYMENTS - Recurring payments
            //   ACCOUNT_BALANCE - Account balance
            //   ENCRYPTED_WEBSITE_PAYMENTS - Encrypted website payments
            //   REFUND - Refunds
            //   NON_REFERENCED_CREDIT - Non-referenced credit
            //   BUTTON_MANAGER - Button Manager
            //   MANAGE_PENDING_TRANSACTION_STATUS includes ManagePendingTransactionStatus
            //   RECURRING_PAYMENT_REPORT - Reporting for recurring payments
            //   EXTENDED_PRO_PROCESSING_REPORT - Extended Pro processing
            //   EXCEPTION_PROCESSING_REPORT - Exception processing
            //   ACCOUNT_MANAGEMENT_PERMISSION - Account Management Permission (MAM)
            //   ACCESS_BASIC_PERSONAL_DATA - User attributes
            //   ACCESS_ADVANCED_PERSONAL_DATA - User attributes
            //   INVOICING - Invoicing
            rp.scope.Add(requestperm);

            string url = context.Request.Url.Scheme + "://" + context.Request.Url.Host + ":" + context.Request.Url.Port;
            string returnURL = url + "/GetAccessToken.aspx?source=" + context.Request.UrlReferrer.LocalPath;

            //(Required) Your callback function that specifies actions to take after the account
            // holder grants or denies the request.
            rp.callback = returnURL;
            PermissionsModelAlias.RequestPermissionsResponse rpr = null;

            try
            {
                // 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();

                // Creating service wrapper object to make an API call by loading configuration map.
                PermissionsAlias.PermissionsService service = new PermissionsAlias.PermissionsService(configurationMap);
                rpr = service.RequestPermissions(rp);

                string ret = "<div class='overview'>Step 1) Invoke the RequestPermissions API and redirect third party to "
                + "PayPal so that the user may login and grant permissions to the API caller<br/></div>";
                ret = ret + "<a href=";
                ret = ret + ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + "_grant-permission&request_token=" + rpr.token;
                ret = ret + "> Redirect URL (Click to redirect) </a><br/><br/>";
                context.Response.Write(ret);

                context.Response.Write("<html><body><textarea rows=30 cols=80>");
                ObjectDumper.Write(rpr, 5, context.Response.Output);
                context.Response.Write("</textarea></body></html>");
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }
        }
Ejemplo n.º 7
0
 /**
   *AUTO_GENERATED
  	  */
 public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest requestPermissionsRequest, string apiUserName)
 {
     string response = Call("RequestPermissions", requestPermissionsRequest.ToNVPString(""), apiUserName);
     NVPUtil util = new NVPUtil();
     return RequestPermissionsResponse.CreateInstance(util.ParseNVPString(response), "", -1);
 }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="requestPermissionsRequest"></param>
        ///<param name="apiUserName">API Username that you want to authenticate this call against. This username and the corresponding 3-token/certificate credentials must be available in Web.Config/App.Config</param>
        public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest requestPermissionsRequest, string apiUserName)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, requestPermissionsRequest.ToNVPString(string.Empty), ServiceName, "RequestPermissions", apiUserName, getAccessToken(), getAccessTokenSecret());
               	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "Permissions";

            NVPUtil util = new NVPUtil();
            return RequestPermissionsResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1);
        }
Ejemplo n.º 9
0
        /**
         *
         */
        public RequestPermissionsResponse RequestPermissions(RequestPermissionsRequest RequestPermissionsRequest, string apiUsername)
        {
            BasePayPalService service = new BasePayPalService(serviceName);
            string resp = service.call("RequestPermissions", RequestPermissionsRequest.toNVPString(""), apiUsername);

            NVPUtil util = new NVPUtil();
            return new RequestPermissionsResponse(util.parseNVPString(resp), "");
        }
    // # RequestPermissions API Operation
    // Use the RequestPermissions API operation to request permissions to execute API operations on a PayPal account holder’s behalf. 
    public RequestPermissionsResponse RequestPermissionsAPIOperation()
    {
        // Create the RequestPermissionsResponse object
        RequestPermissionsResponse responseRequestPermissions = new RequestPermissionsResponse();
        
        try
        {
            // # RequestPermissionsRequest
            // `Scope`, which can take at least 1 of the following permission
            // categories:
            // 
            // * EXPRESS_CHECKOUT
            // * DIRECT_PAYMENT
            // * AUTH_CAPTURE
            // * AIR_TRAVEL
            // * TRANSACTION_SEARCH
            // * RECURRING_PAYMENTS
            // * ACCOUNT_BALANCE
            // * ENCRYPTED_WEBSITE_PAYMENTS
            // * REFUND
            // * BILLING_AGREEMENT
            // * REFERENCE_TRANSACTION
            // * MASS_PAY
            // * TRANSACTION_DETAILS
            // * NON_REFERENCED_CREDIT
            // * SETTLEMENT_CONSOLIDATION
            // * SETTLEMENT_REPORTING
            // * BUTTON_MANAGER
            // * MANAGE_PENDING_TRANSACTION_STATUS
            // * RECURRING_PAYMENT_REPORT
            // * EXTENDED_PRO_PROCESSING_REPORT
            // * EXCEPTION_PROCESSING_REPORT
            // * ACCOUNT_MANAGEMENT_PERMISSION
            // * INVOICING
            // * ACCESS_BASIC_PERSONAL_DATA
            // * ACCESS_ADVANCED_PERSONAL_DATA
            List<String> scopeList = new List<String>();
            scopeList.Add("INVOICING");
            scopeList.Add("EXPRESS_CHECKOUT");

            // Create RequestPermissionsRequest object which takes mandatory params:
            // 
            // * `Scope`
            // * `Callback` - Your callback function that specifies actions to take
            // after the account holder grants or denies the request.
            RequestPermissionsRequest requestRequestPermissions = new RequestPermissionsRequest(scopeList, "http://localhost/callback");

            // Create the service wrapper object
            PermissionsService service = new PermissionsService();

            // # API call      
            // Invoke the RequestPermissions method in service wrapper object
            responseRequestPermissions = service.RequestPermissions(requestRequestPermissions);

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

                // # Success values
                if (responseRequestPermissions.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // # Redirecting to PayPal
                    // Once you get the success response, user needs to redirect to
                    // paypal to authorize. Construct the `redirectUrl` as follows,
                    // 
                    //     redirectURL=https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token="+responseRequestPermissions.token;
                    // 
                    // Once you are done with authorization, you will be returning
                    // back to `callback` url mentioned in your request. While
                    // returning, PayPal will send two parameters in request:
                    // 
                    // * `request_token`
                    // * `token_verifier`
                    // You have to use these values in `GetAccessToken` API call to
                    // generate `AccessToken` and `TokenSecret`
                }
                // # Error Values                
                else
                {
                    List<ErrorData> errorMessages = responseRequestPermissions.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 responseRequestPermissions;
    }
Ejemplo n.º 11
0
        private void RequestPermissions(HttpContext context)
        {
            RequestPermissionsRequest rp = new RequestPermissionsRequest();
            rp.scope = new List<string>();
            string[] scopes = context.Request.Form.GetValues("api");

            for (int i = 0; i < scopes.Length; i++)
                rp.scope.Add(scopes[i]);

            rp.callback = context.Request.Params["callback"];
            rp.requestEnvelope = new RequestEnvelope("en_US");
            RequestPermissionsResponse rpr = null;

            try
            {
                PermissionsService service = new PermissionsService();
                rpr = service.RequestPermissions(rp);
                context.Response.Write("<html><body><textarea rows=30 cols=80>");
                ObjectDumper.Write(rpr, 5, context.Response.Output);
                context.Response.Write("</textarea></body></html>");

                string red = "<br>";
                red = red + "<a href=";
                red = red + ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + "_grant-permission&request_token=" + rpr.token;
                red = red + ">Redirect URL (Click to redirect)</a><br>";
                context.Response.Write(red);
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
            }
        }