public function test_paypalAccountEmail()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->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);
 }
 public function testDelete()
 {
     $paymentMethodToken = 'PAYPALToken-' . strval(rand());
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(['paypal_account' => ['consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken]]);
     Braintree\PaymentMethod::create(['customerId' => $customer->id, 'paymentMethodNonce' => $nonce]);
     Braintree\PayPalAccount::delete($paymentMethodToken);
     $this->setExpectedException('Braintree\\Exception\\NotFound');
     Braintree\PayPalAccount::find($paymentMethodToken);
 }
예제 #3
0
 public function testCreate_fromPayPalACcount()
 {
     $paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand());
     $customer = Braintree\Customer::createNoValidate();
     $plan = SubscriptionHelper::triallessPlan();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(['paypal_account' => ['consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken]]);
     $paypalResult = Braintree\PaymentMethod::create(['customerId' => $customer->id, 'paymentMethodNonce' => $nonce]);
     $subscriptionResult = Braintree\Subscription::create(['paymentMethodToken' => $paymentMethodToken, 'planId' => $plan['id']]);
     $this->assertTrue($subscriptionResult->success);
     $transaction = $subscriptionResult->subscription->transactions[0];
     $this->assertEquals('*****@*****.**', $transaction->paypalDetails->payerEmail);
 }
 public function testHandlesPayPalAccounts()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(['paypal_account' => ['access_token' => 'PAYPAL_ACCESS_TOKEN']]);
     $result = Braintree\Transaction::sale(['amount' => Braintree\Test\TransactionAmounts::$authorize, 'paymentMethodNonce' => $nonce]);
     $this->assertTrue($result->success);
     $paypalDetails = $result->transaction->paypalDetails;
     $collection = Braintree\Transaction::search([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);
 }
 public function testDelete_worksWithPayPalAccounts()
 {
     $paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand());
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->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);
 }
예제 #6
0
 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);
 }
예제 #7
0
 public function testCreate_withPayPalHandlesBadUnvalidatedNonces()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(['paypal_account' => ['access_token' => 'PAYPAL_ACCESS_TOKEN', 'consent_code' => 'PAYPAL_CONSENT_CODE']]);
     $result = Braintree\Transaction::sale(['amount' => Braintree\Test\TransactionAmounts::$authorize, 'paymentMethodNonce' => $nonce, 'options' => ['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);
 }