Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing email on PayLink with custom Billable model #8

Closed
enkota opened this issue Jun 13, 2020 · 5 comments
Closed

Passing email on PayLink with custom Billable model #8

enkota opened this issue Jun 13, 2020 · 5 comments

Comments

@enkota
Copy link

enkota commented Jun 13, 2020

Hey again,

When using something other than User for Billable I can't seem to pass through the customer_email parameter as specified on the Paddle docs.

$payLink = $tenant->newSubscription('default', $starter = 123456)
  ->returnTo(route('home'))
  ->create([
      'customer_email' => $tenant->owner->email,
       'prices' => ["USD:1200"]
  ]);

Price seems to work fine, but using customer_email will not pre-fill the email field. I have tried adding marketing_consent = 1 as it mentions this is required but no difference.

Thanks!

@enkota
Copy link
Author

enkota commented Jun 13, 2020

I can see under ManagesCustomer you are referencing the email column on the particular model. It would be good to override so we can set the customer_email in the create method.

    public function paddleEmail()
    {
        return $this->email;
    }

@driesvints
Copy link
Member

Hey @enkota. Please read the core concepts in the docs, particularly the section here: https://laravel.com/docs/7.x/cashier-paddle#user-identification

We take over control of the customer_email key in Cashier to ensure every payment made is properly linked to the same use in Paddle. This is absolutely vital to make sure Cashier Paddle works properly.

Unfortunately this is due to how Paddle's user identification works and there's no other way for us to achieve this.

@enkota
Copy link
Author

enkota commented Jun 15, 2020

Hey @driesvints. I understand that you need to control the customer_email key, however, at the moment when using a different Billable model than User, the payLink will not assign to any email and require the user to enter one on the pop-up.

I do not need to update the email after creation, only the inital subscription where the Tenant owner is the relation to the user.

If you’d rather not allow the email to be passed on the create() method, would you allow the email to be passed through newSubscription()?

For my case, adding the relation to paddleEmail works perfectly since the Tenant belongs to the owner (User):

    public function paddleEmail()
    {
        return $this->owner->email;
    }

This would be useful as at the moment no email can be assigned on a Billable model outside User.

Thanks!

@driesvints
Copy link
Member

If you’d rather not allow the email to be passed on the create() method, would you allow the email to be passed through newSubscription()?

Hmm we don't allow that anywhere?

I think you're looking for https://laravel.com/docs/7.x/cashier-paddle#customer-defaults. You can overwrite the paddleEmail method just like you did. It was intended to be used like this. I'm not sure if I understand you completely correctly?

@enkota
Copy link
Author

enkota commented Jun 15, 2020

Hey @driesvints ahh sorry, missed that part in the docs. Didn’t realise we could override that on the Model. All makes sense now :) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants