function test_paypalAccountEmail()
 {
     $nonce = Braintree_HttpClientApi::nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE')));
     $customerId = 'UNIQUE_CUSTOMER_ID-' . strval(rand());
     $customerResult = Braintree_Customer::create(array('paymentMethodNonce' => $nonce, 'id' => $customerId));
     $this->assertTrue($customerResult->success);
     $customer = $customerResult->customer;
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::paypalAccountEmail()->is('*****@*****.**')));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
 }
예제 #2
0
 function testUpdate_doesNotWorkWithOnetimePayPalNonce()
 {
     $customerResult = Braintree_Customer::create(array('creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12', 'options' => array('makeDefault' => true))));
     $paypalAccountToken = 'PAYPALToken-' . strval(rand());
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(array('paypal_account' => array('access_token' => 'PAYPAL_ACCESS_TOKEN', 'token' => $paypalAccountToken, 'options' => array('makeDefault' => true))));
     $result = Braintree_Customer::update($customerResult->customer->id, array('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);
 }
 function testDelete_worksWithPayPalAccounts()
 {
     $paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand());
     $customer = Braintree_Customer::createNoValidate();
     $nonce = Braintree_HttpClientApi::nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken)));
     $paypalAccountResult = Braintree_PaymentMethod::create(array('customerId' => $customer->id, 'paymentMethodNonce' => $nonce));
     $this->assertTrue($paypalAccountResult->success);
     Braintree_PaymentMethod::delete($paymentMethodToken);
     $this->setExpectedException('Braintree_Exception_NotFound');
     Braintree_PaymentMethod::find($paymentMethodToken);
 }
 function testHandlesPayPalAccounts()
 {
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(array('paypal_account' => array('access_token' => 'PAYPAL_ACCESS_TOKEN')));
     $result = Braintree_Transaction::sale(array('amount' => Braintree_Test_TransactionAmounts::$authorize, 'paymentMethodNonce' => $nonce));
     $this->assertTrue($result->success);
     $paypalDetails = $result->transaction->paypalDetails;
     $collection = Braintree_Transaction::search(array(Braintree_TransactionSearch::paypalPaymentId()->is($paypalDetails->paymentId), Braintree_TransactionSearch::paypalAuthorizationId()->is($paypalDetails->authorizationId), Braintree_TransactionSearch::paypalPayerEmail()->is($paypalDetails->payerEmail)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($result->transaction->id, $collection->firstItem()->id);
 }
 function testCreate_fromPayPalACcount()
 {
     $paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand());
     $customer = Braintree_Customer::createNoValidate();
     $plan = Braintree_SubscriptionTestHelper::triallessPlan();
     $nonce = Braintree_HttpClientApi::nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken)));
     $paypalResult = Braintree_PaymentMethod::create(array('customerId' => $customer->id, 'paymentMethodNonce' => $nonce));
     $subscriptionResult = Braintree_Subscription::create(array('paymentMethodToken' => $paymentMethodToken, 'planId' => $plan['id']));
     $this->assertTrue($subscriptionResult->success);
     $transaction = $subscriptionResult->subscription->transactions[0];
     $this->assertEquals('*****@*****.**', $transaction->paypalDetails->payerEmail);
 }
 function testCreate_withPayPalHandlesBadUnvalidatedNonces()
 {
     $nonce = Braintree_HttpClientApi::nonceForPayPalAccount(array('paypal_account' => array('access_token' => 'PAYPAL_ACCESS_TOKEN', 'consent_code' => 'PAYPAL_CONSENT_CODE')));
     $result = Braintree_Transaction::sale(array('amount' => Braintree_Test_TransactionAmounts::$authorize, 'paymentMethodNonce' => $nonce, 'options' => array('submitForSettlement' => true)));
     $this->assertFalse($result->success);
     $errors = $result->errors->forKey('transaction')->forKey('paypalAccount')->errors;
     $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CANNOT_HAVE_BOTH_ACCESS_TOKEN_AND_CONSENT_CODE, $errors[0]->code);
 }
예제 #7
0
 function testDelete()
 {
     $paymentMethodToken = 'PAYPALToken-' . strval(rand());
     $customer = Braintree_Customer::createNoValidate();
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken)));
     Braintree_PaymentMethod::create(array('customerId' => $customer->id, 'paymentMethodNonce' => $nonce));
     Braintree_PayPalAccount::delete($paymentMethodToken);
     $this->setExpectedException('Braintree_Exception_NotFound');
     Braintree_PayPalAccount::find($paymentMethodToken);
 }