0

PaymentController:

class PaymentController extends Controller
{
public function paymentProcess()
{
\Stripe\Stripe::setApiKey("sk_test_1M123Dge214GicrsW30adwG12X1");
$token = $request->get('stripetoken');
$charge=\Stripe\Charge::create([
'amount'=>1000,
'currency'=>'usd',
'description'=>'Example charge',
'source'=>$token,
]);
}
}

index.blade.php:

<div class="content">
    <div class="title m-b-md">
        Laravel + Stripe
    </div>
    <div class="links">
        <form action="/api/payment" method="POST">
        <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
         data-key='pk_test_zWfsa5k3D21cq1hPA39FmIdMJfkG3Taf74LD'
        data-amount="100000"
         data-name="My Name"
          data-description="Test" 
          data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
        data-locale="auto" 
        data-currency="USD">
    </script>
        </form>
    </div>
</div>

api.php:

Route::post('/payment','PaymentController@paymentProcess');

it keeps giving me this error Must provide source or customer. and on my stripe test dashboard its still 0, no money has been added. Any help is highly appreciated, Thank you in advance

padaleiana
  • 955
  • 1
  • 14
  • 23
Harout
  • 175
  • 2
  • 3
  • 12

1 Answers1

1

The input name that has the token is probably stripeToken not stripetoken.

$token = $request->input('stripeToken');
lagbox
  • 48,571
  • 8
  • 72
  • 83