I have been banging my head against a wall for the last couple of days trying to get express checkout working in a simple asp.net mvc application with permissions. In every iteration I receive some type of unauthorized message. I believe that the token
is being generated correctly I can't seem to find how to get the sand box to accept the generated header. Can someone please point me in the right direction? I am using a service reference for the soap api. Below is the action calling the setexpresscheckout
method. I have removed username, password and url strings for the post.
gabaroar
0 Points
1 Post
Authentication error returned from express checkout using permissions
Feb 15, 2013 08:53 PM|LINK
I have been banging my head against a wall for the last couple of days trying to get express checkout working in a simple asp.net mvc application with permissions. In every iteration I receive some type of unauthorized message. I believe that the token is being generated correctly I can't seem to find how to get the sand box to accept the generated header. Can someone please point me in the right direction? I am using a service reference for the soap api. Below is the action calling the setexpresscheckout method. I have removed username, password and url strings for the post.
public ActionResult BuySomething() { String accessToken = Session["access_token"].ToString(); String tokenSecret = Session["token_secret"].ToString(); String normalizedUrl = String.Empty; String normalizedRequestParameters = String.Empty; String oauthTimeStamp = String.Empty; Hashtable queryParams = null; String url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; Hashtable map = OauthSignature.getAuthHeader(username, password, accessToken, tokenSecret, OauthSignature.HTTPMethod.POST, expressCheckoutEndpoint, queryParams); CustomSecurityHeaderType header = new CustomSecurityHeaderType(); SetExpressCheckoutReq req = new SetExpressCheckoutReq() { SetExpressCheckoutRequest = new SetExpressCheckoutRequestType() { Version = "98.0", SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType() { OrderDescription = "Test", OrderTotal = new BasicAmountType() { Value = "10.00", currencyID = CurrencyCodeType.USD }, CancelURL = ConfigurationManager.AppSettings["PaypalExpressCancel"], ReturnURL = ConfigurationManager.AppSettings["PaypalExpressSuccess"] } } }; PayPalAPIAAInterfaceClient client = new PayPalAPIAAInterfaceClient(); client.Endpoint.Address = new EndpointAddress(expressCheckoutEndpoint); using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) { HttpRequestMessageProperty httpRequestMessageProperty = new HttpRequestMessageProperty(); httpRequestMessageProperty.Headers["X-PAYPAL-AUTHORIZATION"] = "token=" + accessToken + ",signature=" + map["Signature"].ToString() + ",timestamp=" + map["TimeStamp"].ToString(); SetExpressCheckoutResponseType responseType = client.SetExpressCheckout(ref header, req); url += responseType.Token; } return Redirect(url); }