title: Paypal Disputes Sandbox Testing
body: <p>i was trying to tests paypal disputes in a sandbox and was following this guide:
  <a href="https://developer.paypal.com/docs/integration/direct/customer-disputes/integration-guide/#sandbox-only-methods" rel="nofollow noreferrer">https://developer.paypal.com/docs/integration/direct/customer-disputes/integration-guide/#sandbox-only-methods</a>.</p>
  
  <p>However, on the step 2(Get permission from the buyer) the code provided by paypal for connect button generation was throwing js syntax error, so I changed it to this:</p>
  
  <pre><code>&lt;span id='cwppButton'&gt;&lt;/span&gt;
  &lt;script src="https://www.paypalobjects.com/js/external/connect/api.js"&gt;&lt;/script&gt;
  &lt;script&gt;
          paypal.use( ['login'], function (login) {
                  login.render ({
                          "appid": "MY_CLIENT_ID",
                          "authend": "sandbox",
                          "scopes": "openid",
                          "containerid": "cwppButton",
                          "locale": "en-us",
                          "buttonType": "CWP",
                          "buttonSize": "lg",
                          "returnurl": "https://a62add0d.ngrok.io/api/payments/paypal/get-token/"
                  });
            });
  &lt;/script&gt;
  </code></pre>
  
  <p>How u can see i changed scopes to just "openid", cuz separating links provided by paypal in this example gave me "Invalid Scope" error
  However i got access token from the button in this step.
  The next problem i faced was on step 4 (Generate JSON web token for PayPal Authorization Assertion), the code paypal provided gave syntax error, so i replaced it to this:</p>
  
  <pre><code>&lt;span id='cwppButton'&gt;&lt;/span&gt;
  &lt;html&gt;
  &lt;script&gt;
              function base64url(source) {
                      encodedSource = btoa(source);
                      encodedSource = encodedSource.replace(/=+$/, '"');
                      encodedSource = encodedSource.replace(/\+/g, '-');
                      encodedSource = encodedSource.replace(/\//g, '-');
  
                      return encodedSource;
              }
              function generateJWT() {
                      var header = {"alg": "none", "typ": "JWT"};
                      var data = {"iss"   :"MY_CLIENT_ID",
                                 "email" : "casino.player@gmail.com" };
                      document.write(base64url(JSON.stringify(header)) + "." +
                      base64url(JSON.stringify(data)) + ".");
              }
  &lt;/script&gt;
  &lt;body onload="generateJWT()"/&gt;
  </code></pre>
  
  <p>And as a result running create dispute request on step 6 i've got this error:</p>
  
  <pre><code>{
      "error": "invalid_request",
      "error_description": "No permissions to set target_client_id"
  }
  </code></pre>
  
  <p>My question is how to setup and test correctly paypal disputes in sandbox? If somebody was facing the same problem with disputes testing?</p>