title: Stripe API error - "Received unknown parameter: source"
body: <p>Creating subscription site in wix code. I keep getting a 400 unknown parameter: source error. (/subscripton)</p>
  
  <p>if you can spot where i am going wrong it would be appreciated. thanks!</p>
  
  <pre><code>import { fetch } from 'wix-fetch';
  
  export async function subscription(token, item) {
  
      const cart = item;
  
      const apiKey = "PRIVATEAPI";
  
      const response = await
      fetch("https://api.stripe.com/v1/subscriptions", {
  
          method: 'post',
  
          headers: {
  
              "Content-Type": "application/x-www-form-urlencoded",
  
              "Authorization": "Bearer " + apiKey
  
          },
  
          body: encodeBody(token, cart)
      });
      if (response.status &gt;= 200 &amp;&amp; response.status &lt; 300) {
  
          const ret = await response.json();
  
          return { "chargeId": ret.id };
  
      }
  
      let res = await response.json(); 
  
      let err = res.error.message;
  
      let code = res.error.code;
  
      let type = res.error.type;
  
      return { "error": err, "code": code, "type": type };
  
  }
  
   function encodeBody(token, cart) {
  
      let encoded = "";
  
      for (let [k, v] of Object.entries(cart)) {
  
          encoded = encoded.concat(k, "=", encodeURI(v), "&amp;");
      }
       encoded = encoded.concat("source=", encodeURI(token));
       return encoded;
  }
  </code></pre>