Laravel Cashier for Openpay Billing Services
Published on by Paul Redmond
The cashier-openpay package by Pedro Perafán provides an expressive, fluent interface to subscriptions using Openpay billing services with Laravel.
This package is set up by defining an Openpay Billable
trait:
use Perafan\CashierOpenpay\Billable; class User extends Authenticatable{ use Billable;}
Then, you can interact with Openpay billing via a User
model instance:
// Create a new customer.$user->createAsOpenpayCustomer(); // Create a new customer, and send additional data.$openpay_customer = $user->createAsOpenpayCustomer([ 'name' => 'Teofilo', 'last_name' => 'Velazco', 'phone_number' => '4421112233', 'address' => [ 'line1' => 'Privada Rio No. 12', 'line2' => 'Co. El Tintero', 'line3' => '', 'postal_code' => '76920', 'state' => 'Querétaro', 'city' => 'Querétaro.', 'country_code' => 'MX' ],]); // Get the Openpay customer record.$openpay_customer = $user->asOpenpayCustomer(); // Update a customer$openpay_customer = $user->asOpenpayCustomer();$openpay_customer->name = 'Juan';$openpay_customer->last_name = 'Godinez';$openpay_customer->save();
Here are some of the highlight features you can do via this package:
- Create new customers
- Manage existing customers
- Delete customers
- Add a card to a user
- Get a user's card(s)
- Create and manage bank accounts for a customer
- Create and manage charges for a customer
- Issue refunds on a charge
- Send/receive transfers
- Make a payout to a customer and manage customer payouts
- Add and Manage subscriptions
- Interact directly with the Openpay PHP SDK
Under the hood, cashier-openpay uses the Openpay PHP bindings package, which is another excellent resource if you want to learn more about using Openpay with PHP.
I'd recommend heading to the usage section of the README to see everything you can do with this package. Also, you can learn more about this package, get full installation instructions, and view the source code on GitHub.