matheusfs/laravel-checkout
最新稳定版本:0.3.3
Composer 安装命令:
composer require matheusfs/laravel-checkout
包简介
Add complete shopping functionalities to your application
README 文档
README
Laravel checkout facade to Pagar.me v4 api
Test coverage map
Instalation
composer require matheusfs/laravel-checkout
php artisan vendor:publish --provider="MatheusFS\Laravel\Checkout\CheckoutServiceProvider" --tag="config"
Simple payment link redirect
public function buy(Request $request, $id) { # Request creates objects from inputs name $shipping = (object) $request->shipping; $customer = (object) $request->customer; $item = Product::find($id); # your product model goes here # Normalize address w/ Pagar.me v4 API $address = new Address( $shipping->street, $shipping->street_number, $shipping->zipcode, 'br', # Default country, if you operate w/ more than one country you can modify the request to ask user $shipping->state, $shipping->city, $shipping->neighborhood, $shipping->complementary ); # Normalize shipping w/ Pagar.me v4 API $Shipping = new Shipping($shipping->name, $address, $shipping->fee, new DateTime()); # Initiate facade $pagarme = new Checkout(); # Normalize customer and billing w/ Pagar.me v4 API $pagarme->setCustomer($customer->name, $customer->cpf, $customer->phone_number, $customer->email); $pagarme->setBilling('Entrega', $address); $pagarme->setShipping($Shipping); # Add normalized item to checkout $pagarme->addItem($item->id, $item->label, $item->price); # Redirect the user to the generated payment link return redirect($pagarme->getPaymentLink($item->price + $shipping->fee)); }
统计信息
- 总下载量: 11.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-11