Closed ApplicationError closed 4 years ago
I'm going to add a Stripe payment to my website with Cashier and I don't have an email field in my Billable model either.
I find it weird that there is a reference to an email
field in the using model, in the Billable::createAsStripeCustomer method:
public function createAsStripeCustomer($token, array $options = [])
{
$options = array_key_exists('email', $options)
? $options : array_merge($options, ['email' => $this->email]);
// ...
(@ApplicationError this may be what causes your error, but it's hard to tell since you provide no information on how to reproduce your error).
I'm wondering why there is such a hard-coded reference to an email
member... In Billable we don't know anything about the model that will use the trait. As far as I can see, this email is just added to the options when creating the Stripe Customer so it is easier to find in the Stripe admin. The email field is not required when creating a Stripe Customer, so, the email should not be mandatory in the Billable Model... (or if so it should be said in the docs, but I don't think it should).
Maybe the existence of the email
member should be tested and added to the options only if present?
@ApplicationError Did you manage to use the Company model as the billable model okay? I also have the exact same use-case and was wondering whether this will cause any problems later?
Hmm, I agree. Email shouldn't be a requirement. I'll mark this as a feature request. Welcoming PRs for this.
Based on the Billable::createAsStripeCustomer method, you could just pass in an empty email key. However considering the benefits that providing an emails gives you / your companies in terms of automatic notifications on failed payments, etc, that are provided by Stripe. Why not provide a company billing/accounts email, someone needs to know about billing after all.
Sent in a PR to https://github.com/laravel/cashier/pull/887
I am encountering an error, and I'm wondering if this could be caused by the fact that I configured cashier to use my 'Company' model instead of the 'User' model. My 'companies' table does not have an 'email' column. I am suspecting that this could be the cause of the error I'm getting.
The error:
Thoughts?