/** * Handle the event. * * @param \Laravel\Spark\Events\Profile\ContactInformationUpdated $event */ public function handle($event) { if (!$event->user->hasBillingProvider()) { return; } BraintreeCustomer::update($event->user->braintree_id, ['email' => $event->user->email]); }
public function testUpdate_doesNotWorkWithOnetimePayPalNonce() { $customerResult = Braintree\Customer::create(['creditCard' => ['number' => '5105105105105100', 'expirationDate' => '05/12', 'options' => ['makeDefault' => true]]]); $paypalAccountToken = 'PAYPALToken-' . strval(rand()); $http = new HttpClientApi(Braintree\Configuration::$global); $nonce = $http->nonceForPayPalAccount(['paypal_account' => ['access_token' => 'PAYPAL_ACCESS_TOKEN', 'token' => $paypalAccountToken, 'options' => ['makeDefault' => true]]]); $result = Braintree\Customer::update($customerResult->customer->id, ['paymentMethodNonce' => $nonce]); $this->assertFalse($result->success); $errors = $result->errors->forKey('customer')->forKey('paypalAccount')->errors; $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); }