public function testCreate_returnsTransactionWhenTransactionFails() { $creditCard = SubscriptionHelper::createCreditCard(); $plan = SubscriptionHelper::triallessPlan(); $result = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $plan['id'], 'price' => Braintree\Test\TransactionAmounts::$decline]); Test\Helper::assertPrintable($result); $this->assertFalse($result->success); $this->assertEquals(Braintree\Transaction::PROCESSOR_DECLINED, $result->transaction->status); }
public function testCreate_withValidationErrors() { $result = Braintree\Customer::create(['email' => 'invalid', 'creditCard' => ['number' => 'invalid', 'billingAddress' => ['streetAddress' => str_repeat('x', 256)]]]); Test\Helper::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); }
public 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(['amount' => '100.00', 'billing' => ['streetAddress' => '200 2nd Street'], 'creditCard' => ['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); Test\Helper::assertPrintable($result); $transaction = $result->transaction; $this->assertEquals(Braintree\Transaction::AVS, $transaction->gatewayRejectionReason); }