title: No such recipient error Stripe
body: <p>I am getting this error when trying to do a test payment transfer to a test bank account through Stripe</p>
  
  <p>My frnt end side code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" &gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="https://js.stripe.com/v2/"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
    Stripe.setPublishableKey('//key//');
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="Payout" method="POST" id="payment-form"&gt;
    &lt;span class="payment-errors"&gt;&lt;/span&gt;
  
    &lt;div class="form-row"&gt;
      &lt;label&gt;
        &lt;span&gt;Card Number&lt;/span&gt;
        &lt;input type="text" size="20" data-stripe="number"&gt;
      &lt;/label&gt;
    &lt;/div&gt;
  
    &lt;div class="form-row"&gt;
      &lt;label&gt;
        &lt;span&gt;Expiration (MM/YY)&lt;/span&gt;
        &lt;input type="text" size="2" data-stripe="exp_month"&gt;
      &lt;/label&gt;
      &lt;span&gt; / &lt;/span&gt;
      &lt;input type="text" size="2" data-stripe="exp_year"&gt;
    &lt;/div&gt;
  
    &lt;div class="form-row"&gt;
      &lt;label&gt;
        &lt;span&gt;CVC&lt;/span&gt;
        &lt;input type="text" size="4" data-stripe="cvc"&gt;
      &lt;/label&gt;
    &lt;/div&gt;
  
    &lt;input type="submit" class="submit" value="Submit Payment"&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
      $(function() {
    var $form = $('#payment-form');
    $form.submit(function(event) {
      // Disable the submit button to prevent repeated clicks:
      $form.find('.submit').prop('disabled', true);
  
      // Request a token from Stripe:
      Stripe.card.createToken($form, stripeResponseHandler);
  
      // Prevent the form from being submitted:
      return false;
    });
  });
  
  function stripeResponseHandler(status, response) {
    // Grab the form:
    var $form = $('#payment-form');
  
    if (response.error) { // Problem!
  
      // Show the errors on the form:
      $form.find('.payment-errors').text(response.error.message);
      $form.find('.submit').prop('disabled', false); // Re-enable submission
  
    } else { // Token was created!
  
      // Get the token ID:
      var token = response.id;
  
      // Insert the token ID into the form so it gets submitted to the server:
      $form.append($('&lt;input type="hidden" name="stripeToken"&gt;').val(token));
  
      // Submit the form:
      $form.get(0).submit();
    }
  };
      &lt;/script&gt;
  &lt;/body&gt;
  
   &lt;/html&gt;
  </code></pre>
  
  <p>And my servlet is: </p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          try {
              //processRequest(request, response);
  
              Stripe.apiKey = "//test key//";
  
  // Get the card details submitted by the form
              String tokenID = request.getParameter("stripeToken");
  
  // Create a Recipient
              Map&lt;String, Object&gt; recipientParams = new HashMap&lt;String, Object&gt;();
              recipientParams.put("name", "Lord");
              recipientParams.put("type", "individual");
              recipientParams.put("card", tokenID);
              recipientParams.put("email", "test6@gmail.com");
  
              Recipient recipient = Recipient.create(recipientParams);
  
              Map&lt;String, Object&gt; transferParams = new HashMap&lt;String, Object&gt;();
  transferParams.put("amount", 1000); // amount in cents
  transferParams.put("currency", "usd");
  transferParams.put("recipient", recipient);
  transferParams.put("bank_account", "000123456789");
  transferParams.put("statement_descriptor", "JULY SALES");
  
  Transfer transfer = Transfer.create(transferParams);
  
              System.out.print("hi");
              RequestDispatcher view = request.getRequestDispatcher("index2.html");
              view.forward(request, response);
  
          } catch (AuthenticationException ex) {
              Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
          } catch (InvalidRequestException ex) {
              Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
          } catch (APIConnectionException ex) {
              Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
          } catch (CardException ex) {
              Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
          } catch (APIException ex) {
              Logger.getLogger(Payout.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  </code></pre>
  
  <p>I am getting the error recepient not found and i am not understanding why. Can anyone help? I am pretty much stunned by this.</p>
  
  <pre><code>Stack Trace:
  SEVERE:   com.stripe.exception.InvalidRequestException: No such recipient: &lt;com.stripe.model.Recipient@1975641541 id=rp_186thkGbhnSWFx0lIDZm2cmQ&gt; JSON: {
    "id": "rp_186thkGbhnSWFx0lIDZm2cmQ",
    "active_account": null,
    "cards": {
      "data": [
        {
          "address_city": null,
          "address_country": null,
          "address_line1": null,
          "address_line1_check": null,
          "address_line2": null,
          "address_state": null,
          "address_zip": null,
          "address_zip_check": null,
          "brand": "Visa",
          "country": "US",
          "currency": null,
          "cvc_check": "pass",
          "default_for_currency": null,
          "dynamic_last4": null,
          "exp_month": 12,
          "exp_year": 2017,
          "fingerprint": "qhUUS5Kf5JM2a8L8",
          "funding": "debit",
          "last4": "5556",
          "name": null,
          "recipient": "rp_186thkGbhnSWFx0lIDZm2cmQ",
          "status": null,
          "tokenization_method": null,
          "type": null,
          "id": "card_186thjGbhnSWFx0lu8w3m1Sq",
          "object": "card",
          "account": null,
          "customer": null,
          "metadata": {}
        }
      ],
      "has_more": false,
      "total_count": 1,
      "url": "/v1/recipients/rp_186thkGbhnSWFx0lIDZm2cmQ/cards",
      "count": null,
      "request_options": null,
      "request_params": null
    },
    "created": 1462244168,
    "default_card": "card_186thjGbhnSWFx0lu8w3m1Sq",
    "deleted": null,
    "description": null,
    "email": "test@gmail.com",
    "livemode": false,
    "metadata": {},
    "migrated_to": null,
    "name": "Lord Blue",
    "type": "individual",
    "verified": false
  }; request-id: req_8Nf12m7y81JQlC
      at com.stripe.net.LiveStripeResponseGetter.handleAPIError(LiveStripeResponseGetter.java:591)
      at com.stripe.net.LiveStripeResponseGetter._request(LiveStripeResponseGetter.java:443)
      at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:65)
      at com.stripe.net.APIResource.request(APIResource.java:133)
      at com.stripe.model.Transfer.create(Transfer.java:359)
      at com.stripe.model.Transfer.create(Transfer.java:318)
      at pay.Payout.doPost(Payout.java:114)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
      at java.lang.Thread.run(Thread.java:724)
  </code></pre>