/** * updates the address record * * if calling this method in context, * customerOrId is the 2nd attribute, addressId 3rd. * customerOrId & addressId are not sent in object context. * * * @access public * @param array $attributes * @param mixed $customerOrId (only used in call) * @param string $addressId (only used in call) * @return object Result\Successful or Result\Error */ public function update($customerOrId, $addressId, $attributes) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); Util::verifyKeys(self::updateSignature(), $attributes); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->put($path, array('address' => $attributes)); return $this->_verifyGatewayResponse($response); }
public function testSearch_daysPastDue() { $creditCard = SubscriptionHelper::createCreditCard(); $triallessPlan = SubscriptionHelper::triallessPlan(); $subscription = Braintree\Subscription::create(['paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id']])->subscription; $http = new Braintree\Http(Braintree\Configuration::$global); $path = Braintree\Configuration::$global->merchantPath() . '/subscriptions/' . $subscription->id . '/make_past_due'; $http->put($path, ['daysPastDue' => 5]); $found = false; $collection = Braintree\Subscription::search([Braintree\SubscriptionSearch::daysPastDue()->between(2, 10)]); foreach ($collection as $item) { $found = true; $this->assertTrue($item->daysPastDue <= 10); $this->assertTrue($item->daysPastDue >= 2); } $this->assertTrue($found); }
public function testRetryCharge_WithAmount() { $subscription = SubscriptionHelper::createSubscription(); $http = new Braintree\Http(Braintree\Configuration::$global); $path = Braintree\Configuration::$global->merchantPath() . '/subscriptions/' . $subscription->id . '/make_past_due'; $http->put($path); $result = Braintree\Subscription::retryCharge($subscription->id, 1000); $this->assertTrue($result->success); $transaction = $result->transaction; $this->assertEquals(1000, $transaction->amount); $this->assertNotNull($transaction->processorAuthorizationCode); $this->assertEquals(Braintree\Transaction::SALE, $transaction->type); $this->assertEquals(Braintree\Transaction::AUTHORIZED, $transaction->status); }
public static function escrow($transactionId) { $http = new Braintree\Http(Braintree\Configuration::$global); $path = Braintree\Configuration::$global->merchantPath() . '/transactions/' . $transactionId . '/escrow'; $http->put($path); }
public function test_rangeNode_settledAt() { $transaction = Braintree\Transaction::saleNoValidate(['amount' => '1000.00', 'creditCard' => ['number' => '4111111111111111', 'expirationDate' => '05/12'], 'options' => ['submitForSettlement' => true]]); $http = new Braintree\Http(Braintree\Configuration::$global); $path = Braintree\Configuration::$global->merchantPath() . '/transactions/' . $transaction->id . '/settle'; $http->put($path); $transaction = Braintree\Transaction::find($transaction->id); $twenty_min_ago = date_create("now -20 minutes", new DateTimeZone("UTC")); $ten_min_ago = date_create("now -10 minutes", new DateTimeZone("UTC")); $ten_min_from_now = date_create("now +10 minutes", new DateTimeZone("UTC")); $collection = Braintree\Transaction::search([Braintree\TransactionSearch::id()->is($transaction->id), Braintree\TransactionSearch::settledAt()->between($twenty_min_ago, $ten_min_ago)]); $this->assertEquals(0, $collection->maximumCount()); $collection = Braintree\Transaction::search([Braintree\TransactionSearch::id()->is($transaction->id), Braintree\TransactionSearch::settledAt()->between($ten_min_ago, $ten_min_from_now)]); $this->assertEquals(1, $collection->maximumCount()); $this->assertEquals($transaction->id, $collection->firstItem()->id); }