public function testFind_exposesNullThreeDSecureInfoIfNoneExists()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(["creditCard" => ["number" => "4111111111111111", "expirationMonth" => "11", "expirationYear" => "2099"]]);
     $foundNonce = Braintree\PaymentMethodNonce::find($nonce);
     $info = $foundNonce->threeDSecureInfo;
     $this->assertEquals($nonce, $foundNonce->nonce);
     $this->assertNull($info);
 }
예제 #2
0
 public function testCreateCustomerWithCardUsingNonce()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(["creditCard" => ["number" => "4111111111111111", "expirationMonth" => "11", "expirationYear" => "2099"], "share" => true]);
     $result = Braintree\Customer::create(['creditCard' => ['paymentMethodNonce' => $nonce]]);
     $this->assertTrue($result->success);
     $this->assertSame("411111", $result->customer->creditCards[0]->bin);
     $this->assertSame("1111", $result->customer->creditCards[0]->last4);
 }
예제 #3
0
 public function testFromNonce_ReturnsErrorWhenNonceIsConsumed()
 {
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(array("credit_card" => array("number" => "4009348888881881", "expirationMonth" => "11", "expirationYear" => "2099"), "customerId" => $customer->id));
     Braintree\CreditCard::fromNonce($nonce);
     $this->setExpectedException('Braintree\\Exception\\NotFound', "consumed");
     Braintree\CreditCard::fromNonce($nonce);
 }
 public function testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce()
 {
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(['credit_card' => ['number' => '4111111111111111', 'expirationMonth' => '12', 'expirationYear' => '2020', 'options' => ['validate' => false]]]);
     $address = Braintree\Address::create(['customerId' => $customer->id, 'firstName' => 'Bobby', 'lastName' => 'Tables'])->address;
     $result = Braintree\PaymentMethod::create(['paymentMethodNonce' => $nonce, 'customerId' => $customer->id, 'billingAddressId' => $address->id]);
     $this->assertTrue($result->success);
     $this->assertTrue(is_a($result->paymentMethod, 'Braintree\\CreditCard'));
     $token = $result->paymentMethod->token;
     $foundCreditCard = Braintree\CreditCard::find($token);
     $this->assertTrue(NULL != $foundCreditCard);
     $this->assertEquals('Bobby', $foundCreditCard->billingAddress->firstName);
     $this->assertEquals('Tables', $foundCreditCard->billingAddress->lastName);
 }
예제 #5
0
 public function testUpdate_canUpdatePaymentMethodWithPaymentMethodNonce()
 {
     $oldCreditCard = SubscriptionHelper::createCreditCard();
     $plan = SubscriptionHelper::triallessPlan();
     $subscription = Braintree\Subscription::create(['paymentMethodToken' => $oldCreditCard->token, 'price' => '54.99', 'planId' => $plan['id']])->subscription;
     $customerId = Braintree\Customer::create()->customer->id;
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(["creditCard" => ["number" => "4111111111111111", "expirationMonth" => "11", "expirationYear" => "2099"], "customerId" => $oldCreditCard->customerId, "share" => true]);
     $result = Braintree\Subscription::update($subscription->id, ['paymentMethodNonce' => $nonce]);
     $this->assertTrue($result->success);
     $newCreditCard = Braintree\CreditCard::find($result->subscription->paymentMethodToken);
     $this->assertEquals("1111", $newCreditCard->last4);
     $this->assertNotEquals($oldCreditCard->last4, $newCreditCard->last4);
 }
예제 #6
0
 public function testSale_withThreeDSecureOptionRequired()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(["creditCard" => ["number" => "4111111111111111", "expirationMonth" => "11", "expirationYear" => "2099"]]);
     $result = Braintree\Transaction::sale(['merchantAccountId' => Test\Helper::threeDSecureMerchantAccountId(), 'amount' => '100.00', 'creditCard' => ['number' => '4111111111111111', 'expirationDate' => '05/09'], 'options' => ['threeDSecure' => ['required' => true]]]);
     $this->assertFalse($result->success);
     $this->assertEquals(Braintree\Transaction::THREE_D_SECURE, $result->transaction->gatewayRejectionReason);
 }