/**
  * Delete Braintree customer when Magento customer is deleted
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->config->isActive()) {
         return $this;
     }
     $customer = $observer->getEvent()->getCustomer();
     $customerId = $this->helper->generateCustomerId($customer->getId(), $customer->getEmail());
     if ($this->vault->exists($customerId)) {
         $this->vault->deleteCustomer($customerId);
     }
     return $this;
 }
Пример #2
0
 public function testDeleteCustomerException()
 {
     $exception = new \Braintree_Exception();
     $customerID = 1;
     $this->braintreeCustomerMock->expects($this->once())->method('delete')->with($customerID)->willThrowException($exception);
     $this->loggerMock->expects($this->once())->method('critical')->with($exception);
     $this->model->deleteCustomer($customerID);
 }