title: Stripe auth and capture charge with NODE.js
body: <p>I'm having trouble with the pre-authorization described here <a href="https://stripe.com/docs/charges#auth-capture" rel="nofollow noreferrer">https://stripe.com/docs/charges#auth-capture</a>.</p>
  
  <p>The auth goes successful (<code>capture</code> params to false), I can store the ID of the carghe on my databse and I can see the <strong>uncaptured charge</strong> from my Stripe Dashboard.</p>
  
  <p>Problem comes when I try to capture the charge, because it fails with <code>Error: No such charge: &lt;CHARGE_ID&gt;</code>.
  Here is the code:</p>
  
  <pre><code>constructor(){
    this.stripe = require('stripe')('&lt;sk_test_mysecretkey&gt;');
  }
  async captureCharge(chargeId) {
    try {
      /**
       * https://stripe.com/docs/api/charges/capture
       */
      return this.stripe.charges.capture(chargeId)
        .then((charge) =&gt; {
          return {
            error: false,
            success: true,
            message: 'ChargeSuccesful',
            code: 200,
            charge: charge,
          };
        },
          (err) =&gt; {
            console.log("CAPTURE CHARGE ERROR: ", err);
            return {
              success: false,
              error: err.type,
              code: err.statusCode,
            };
          }
        );
    } catch (e) {
      console.log('ERROR CAPTURE', e);
    }
  }
  </code></pre>
  
  <p>Even if I try with a POST to <code>https://api.stripe.com/v1/charges/&lt;CHARGE_ID&gt;/capture</code> with <code>auth: Bearer &lt;sk_test_mysecretkey&gt;</code> i get the same error:</p>
  
  <pre><code>{
      "error": {
          "code": "resource_missing",
          "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
          "message": "No such charge: &lt;CHARGE_ID&gt;",
          "param": "charge",
          "type": "invalid_request_error"
      }
  }
  </code></pre>
  
  <p>The uncaptured charge still exist on Stripe.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I forgot to say that the charge isn't a simple charge, but it is a split payment with a <a href="https://stripe.com/docs/connect/shared-customers" rel="nofollow noreferrer">shared customer</a>. Stripe supports <a href="https://stripe.com/docs/connect/charges#choosing-approach" rel="nofollow noreferrer">three approaches</a> for processing split payment, I have choosed the <a href="https://stripe.com/docs/connect/direct-charges" rel="nofollow noreferrer">direct charges</a>:</p>
  
  <pre><code>async authorizationCharge(amount, merchantStripeId, billId, customerId) {
    try {    
      var fee = 0.25;
      /** Pre-Authorization Charge using a shared customer
      * https://stripe.com/docs/charges#auth-capture
      * https://stripe.com/docs/connect/shared-customers
      */
      return this.stripe.tokens
        .create(
          { customer: customerId },
          { stripe_account: merchantStripeId }
        )
        .then((oneTimeToken) =&gt; {
          return this.stripe.charges
            .create(
              {
                amount: Math.round(amount),
                currency: 'eur',
                application_fee: fee,
                description: 'Bill ID: ' + billId,
                source: oneTimeToken.id,
                capture: false,
              },
              { stripe_account: merchantStripeId }
            )
            .then((charge) =&gt; {
              console.log('CHARGE: ', charge);
              return {
                error: false,
                success: true,
                code: 200,
                charge: charge,
                fee: fee,
              };
            },
              (err) =&gt; {
                // ERROR INFO:
                // https://stripe.com/docs/api#error_handling
                console.log('ERROR', err);
                return {
                  success: false,
                  error: err.type,
                  code: err.statusCode,
                };
              }
            );
        },
          (err) =&gt; {
            // ERROR INFO:
            // https://stripe.com/docs/api#error_handling
            console.log('ERROR', err);
            return { success: false, error: err.type, code: err.statusCode };
          }
        );
    } catch (e) {
      console.log(e);
    }
  }
  </code></pre>