Question

I have spent almost a day trying to resolve this and would appreciate any tips or guidance to get this damn thing working! My SetExpressCheckOut and GetExpressCheckOut functions work correctly but I'm getting the objects back from PayPal..

But the last step DoExpressCheckOut fails with this error message: "You do not have permissions to make this API call" so it cant' be my credentials because I used the same when doing Set and Get calls.

I have the standard PayPal account (not the pro one) I 'm using the live end point: https://api-3t.paypal.com/2.0/ and connect via API Username/Password/Signature

I've looked everywhere to see if there is specific API permissions to configure on PayPal but I had no luck...

Here's the code. and I appreciate the help..

public bool DoExpressCheckout(string token)
        {
            var getDetailsResponse = new GetExpressCheckoutDetailsResponseType();
            var getDetailsRequestType = new GetExpressCheckoutDetailsRequestType();
            var getDetailsReq = new GetExpressCheckoutDetailsReq();
            getDetailsRequestType.Version = GetVersionOrDefault();
            getDetailsRequestType.Token = token;
            getDetailsReq.GetExpressCheckoutDetailsRequest = getDetailsRequestType;

            var requestType = new DoExpressCheckoutPaymentRequestType();
            requestType.Version = GetVersionOrDefault(); // 109

             try
            {
                var type2 = new CustomSecurityHeaderType
                {
                    Credentials = new UserIdPasswordType()
                    {
                        Username = ConfigurationManager.AppSettings["PAYPAL_API_USERNAME"],
                        Password = ConfigurationManager.AppSettings["PAYPAL_API_PASSWORD"],
                        Signature = ConfigurationManager.AppSettings["PAYPAL_API_SIGNATURE"],
                    }
                };

                var paypalAAInt = new PayPalAPIAAInterfaceClient();

                getDetailsResponse = paypalAAInt.GetExpressCheckoutDetails(ref type2, getDetailsReq);
                if (getDetailsResponse.Errors != null && getDetailsResponse.Errors.Length > 0)
                {
                    throw new Exception("Exception(s) occured when calling PayPal. First exception: " +
                        getDetailsResponse.Errors[0].LongMessage + getDetailsResponse.Errors.Length.ToString());
                }

                if (getDetailsResponse.Ack == AckCodeType.Success)
                {
                     var payReq = new DoExpressCheckoutPaymentReq()
                        {
                            DoExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType()
                            {
                                Version = GetVersionOrDefault(), //109
                                DoExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType()
                                {
                                    Token = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails.Token,
                                    PaymentAction = PaymentActionCodeType.Sale,
                                    PaymentActionSpecified = true,
                                    PayerID = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID,
                                    PaymentDetails = new PaymentDetailsType[] {
                                        new PaymentDetailsType()
                                        {
                                            OrderTotal = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails[0].OrderTotal

                                        }
                                    }
                                }
                            }
                        };

                     var resp = paypalAAInt.DoExpressCheckoutPayment(ref type2, payReq);
                     if (resp.Errors != null && resp.Errors.Length > 0)
                     {
                         // ######### IT DIES HERE ################3
                         throw new Exception("Exception(s) occured when calling PayPal. First exception: " +
                             resp.Errors[0].LongMessage + resp.Errors.Length.ToString());
                     }

                     if (resp.Ack == AckCodeType.Success)
                         return true;
                     }
                     else
                         return false;

                return false;
            }


            catch (Exception ex)
            {
                Logger.LogError(ex, null, null, "Problem in PayPal DoExpressCheckOut function");
                throw new Exception("There was a problem processing your request. You have not been charged!");
            }
        }
Was it helpful?

Solution

I knew it had to be something stupid! here's the answer
The CustomSecurityHeaderType.. I was reusing it for both GetDetails and DoExpressCheckout calls. the user/pass/signature info clears out with the first call and it's empty when sent out to paypalAAInt.DoExpressCheckoutPayment. good grief.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top