I am using Stripe in my app. I want to write an integration test for placing a payment that checks Stripe that a payment was created. I'm using Stripe.js.
In my test I need a card token to perform the test charge. Usually this token would be generated client side with stripe.js and sent in the request to perform the charge. As this is a server-side only test is there some way I can generate a token from within the test?
For reference the test would be something like this (uses php but the principle is the same):
/** @test **/
public function it_creates_a_charge()
{
$order = factory(Order::class)->create();
$stripe_token = Stripe::generateToken([
'card' => '4242424242424242'
'exp' => '04/2017',
'cvc' => '123'
]); // does not exist afaik
$response = $this->post('charges/store', [
'stripe_token' => $stripe_token,
'order_id' => $order->id,
//etc
]);
// assertions...
}
Essentially I'm asking if there's something within the Stripe API that allows server-side token generation.