yii2mod / yii2-cashier

Yii2 Cashier provides an interface to Stripe's subscription billing services.
MIT License
45 stars 25 forks source link

Stripe lib updated to 7, Stripe Checkout & webhook & some new attributes #15

Closed raimon-segura closed 4 years ago

raimon-segura commented 4 years ago

Hi Igor!

I've updated the stipe library, composer.json , from version 4 to 7, the latest one. Also, I've updated its test. Beside this, I've added the checkout UI & Stripe's session for an easy & quick payment gateway.

The webhook creates a subscriptions if its created with "Stripe checkout UI" , also you can refresh/load subscriptions from stripe's api.

Hope it works for you! ...Let me how it looks

Thanks!

raimon.

raimon-segura commented 4 years ago

https://travis-ci.org/yii2mod/yii2-cashier/builds/625800603?utm_source=github_status&utm_medium=notification

it shows a api key error: Stripe\Exception\AuthenticationException: No API key provided. (HINT: set your API key using "Stripe::setApiKey()". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.

How do you test those cases? ..I've seen in your test results env vars for stripe keys, but I'm not sure how to do it

Setting environment variables from repository settings $ export STRIPE_SECRET=[secure]

thanks!

ihorchepurnyi commented 4 years ago

Hi @raimon-segura, thanks a lot for your PR. I'll check it today and I hope I'll merge it

ihorchepurnyi commented 4 years ago

But, this package is very similar to the laravel cashier package. I think we should check the last changes in that one

raimon-segura commented 4 years ago

Hi!... thanks for your quick reply!

that's true, lavarel one has more functions than yii2 version... I'll take a look.

Although, lavarel package seems that doesn't have any "stripe checkout" widget nor metada optional data. The main changes are:

Besides this, if you merge these changes you will need to "release" a new version, right?

Do you have any guideline to fix travis errors about stripe key?

Many Thanks!

ihorchepurnyi commented 4 years ago

@raimon-segura I'll check laravel version first and then I'll let you know

raimon-segura commented 4 years ago

Hi Igor!,

I've added few changes.. I'm thinking to add another column(current_period_end) to keep when the subscription ends.

I've tried to use ends_at colum to store "current_period_end" but its a quite rare, because of how is used this field in SubscriptionModel ...So, resume/cancel/create subscription not works as before and I will undo changes about ends_at as soon as posible.

A null value of ends_at means that Subscription is NOT cancelled: SubscriptionModel.php L141: public function cancelled(): bool { return !is_null($this->ends_at); }

Because of that, there are 2 test that are failing. lavarel cashier uses ends_at in the same way: https://github.com/laravel/cashier/issues/353 https://github.com/laravel/cashier/blob/10.0/src/Subscription.php#L196 https://laravel.com/docs/5.3/billing#cancelling-subscriptions

regards!

raimon-segura commented 4 years ago

Just updated with new attribute: current_period_end . With that current_period_end & cancel_at_period_end you can check the vadility of a subscription & its recurring billing without any stripe request.

"ends_at" attribute works like lavarel cashier.

let me know how it looks :D

Thanks!

raimon-segura commented 4 years ago

Hi Igor!,

Hope your are doing well!!

I've just update a couple of things: 1- Added composer-lock.json to have the same dependency versions. 2- Update all composer libs to latest version, nesbot/carbon is deprecated and generates some conflicts with other libs in my yii project.

BTW, all tests are passed in my machine :D ... travis-ci have some issues, do you know why?

Many thanks!

paskuale75 commented 4 years ago

what is the most updated version? Why was this pull request not loaded? Thanks

raimon-segura commented 4 years ago

ive been using a forked version , from my repository, for a few weeks... It uses an updated version of php and stripe

Regards

On Fri, May 8, 2020, 19:42 pasquale notifications@github.com wrote:

what is the most updated version? Why was this pull request not loaded? Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yii2mod/yii2-cashier/pull/15#issuecomment-625934077, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMNQISXAKHFZKGU5TZCOILRQRAA5ANCNFSM4J3NWEEA .

raimon-segura commented 4 years ago

Beside php & stripe versions, the most important update is "Stripe's checkout UI". it simplifies a lot the payment process using the stripe UI that complians all the EU laws.Then in the webhook you can save what ever you want: subscription, payment, etc... in your database, Another cool feature is to retrieve all the payments done by user from stripe remote server, so you always can update your own databases in case that webhook fails fo whatever reason.

regards!

kmindi commented 4 years ago

Is there any progress merging this / updating this awesome library to the recent stripe versions/changes?

kmindi commented 4 years ago

btw: symfony requires "PHP 7.2.5 or higher and these PHP extensions (which are installed and enabled by default in most PHP 7 installations): Ctype, iconv, JSON, PCRE, Session, SimpleXML, and Tokenizer;" that's why the build is failing

raimon-segura commented 4 years ago

I've been using a forked version(in my repo) in a php 7.3 server, so it should work changing the php version in composer.json file.

kmindi commented 4 years ago

nice, yet some style fixes are preventing it an the missing api key, see #16 (you might integrate the travis and php version dependency changes here of course already)