2017 © Pedro Peláez
 

library yii2-stripe

Yii2 Stripe Wrapper

image

ruskid/yii2-stripe

Yii2 Stripe Wrapper

  • Friday, February 10, 2017
  • by ruskid
  • Repository
  • 4 Watchers
  • 22 Stars
  • 6,571 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 2 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

Yii2 Stripe Wrapper.

Installation

The preferred way to install this extension is through http://getcomposer.org/download/., (*1)

Either run, (*2)

php composer.phar require ruskid/yii2-stripe "dev-master"

or add, (*3)

"ruskid/yii2-stripe": "dev-master"

to the require section of your composer.json file., (*4)

Usage

Add a new component in main.php, (*5)

'components' => [
...
'stripe' => [
    'class' => 'ruskid\stripe\Stripe',
    'publicKey' => "pk_test_xxxxxxxxxxxxxxxxxxx",
    'privateKey' => "sk_test_xxxxxxxxxxxxxxxxxx",
],
...

To render simple checkout form just call the widget in the view, it will automatically register the scripts. Check stripe documentation for more options., (*6)

use ruskid\stripe\StripeCheckout;

=
StripeCheckout::widget([
    'action' => '/',
    'name' => 'Demo test',
    'description' => '2 widgets ($20.00)',
    'amount' => 2000,
    'image' => '/128x128.png',
]);
?>

Custom checkout form is an extended version of simple form, but you can customize the button (see buttonOptions) and handle token as you want (tokenFunction)., (*7)

use ruskid\stripe\StripeCheckoutCustom;

=
StripeCheckoutCustom::widget([
    'action' => '/',
    'name' => 'Demo test',
    'description' => '2 widgets ($20.00)',
    'amount' => 2000,
    'image' => '/128x128.png',
    'buttonOptions' => [
        'class' => 'btn btn-lg btn-success',
    ],
    'tokenFunction' => new JsExpression('function(token) {
                alert("Here you should control your token.");
    }'),
    'openedFunction' => new JsExpression('function() {
                alert("Model opened");
    }'),
    'closedFunction' => new JsExpression('function() {
                alert("Model closed");
    }'),
]);
?>

StripeFormV2 - is getting depreciated on 14 September 2019, (*8)

You can use new StripeForm.php. But I don't see it so useful, (*9)

use ruskid\stripe\StripeForm;

 $form = StripeForm::begin([
     'action' => Url::toRoute('payment/create'),
     'options' => [
         'autocomplete' => 'on',
         'data-secret' => 'payment intent client secret',
     ],
     'elementsOptions' => [
         'locale' => 'es' // stripe elements language
     ],
     'formEvents' => [
         'beforeSubmit' => 'what ever form events',
         'submit' => new JsExpression('function(event) {
              // you can define as you want
              // stripe.handleCardPayment()
              // stripe.createToken()
         }'),
     ]
 ]);

echo $form->cardInput([
    'hidePostalCode' => true,
    'style' => [
        'base' => [
            'color' => 'blue',
        ],
        'invalid' => [
            'color' => 'red',
            'iconColor' => 'red'
        ]
    ],
], [
    'change' => new JsExpression('function(event) {        
        if (event.error) {
            alert(event.error.message);
        } else {
           // input is good
        }
    }')
]);

echo $form->cardNumber();
echo $form->cardExpiry();
echo $form->cardCvc();

echo Html::submitButton('Submit');

StripeForm::end();

The Versions

10/02 2017

dev-master

9999999-dev https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe

05/02 2017

1.5

1.5.0.0 https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe

05/02 2017

1.4

1.4.0.0 https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe

08/06 2016

1.3

1.3.0.0 https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe

21/03 2016

1.2

1.2.0.0 https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe

15/04 2015

1.1

1.1.0.0 https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe

24/03 2015

v1.0

1.0.0.0 https://github.com/ruskid/yii2-stripe

Yii2 Stripe Wrapper

  Sources   Download

GNU

The Requires

 

by Victor Demin

yii2 stripe