function testCreate_canSetTheMerchantAccountId() { $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); $plan = Braintree_SubscriptionTestHelper::triallessPlan(); $result = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $plan['id'], 'merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId())); $this->assertTrue($result->success); $subscription = $result->subscription; $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $subscription->merchantAccountId); }
function testSearch_merchantAccountId() { $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); $rand_id = strval(rand()); $subscription_1 = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'id' => strval(rand()) . '_subscription_' . $rand_id, 'price' => '2'))->subscription; $subscription_2 = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'id' => strval(rand()) . '_subscription_' . $rand_id, 'merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), 'price' => '2'))->subscription; $collection = Braintree_Subscription::search(array(Braintree_SubscriptionSearch::id()->endsWith('subscription_' . $rand_id), Braintree_SubscriptionSearch::merchantAccountId()->in(array(Braintree_TestHelper::nonDefaultMerchantAccountId())), Braintree_SubscriptionSearch::price()->is('2'))); $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription_1)); $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_2)); }
function testUpdate_withCardVerificationAndSpecificMerchantAccount() { $customer = Braintree_Customer::createNoValidate(); $initialCreditCard = Braintree_CreditCard::create(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/12'))->creditCard; $result = Braintree_CreditCard::update($initialCreditCard->token, array('billingAddress' => array('region' => 'IL'), 'options' => array('verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), 'verifyCard' => true))); $this->assertFalse($result->success); $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); }
function testCreate_withCreditCardAndSpecificVerificationMerchantAccount() { $result = Braintree_Customer::create(array('firstName' => 'Mike', 'lastName' => 'Jones', 'company' => 'Jones Co.', 'email' => '*****@*****.**', 'phone' => '419.555.1234', 'fax' => '419.555.1235', 'website' => 'http://example.com', 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12', 'cvv' => '123', 'cardholderName' => 'Mike Jones', 'options' => array('verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), 'verifyCard' => true)))); Braintree_TestHelper::assertPrintable($result); $this->assertFalse($result->success); $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); $this->assertEquals('M', $result->creditCardVerification->cvvResponseCode); $this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode); $this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode); $this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode); }
function testCreate_respectsVerifyCardAndVerificationMerchantAccountIdWhenIncludedOutsideOfTheNonce() { $nonce = Braintree_HttpClientApi::nonce_for_new_card(array('credit_card' => array('number' => '4000111111111115', 'expirationMonth' => '11', 'expirationYear' => '2099'))); $customer = Braintree_Customer::createNoValidate(); $result = Braintree_PaymentMethod::create(array('paymentMethodNonce' => $nonce, 'customerId' => $customer->id, 'options' => array('verifyCard' => 'true', 'verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId()))); $this->assertFalse($result->success); $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); }
function testSubmitForRelease_fromEscrowFailsForTransactionsNotHeldInEscrow() { $result = Braintree_Transaction::sale(array('merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), 'amount' => '100.00', 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12'))); $result = Braintree_Transaction::releaseFromEscrow($result->transaction->id); $this->assertFalse($result->success); $errors = $result->errors->forKey('transaction')->onAttribute('base'); $this->assertEquals(Braintree_Error_Codes::TRANSACTION_CANNOT_RELEASE_FROM_ESCROW, $errors[0]->code); }
function testCredit_withMerchantAccountId() { $result = Braintree_Transaction::credit(array('amount' => '100.00', 'merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12'))); $this->assertTrue($result->success); $transaction = $result->transaction; $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $transaction->merchantAccountId); }