Пример #1
0
 function testCreate_returnsTransactionWhenTransactionFails()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $plan = Braintree_SubscriptionTestHelper::triallessPlan();
     $result = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $plan['id'], 'price' => Braintree_Test_TransactionAmounts::$decline));
     Braintree_TestHelper::assertPrintable($result);
     $this->assertFalse($result->success);
     $this->assertEquals(Braintree_Transaction::PROCESSOR_DECLINED, $result->transaction->status);
 }
Пример #2
0
 function testCreate_withValidationErrors()
 {
     $result = Braintree_Customer::create(array('email' => 'invalid', 'creditCard' => array('number' => 'invalid', 'billingAddress' => array('streetAddress' => str_repeat('x', 256)))));
     Braintree_TestHelper::assertPrintable($result);
     $this->assertEquals(false, $result->success);
     $errors = $result->errors->forKey('customer')->onAttribute('email');
     $this->assertEquals(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code);
     $errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number');
     $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code);
     $errors = $result->errors->forKey('customer')->forKey('creditCard')->forKey('billingAddress')->onAttribute('streetAddress');
     $this->assertEquals(Braintree_Error_Codes::ADDRESS_STREET_ADDRESS_IS_TOO_LONG, $errors[0]->code);
 }
 function testGatewayRejectionOnAvs()
 {
     $old_merchant_id = Braintree_Configuration::merchantId();
     $old_public_key = Braintree_Configuration::publicKey();
     $old_private_key = Braintree_Configuration::privateKey();
     Braintree_Configuration::merchantId('processing_rules_merchant_id');
     Braintree_Configuration::publicKey('processing_rules_public_key');
     Braintree_Configuration::privateKey('processing_rules_private_key');
     $result = Braintree_Transaction::sale(array('amount' => '100.00', 'billing' => array('streetAddress' => '200 2nd Street'), 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12')));
     Braintree_Configuration::merchantId($old_merchant_id);
     Braintree_Configuration::publicKey($old_public_key);
     Braintree_Configuration::privateKey($old_private_key);
     $this->assertFalse($result->success);
     Braintree_TestHelper::assertPrintable($result);
     $transaction = $result->transaction;
     $this->assertEquals(Braintree_Transaction::AVS, $transaction->gatewayRejectionReason);
 }