상속: extends Artovenry\Helper
예제 #1
0
 public function testAll_withNoPlans_returnsEmptyArray()
 {
     Helper::testMerchantConfig();
     $plans = Braintree\Plan::all();
     $this->assertEquals($plans, array());
     self::integrationMerchantConfig();
 }
 public function testCreateWithDeprecatedParameters()
 {
     Test\Helper::suppressDeprecationWarnings();
     $result = Braintree\MerchantAccount::create(self::$deprecatedValidParams);
     $this->assertEquals(true, $result->success);
     $merchantAccount = $result->merchantAccount;
     $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status);
     $this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id);
 }
 public function testGenerate_canBeGroupedByACustomField()
 {
     $transaction = Braintree\Transaction::saleNoValidate(['amount' => '100.00', 'creditCard' => ['number' => '5105105105105100', 'expirationDate' => '05/12'], 'customFields' => ['store_me' => 'custom value'], 'options' => ['submitForSettlement' => true]]);
     Braintree\Test\Transaction::settle($transaction->id);
     $today = new Datetime();
     $result = Braintree\SettlementBatchSummary::generate(Test\Helper::nowInEastern(), 'store_me');
     $this->assertTrue($result->success);
     $this->assertTrue(count($result->settlementBatchSummary->records) > 0);
     $this->assertArrayHasKey('store_me', $result->settlementBatchSummary->records[0]);
 }
 public function testIn_multipleValues()
 {
     $creditCard = SubscriptionHelper::createCreditCard();
     $triallessPlan = SubscriptionHelper::triallessPlan();
     $activeSubscription = Braintree\Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '4'))->subscription;
     $canceledSubscription = Braintree\Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '4'))->subscription;
     Braintree\Subscription::cancel($canceledSubscription->id);
     $collection = Braintree\Subscription::search(array(Braintree\SubscriptionSearch::status()->in(array(Braintree\Subscription::ACTIVE, Braintree\Subscription::CANCELED)), Braintree\SubscriptionSearch::price()->is('4')));
     $this->assertTrue(Test\Helper::includes($collection, $activeSubscription));
     $this->assertTrue(Test\Helper::includes($collection, $canceledSubscription));
 }
 public function testFind_exposesThreeDSecureInfo()
 {
     $creditCard = ['creditCard' => ['number' => '4111111111111111', 'expirationMonth' => '12', 'expirationYear' => '2020']];
     $nonce = Helper::generate3DSNonce($creditCard);
     $foundNonce = Braintree\PaymentMethodNonce::find($nonce);
     $info = $foundNonce->threeDSecureInfo;
     $this->assertEquals($nonce, $foundNonce->nonce);
     $this->assertEquals('CreditCard', $foundNonce->type);
     $this->assertEquals('Y', $info->enrolled);
     $this->assertEquals('authenticate_successful', $info->status);
     $this->assertTrue($info->liabilityShifted);
     $this->assertTrue($info->liabilityShiftPossible);
 }
