πŸ‘₯Connected Customers

It is now possible for a connected account to have direct customers, so instead of those customers appearing in your platform's stripe dashboard they will appear in the dashboard for the connected account they belong to.

You can make any model a connected customer. In our example we will use the "customer" model.

Simply add the ConnectCustomer trait to your customer model and it will inherit all of the required customer functions.

use Lanos\CashierConnect\ConnectCustomer;

class Customer extends Model{

    use ConnectCustomer;
   
}

Now in order to create the connected customer, we must have a Connected account set up in order to take ownership this customer. For our example we will use our store model.

public function createStripeCustomer(Store $store, Customer $customer){

    $stripeCustomer = $customer->createStripeCustomer($store, $customerData);

}

After this, your customer model will now exist within stripe and thanks to the mapping, you will now be able to access and interact with this stripe customer from within your customer model. An outline of some functions are listed below.

Checking if a model exists as a stripe customer

The below function will return a boolean.

$customer->hasCustomerRecord();

Retrieve payment methods

If you need retrieve all of the customers payment methods you can do so via:

$customer->getPaymentMethods();

Delete payment method

You can delete a customers payment method via the below function. You must provide the payment method ID and it must belong to that customer or an exception will be thrown.

$customer->removePaymentMethod($id);

Delete stripe customer

The below function will delete the customer from stripe. Any outstanding subscriptions will be cancelled.

$customer->deleteStripeCustomer();

Last updated