Seleccionar página

Enlaces de interés

https://github.com/stripe/stripe-php/blob/master/examples/oauth.php

https://www.youtube.com/watch?v=EildM6OMcoQ

Ejemplo de cómo realizar un cargo:

https://stripe.com/docs/stripe-js/elements/quickstart (ejemplo con javascript)

https://github.com/bradtraversy/php_stripe_paypage/blob/master/index.php

https://github.com/bradtraversy/php_stripe_paypage/blob/master/charge.php

Ejemplos en Stripe.dev

https://stripe.dev/elements-examples/es/


Recortes de ejemplos de uso

\Stripe\Stripe::setApiKey(WEBSITE_CONFIG['stripe']['api-secret-key']);

//$stripeToken es creado desde el fichero JS; también se puede crear manualmente de esta forma:

https://stackoverflow.com/questions/50835945/laravel-cashier-where-does-stripetoken-come-from/50855564#50855564 

It turns out that the stripeToken is usually generated by stripe.js forms when they are submitted.

As I am using API driven checkout forms and not standard html submission forms I need to use the Stripe API to create the token from the card details provided.

$stripeToken = Token::create(array(
                       "card" => array(
                           "number"    => $request->get('number'),
                           "exp_month" => str_before($request->get('expiry'), '/'),
                           "exp_year"  => str_after($request->get('expiry'), '/'),
                           "cvc"       => $request->get('cvc'),
                           "name"      => $request->get('name')
                       )
                   ));

Then I use $stripeToken->id and pass it:

$user->newSubscription('main', 'premium')->create($stripeToken->id);

//Crear un cargo

$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => $stripeToken]);

Esta web utiliza cookies propias y de terceros para su correcto funcionamiento y para fines analíticos. Al hacer clic en el botón Aceptar, acepta el uso de estas tecnologías y el procesamiento de tus datos para estos propósitos. Ver
Privacidad