예제 #6
0
 public function testSale_createsASaleUsingGivenToken()
 {
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = Test\Helper::generateValidUsBankAccountNonce();
     $result = Braintree\PaymentMethod::create(['customerId' => $customer->id, 'paymentMethodNonce' => $nonce]);
     $result = Braintree\UsBankAccount::sale($result->paymentMethod->token, ['merchantAccountId' => 'us_bank_merchant_account', 'amount' => '100.00']);
     $this->assertTrue($result->success);
     $transaction = $result->transaction;
     $this->assertEquals(Braintree\Transaction::SETTLEMENT_PENDING, $transaction->status);
     $this->assertEquals(Braintree\Transaction::SALE, $transaction->type);
     $this->assertEquals('100.00', $transaction->amount);
     $this->assertEquals('021000021', $transaction->usBankAccount->routingNumber);
     $this->assertEquals('1234', $transaction->usBankAccount->last4);
     $this->assertEquals('checking', $transaction->usBankAccount->accountType);
     $this->assertEquals('PayPal Checking - 1234', $transaction->usBankAccount->accountDescription);
     $this->assertEquals('Dan Schulman', $transaction->usBankAccount->accountHolderName);
     $this->assertRegExp('/CHASE/', $transaction->usBankAccount->bankName);
 }
 public function testCreate_respectsVerifyCardAndVerificationMerchantAccountIdWhenIncludedOutsideOfTheNonce()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(['credit_card' => ['number' => '4000111111111115', 'expirationMonth' => '11', 'expirationYear' => '2099']]);
     $customer = Braintree\Customer::createNoValidate();
     $result = Braintree\PaymentMethod::create(['paymentMethodNonce' => $nonce, 'customerId' => $customer->id, 'options' => ['verifyCard' => 'true', 'verificationMerchantAccountId' => Test\Helper::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(Test\Helper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId);
 }
예제 #8
0
 public function testFind_returnsUsBankAccount()
 {
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $result = Braintree\PaymentMethod::create(['customerId' => $customer->id, 'paymentMethodNonce' => Test\Helper::generateValidUsBankAccountNonce()]);
     $foundUsBankAccount = Braintree\PaymentMethod::find($result->paymentMethod->token);
     $this->assertInstanceOf('Braintree\\UsBankAccount', $foundUsBankAccount);
     $this->assertEquals('123456789', $foundUsBankAccount->routingNumber);
     $this->assertEquals('1234', $foundUsBankAccount->last4);
     $this->assertEquals('checking', $foundUsBankAccount->accountType);
     $this->assertEquals('PayPal Checking - 1234', $foundUsBankAccount->accountDescription);
     $this->assertEquals('Dan Schulman', $foundUsBankAccount->accountHolderName);
     $this->assertEquals('UNKNOWN', $foundUsBankAccount->bankName);
 }
예제 #9
0
 public function testCreate_canSetTheMerchantAccountId()
 {
     $creditCard = SubscriptionHelper::createCreditCard();
     $plan = SubscriptionHelper::triallessPlan();
     $result = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $plan['id'], 'merchantAccountId' => Test\Helper::nonDefaultMerchantAccountId()]);
     $this->assertTrue($result->success);
     $subscription = $result->subscription;
     $this->assertEquals(Test\Helper::nonDefaultMerchantAccountId(), $subscription->merchantAccountId);
 }
 public function testUpdateCreditCardFromTransparentRedirect()
 {
     $customer = Braintree\Customer::create(array('firstName' => 'Mike', 'lastName' => 'Jonez'))->customer;
     $creditCard = Braintree\CreditCard::create(array('customerId' => $customer->id, 'number' => Braintree\Test\CreditCardNumbers::$masterCard, 'expirationMonth' => '10', 'expirationYear' => '10'))->creditCard;
     $params = array('credit_card' => array('number' => Braintree\Test\CreditCardNumbers::$visa));
     $trParams = array('paymentMethodToken' => $creditCard->token, 'creditCard' => array('expirationMonth' => '11', 'expirationYear' => '11'));
     $trData = Braintree\TransparentRedirect::updateCreditCardData(array_merge($trParams, array("redirectUrl" => "http://www.example.com")));
     $queryString = Test\Helper::submitTrRequest(Braintree\TransparentRedirect::url(), $params, $trData);
     Braintree\TransparentRedirect::confirm($queryString);
     $creditCard = Braintree\CreditCard::find($creditCard->token);
     $this->assertequals('401288', $creditCard->bin);
     $this->assertequals('1881', $creditCard->last4);
     $this->assertequals('11/2011', $creditCard->expirationDate);
 }
예제 #11
0
 public function nonceForPayPalAccount($options)
 {
     $clientToken = json_decode(Test\Helper::decodedClientToken());
     $options["authorization_fingerprint"] = $clientToken->authorizationFingerprint;
     $response = $this->post('/client_api/v1/payment_methods/paypal_accounts.json', json_encode($options));
     if ($response["status"] == 201 || $response["status"] == 202) {
         $body = json_decode($response["body"], true);
         return $body["paypalAccounts"][0]["nonce"];
     } else {
         throw new Exception(var_dump($response));
     }
 }
예제 #12
0
 public function updateCustomerViaTr($regularParams, $trParams)
 {
     Test\Helper::suppressDeprecationWarnings();
     $trData = Braintree\TransparentRedirect::updateCustomerData(array_merge($trParams, ["redirectUrl" => "http://www.example.com"]));
     return Test\Helper::submitTrRequest(Braintree\Customer::updateCustomerUrl(), $regularParams, $trData);
 }
