尊龙凯时人生就是博

Laravel¿ª·¢£ºÔõÑùʹÓÃLaravel CashierʵÏÖ¶©Ôĸ¶¿î £¿

laravelÊÇÒ»¸öºÜÊÇÊ¢ÐеÄphp¿ò¼Ü£¬±»ÆÕ±éÓ¦ÓÃÓÚweb¿ª·¢ÁìÓò¡£ laravel cashierÊÇÒ»¸öÌṩ¶©Ôĸ¶¿î¹¦Ð§µÄÀ©Õ¹°ü£¬Ê¹µÃ¿ª·¢Ö°Ô±¿ÉÒÔÇáËɵش¦Àí¶©Ôĺ͸¶¿îÏà¹ØµÄÂß¼­£¬¿ÉÒÔ¼«´óµØÌáÉý¿ª·¢Ð§ÂÊ¡£

±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃLaravel CashierʵÏÖ¶©Ôĸ¶¿î¹¦Ð§¡£

×°ÖÃLaravel Cashier

Ê×ÏÈ£¬ÐèҪװÖÃLaravel Cashier¡£Í¨¹ýComposer×°Öã¬Ö»ÐèÒªÔÚÖÕ¶ËÊäÈëÒÔÏÂÏÂÁ

composer require laravel/cashier

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬ÐèÒªÐû²¼CashierµÄÉèÖÃÎļþºÍÊý¾Ý¿âǨáãÎļþ£º

php artisan vendor:publish --provider="LaravelCashierCashierServiceProvider" --tag="cashier-migrations"
php artisan migrate

µÇ¼ºó¸´ÖÆ

ÉèÖÃStripe

Laravel CashierĬÈÏʹÓÃStripe×÷Ϊ֧¸¶Æ½Ì¨£¬Òò´ËÐèÒªÔÚStripeÉÏ×¢²áÕ˺Å£¬²¢ÇÒ»ñÈ¡APIÃÜÔ¿£¨Secret key£©ºÍ¹«Ô¿£¨Publishable key£©¡£

ÔÚ.envÎļþÖÐÉèÖÃÏà¹ØµÄStripeÕË»§ÐÅÏ¢£º

STRIPE_KEY=your-stripe-publishable-key
STRIPE_SECRET=your-stripe-secret-key

µÇ¼ºó¸´ÖÆ

½¨É趩ÔÄÍýÏë

ÔÚStripeµÄ¿ØÖÆÃæ°åÖУ¬¿ÉÒÔ½¨Éè¶à¸ö¶©ÔÄÍýÏë¡£ÀýÈ磬¿ÉÒÔ½¨ÉèÒ»¸öÔ¶ȶ©ÔÄ¡¢¼¾¶È¶©ÔÄ»òÕßÄê¶È¶©ÔĵÈ¡£

ÔÚLaravelÖУ¬¿ÉÒÔʹÓÃÈçÏ´úÂëÀ´½¨É趩ÔÄÍýÏ룺

use IlluminateDatabaseEloquentModel;
use LaravelCashierSubscriptionBuilder;

class Plan extends Model
{
    public function createStripePlan()
    {
        $builder = new SubscriptionBuilder();
        $builder->nickname('Monthly')->interval(SubscriptionBuilder::INTERVAL_MONTH);
        $builder->name('Monthly Plan')->amount(1000);
        $builder->create();
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽨ÉèÁËÒ»¸öÔ¶ȶ©ÔÄÍýÏ룬¼ÛǮΪ$10¡£

½¨É趩ÔÄ

ÔÚLaravelÖУ¬¿ÉÒÔʹÓÃÈçÏ´úÂ뽨É趩ÔÄ£º

$user = User::find(1);

$user->newSubscription('monthly', 'monthly-plan')->create($paymentMethod);

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽨ÉèÁËÒ»¸öÃûΪ¡°monthly¡±µÄ¶©ÔÄ£¬¹ØÁªµÄÊÇÇ°ÎĽ¨ÉèµÄ¶©ÔÄÍýÏë¡£

ÕâÀïÐèҪת´ïÒ»¸ö$paymentMethod²ÎÊý£¬ÌåÏÖÓû§µÄÖ§¸¶·½·¨¡£Laravel CashierÖ§³Ö¶àÖÖÖ§¸¶·½·¨£¬°üÀ¨ÐÅÓÿ¨¡¢ÒøÐп¨ºÍÖ§¸¶±¦µÈ¡£

×÷·Ï¶©ÔÄ

×÷·Ï¶©ÔÄͬÑùºÜÊǼòÆÓ£¬Ö»ÐèҪŲÓÃcancel()ÒªÁì¼´¿É£º

$user->subscription('monthly')->cancel();

µÇ¼ºó¸´ÖÆ

´¦Àí¸¶¿îʧ°Ü

ÈôÊÇÓû§µÄ¸¶¿îʧ°Ü£¬Laravel Cashier»á×Ô¶¯·¢ËÍÓʼþÌáÐÑÓû§£¬ÒªÇóÓû§¸üÐÂÖ§¸¶ÐÅÏ¢¡ £¿ª·¢Ö°Ô±¿ÉÒÔÔÚϵͳÖÐÉèÖÃÓʼþÄ£°å£¬²¢ÇÒ¿ÉÒÔÇáËɵØ×Ô½ç˵ÓʼþÄÚÈÝ¡£

namespace AppProviders;

use IlluminateSupportServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        IlluminateNotificationsNotification::observe(function ($notification) {
            $notification->setChannels(['mail']);
        });
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂë¸æËßLaravel CashierֻʹÓÃÓʼþ֪ͨ·½·¨¡£

½áÓï

Laravel CashierΪLaravel¿ª·¢Ö°Ô±ÌṩÁËÒ»¸ö¸ßЧ¡¢Îȹ̵Ķ©Ôĸ¶¿î¹¦Ð§£¬×èÖ¹ÁË×ÔÐпª·¢¸¶¿î¹¦Ð§µÄÖظ´ÀͶ¯£¬¹ØÓÚÔÚÏßÉ̳ǡ¢¶©ÔÄЧÀ͵ÈÓªÒµ³¡¾°ºÜÊÇÓÐÓá£

ÒÔÉϾÍÊÇLaravel¿ª·¢£ºÔõÑùʹÓÃLaravel CashierʵÏÖ¶©Ôĸ¶¿î £¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