Laravel Cashier for Openpay Billing Services

Packages

August 20th, 2021

cashier-openpay-featured.png

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:

1use Perafan\CashierOpenpay\Billable;
2 
3class User extends Authenticatable
4{
5 use Billable;
6}

Then, you can interact with Openpay billing via a User model instance:

1// Create a new customer.
2$user->createAsOpenpayCustomer();
3 
4// Create a new customer, and send additional data.
5$openpay_customer = $user->createAsOpenpayCustomer([
6 'name' => 'Teofilo',
7 'last_name' => 'Velazco',
8 'phone_number' => '4421112233',
9 'address' => [
10 'line1' => 'Privada Rio No. 12',
11 'line2' => 'Co. El Tintero',
12 'line3' => '',
13 'postal_code' => '76920',
14 'state' => 'Querétaro',
15 'city' => 'Querétaro.',
16 'country_code' => 'MX'
17 ],
18]);
19 
20// Get the Openpay customer record.
21$openpay_customer = $user->asOpenpayCustomer();
22 
23// Update a customer
24$openpay_customer = $user->asOpenpayCustomer();
25$openpay_customer->name = 'Juan';
26$openpay_customer->last_name = 'Godinez';
27$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.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.