예제 #13
0
 public static function generateValidUsBankAccountNonce()
 {
     $client_token = json_decode(Helper::decodedClientToken(), true);
     $url = $client_token['braintree_api']['url'] . '/tokens';
     $token = $client_token['braintree_api']['access_token'];
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($curl, CURLOPT_URL, $url);
     $headers[] = 'Content-Type: application/json';
     $headers[] = 'Braintree-Version: 2015-11-01';
     $headers[] = 'Authorization: Bearer ' . $token;
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     $requestBody = ['type' => 'us_bank_account', 'billing_address' => ['street_address' => '123 Ave', 'region' => 'CA', 'locality' => 'San Francisco', 'postal_code' => '94112'], 'account_type' => 'checking', 'routing_number' => '123456789', 'account_number' => '567891234', 'account_holder_name' => 'Dan Schulman', 'account_description' => 'PayPal Checking - 1234', 'ach_mandate' => ['text' => '']];
     curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($requestBody));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec($curl);
     $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     $error_code = curl_errno($curl);
     curl_close($curl);
     $jsonResponse = json_decode($response, true);
     return $jsonResponse['data']['id'];
 }
예제 #14
0
 public function test_ClientTokenAcceptsMerchantAccountId()
 {
     $clientToken = Test\Helper::decodedClientToken(array('merchantAccountId' => 'my_merchant_account'));
     $merchantAccountId = json_decode($clientToken)->merchantAccountId;
     $this->assertEquals('my_merchant_account', $merchantAccountId);
 }
예제 #15
0
 public function testSubmitForSettlement_withAmexRewardsSucceedsEvenIfCardBalanceIsInsufficient()
 {
     $result = Braintree\Transaction::sale(['amount' => '47.00', 'merchantAccountId' => Test\Helper::fakeAmexDirectMerchantAccountId(), 'creditCard' => ['cardholderName' => 'The Cardholder', 'number' => Braintree\Test\CreditCardNumbers::$amexPayWithPoints['InsufficientPoints'], 'expirationDate' => '05/12'], 'options' => ['amexRewards' => ['requestId' => 'ABC123', 'points' => '100', 'currencyAmount' => '1.00', 'currencyIsoCode' => 'USD']]]);
     $this->assertTrue($result->success);
     $transaction = $result->transaction;
     $this->assertEquals(Braintree\Transaction::AUTHORIZED, $transaction->status);
     $this->assertEquals(Braintree\Transaction::SALE, $transaction->type);
     $submitResult = Braintree\Transaction::submitForSettlement($transaction->id, '47.00');
     $submitTransaction = $submitResult->transaction;
     $this->assertEquals(Braintree\Transaction::SUBMITTED_FOR_SETTLEMENT, $submitTransaction->status);
 }
예제 #16
0
 public function updateCreditCardViaTr($regularParams, $trParams)
 {
     $trData = Braintree\TransparentRedirect::updateCreditCardData(array_merge($trParams, array("redirectUrl" => "http://www.example.com")));
     return Test\Helper::submitTrRequest(Braintree\CreditCard::updateCreditCardUrl(), $regularParams, $trData);
 }
 public function testSearch_transactionId()
 {
     $creditCard = SubscriptionHelper::createCreditCard();
     $triallessPlan = SubscriptionHelper::triallessPlan();
     $matchingSubscription = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id']])->subscription;
     $nonMatchingSubscription = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id']])->subscription;
     $collection = Braintree\Subscription::search([Braintree\SubscriptionSearch::transactionId()->is($matchingSubscription->transactions[0]->id)]);
     $this->assertTrue(Test\Helper::includes($collection, $matchingSubscription));
     $this->assertFalse(Test\Helper::includes($collection, $nonMatchingSubscription));
 }
예제 #18
-1
 public function testContains()
 {
     $creditCard = SubscriptionHelper::createCreditCard();
     $triallessPlan = SubscriptionHelper::triallessPlan();
     $trialPlan = SubscriptionHelper::trialPlan();
     $trialSubscription = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $trialPlan['id'], 'price' => '9'])->subscription;
     $triallessSubscription = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '9'])->subscription;
     $collection = Braintree\Subscription::search([Braintree\SubscriptionSearch::planId()->contains("ration_trial_pl"), Braintree\SubscriptionSearch::price()->is("9")]);
     $this->assertTrue(Test\Helper::includes($collection, $trialSubscription));
     $this->assertFalse(Test\Helper::includes($collection, $triallessSubscription));
 }