Ejemplo n.º 1
0
 /**
  * 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 Braintree_Result_Successful or Braintree_Result_Error
  */
 public function update($customerOrId, $addressId, $attributes)
 {
     $this->_validateId($addressId);
     $customerId = $this->_determineCustomerId($customerOrId);
     Braintree_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);
 }
 function testSearch_daysPastDue()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
     $subscription = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id']))->subscription;
     Braintree_Http::put('/subscriptions/' . $subscription->id . '/make_past_due', array('daysPastDue' => 5));
     $found = false;
     $collection = Braintree_Subscription::search(array(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);
 }
Ejemplo n.º 3
0
 public static function cancelRelease($transactionId)
 {
     self::_validateId($transactionId);
     $response = Braintree_Http::put('/transactions/' . $transactionId . '/cancel_release', array());
     return self::_verifyGatewayResponse($response);
 }
Ejemplo n.º 4
0
 public static function escrow($transactionId)
 {
     $http = new Braintree_Http(Braintree_Configuration::$global);
     $path = Braintree_Configuration::$global->merchantPath() . '/transactions/' . $transactionId . '/escrow';
     $http->put($path);
 }
Ejemplo n.º 5
0
 public static function escrow($transactionId)
 {
     Braintree_Http::put('/transactions/' . $transactionId . '/escrow');
 }
 function test_rangeNode_settledAt()
 {
     $transaction = Braintree_Transaction::saleNoValidate(array('amount' => '1000.00', 'creditCard' => array('number' => '4111111111111111', 'expirationDate' => '05/12'), 'options' => array('submitForSettlement' => true)));
     Braintree_Http::put('/transactions/' . $transaction->id . '/settle');
     $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(array(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(array(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);
 }
Ejemplo n.º 7
0
 function testRetryCharge_WithAmount()
 {
     $subscription = Braintree_SubscriptionTestHelper::createSubscription();
     Braintree_Http::put('/subscriptions/' . $subscription->id . '/make_past_due');
     $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);
 }
 private static function _doUpdate($url, $params)
 {
     $response = Braintree_Http::put($url, $params);
     return self::_verifyGatewayResponse($response);
 }
Ejemplo n.º 9
0
 /**
  * updates the address record
  *
  * if calling this method in static 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 static call)
  * @param string $addressId (only used in static call)
  * @return object Braintree_Result_Successful or Braintree_Result_Error
  */
 public static function update($customerOrId, $addressId, $attributes)
 {
     self::_validateId($addressId);
     $customerId = self::_determineCustomerId($customerOrId);
     Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
     $response = Braintree_Http::put('/customers/' . $customerId . '/addresses/' . $addressId, array('address' => $attributes));
     return self::_verifyGatewayResponse($response);
 }
Ejemplo n.º 10
0
 public static function settle($transactionId)
 {
     Braintree_Http::put('/transactions/' . $transactionId . '/settle');
 }
Ejemplo n.º 11
0
 public static function cancel($subscriptionId)
 {
     $response = Braintree_Http::put('/subscriptions/' . $subscriptionId . '/cancel');
     return self::_verifyGatewayResponse($response);
 }
Ejemplo n.º 12
0
 public static function submitForSettlement($transactionId, $amount = null)
 {
     self::_validateId($transactionId);
     $response = Braintree_Http::put('/transactions/' . $transactionId . '/submit_for_settlement', array('transaction' => array('amount' => $amount)));
     return self::_verifyGatewayResponse($response);
 }
Ejemplo n.º 13
0
 function testRetryCharge_WithAmount()
 {
     $subscription = Braintree_SubscriptionTestHelper::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);
 }