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

PayPal Pro - Duplicate entry for key 'email' #1874

Closed
Noodleyman opened this Issue Feb 21, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@Noodleyman
Copy link

Noodleyman commented Feb 21, 2018

ran into this whilst testing today.

  1. Log into the site as an existing customer (test1@test.com)
  2. add an item to the cart and checkout using PayPal Pro
  3. Make your payment, but use a different email address to your account, (test2@test.com)
  4. return to the site and press the button to complete the sale
  5. If test2@test.com already exists on your site (customer has used it before) youg et a HTTP 500 error

From Log:
File: [class.cubecart.construct.confirm.php] Line: [102] "UPDATE CubeCart_customerSETtitle = '',first_name = 'childsfancydress',last_name = 'childsfancydress',email = 'testbuyer@childsfancydress.co.uk',phone = '65789' WHERE CubeCart_customer.customer_id = '1';" - Duplicate entry 'test2@test.com' for key 'email'

it tried to update the email address for your logged in customer account record to that of another customer and violates the primary key.

@abrookbanks

This comment has been minimized.

Copy link
Member

abrookbanks commented Feb 21, 2018

Begs the question.. do we change the email address from the one supplied by PayPal or keep it as the one used to login. I'd suggest the latter as it was the last preference.

@abrookbanks

This comment has been minimized.

Copy link
Member

abrookbanks commented Feb 21, 2018

Ignore me...

@Noodleyman

This comment has been minimized.

Copy link

Noodleyman commented Feb 21, 2018

My thoughts would be that if the customer is unregistered, or doesn't already exist in CubeCart_customer then it gets added.

There shouldn't be any need to update/revise the CubeCart_customer email address at alll. Checking out using a PayPal email address which is different shouldn't matter. the PP email address should be captured in CubeCart_order_summary

@abrookbanks

This comment has been minimized.

Copy link
Member

abrookbanks commented Feb 21, 2018

Yup. Thanks.

I changed;

$GLOBALS['db']->update('CubeCart_customer', $customer, array('customer_id' => $GLOBALS['user']->getId()));

To:

if ($GLOBALS['db']->select('CubeCart_customer', 'customer_id', array('email' => $customer['email']), false, 1, false, false)) {
	unset($customer['email']); // It's taken so we can't update to this.
}
$GLOBALS['db']->update('CubeCart_customer', $customer, array('customer_id' => $GLOBALS['user']->getId()));
@abrookbanks

This comment has been minimized.

Copy link
Member

abrookbanks commented Feb 21, 2018

In fact you are right just the following will suffice...

unset($customer['email']); 
$GLOBALS['db']->update('CubeCart_customer', $customer, array('customer_id' => $GLOBALS['user']->getId()));

@abrookbanks abrookbanks added the bug label Feb 21, 2018

@abrookbanks

This comment has been minimized.

Copy link
Member

abrookbanks commented Feb 21, 2018

Fixed with 1.1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment