JillzTom's avatar

Testing Stripe Payment Form

Is there anyone who've successfully tried and tested Stripe Payment Forms using phpunit ? I'm not using Laravel Cashier. Can anybody suggest me a way to test the Stripe Payment form? Thanks in advance

0 likes
1 reply
bjones2015's avatar

You shouldn't try to test the form. Stripe themselves should be doing that. Like Jeffery Way has said before, you shouldn't test other peoples code.

Anyway I'm like you, I just built a Stripe Gateway as I couldn't use cashier due to it's one subscription limit. To test to make sure my gateway was working I needed a token. So in case you need that you can do something like this

    public function createToken(){
        $this->gateway = new StripeGateway();

        \Stripe\Stripe::setApiKey(config('services.stripe.secret'));
        $data = \Stripe\Token::create([
            'card' => [
                "number" => "4242424242424242",
                "exp_month" => 11,
                "exp_year" => 2016,
                "cvc" => "314"
            ]
        ]);

        $this->token = $data['id'];
    }
3 likes

Please or to participate in this conversation.