承接 amonger/laravel-payment-commands 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amonger/laravel-payment-commands

最新稳定版本:v0.1.5

Composer 安装命令:

composer require amonger/laravel-payment-commands

包简介

Payment commands for laravel

README 文档

README

This repo contains a set of commands which allow you to use Laravels command bus to take payments through paypal express (with more to come).

Setting up

Initially you're going to have to find your api details, which you can find under your profile page on paypal.

You'll need to add these to your .env file

PAYPAL_USERNAME=username
PAYPAL_PASSWORD=password
PAYPAL_SIGNATURE=signature
#PAYPAL_TEST_MODE=true # Be sure to use this if accessing a sandbox!

You'll then need to add the gateway service provider to your app.php. This binds the provider to the GatewayInterface.

    'providers' => [
        ...
        PaymentCommands\Paypal\Providers\GatewayServiceProvider::class
    ],

Dispatching Commands

After this has been added, you're good to go! Just fire the command bus in your controller for handling the payment. This will return the redirect url, which you can then redirect to.

    public function index()
    {
        $cancelUrl = url('/cancel');
        $returnUrl = url('/capture');
        $currency = 'GBP';

        $items = [
            [
                'price' => 200,
                'description' => 'A bike',
                'quantity' => 1
            ]
        ];

        $redirectUrl = $this->dispatch(new MakePayment($items, $currency, $cancelUrl, $returnUrl));
        return redirect($redirectUrl);
    }

After the payment has been completed, you redirect the user back to your website.

    public function capture()
    {
        $this->dispatch(new CapturePayment(Input::get('token'), Input::get('payerID')));
    }

Extending

Each stage of the command bus fires an event which you can hook into.

You can read about how to implement this by looking at the Event Documentation

统计信息

  • 总下载量: 710
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-18