I'm trying to submit a stripeToken to charge.php without ajax but I'm getting following error:

> 
> Fatal error: Uncaught exception 'Stripe\Error\InvalidRequest' with
>  message 'Invalid source object: must be a dictionary or a non-empty
>  string.
> 
> 
> 

I believe it has something to do with the token not being appended to input. I have tried several different ways without success.

**minimum markup**

```
<form action="charge.php" method="POST" id="payment-form">

//rest of the form

<input id="stripeToken" type="hidden" name="stripeToken" value="">
<input type="submit" class="submit" value="Submit Payment">
</form>

```

**javascript**

```
Stripe.setPublishableKey('pk_test_PUBLISHABLE'); //publishable key
var $form = $('#payment-form'); // declare form variable
$(function() {

  $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) {
  if (response.error) {

    // display errors in form

 } else {

    // Get the token
    var token = response.id;

    // Insert the token in the form:
    document.getElementById('stripeToken').value=token;
   // $form.append($('<input type="hidden" name="stripeToken">').val(token));

    // Submit the form:
    $form.get(0).submit();
  }
};

```

**charge.php**

```
require_once('config.php');

\Stripe\Stripe::setApiKey($mysk_key);

$stripeToken=$_POST['stripeToken'];//line of the error

  $customer = \Stripe\Customer::create(array(
    'email' => $email,
    'source'  =>$stripeToken, //line of the error
    'plan' => $myplan
  ));

```

**UPDATE config.php**

```
<?php

    require_once('vendor/init.php');

    $test_sk="sk_test_xxx";
    $live_sk="sk_live_xxx";
    $mykey_sk=$test_sk;

    $test_pk="pk_test_xxx";
    $live_pk="pk_live_xxx";
    $mykey_pk=$test_pk;

    $stripe = array(
      "secret_key"      =>$mykey_sk,
      "publishable_key" =>$mykey_pk
    );

    \Stripe\Stripe::setApiKey($stripe['secret_key']);
    ?>

```