当前位置: 首页>>代码示例>>PHP>>正文


PHP Braintree_Subscription::search方法代码示例

本文整理汇总了PHP中Braintree_Subscription::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Subscription::search方法的具体用法?PHP Braintree_Subscription::search怎么用?PHP Braintree_Subscription::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Braintree_Subscription的用法示例。


在下文中一共展示了Braintree_Subscription::search方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateSubscriptions

 /**
  * updateSubscriptions
  * --------------------------------------------------
  * Updating the BraintreeSubscriptions.
  * @return The stripe plans.
  * @throws BraintreeNotConnected
  * --------------------------------------------------
  */
 public function updateSubscriptions()
 {
     // Updating plans to be up to date.
     $this->updatePlans();
     $subscriptions = array();
     // Clollecting subscriptions.
     try {
         $braintreeSubscriptions = Braintree_Subscription::search(array(Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::ACTIVE))));
     } catch (Exception $e) {
         // Something went wrong.
         return;
     }
     foreach ($braintreeSubscriptions as $subscription) {
         $new_subscription = new BraintreeSubscription(array('start' => $subscription->firstBillingDate, 'status' => $subscription->status));
         $plan = BraintreePlan::where('plan_id', $subscription->planId)->first();
         if ($plan === null) {
             // Braintree integrity error, link to a non-existing plan.
             return array();
         }
         $new_subscription->plan()->associate($plan);
         array_push($subscriptions, $new_subscription);
     }
     // Save new.
     foreach ($subscriptions as $subscription) {
         $subscription->save();
     }
     return $subscriptions;
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:36,代码来源:BraintreeDataCollector.php

示例2: afterFind

 public function afterFind($results, $primary = false)
 {
     if ($primary) {
         $results = Hash::insert($results, "{n}.BraintreeSubscription", array());
         $results = Hash::insert($results, "{n}.BraintreePlan", array());
         $braintreeSubscriptions = Braintree_Subscription::search([Braintree_SubscriptionSearch::ids()->in(Hash::extract($results, "{n}.BillingSubscription.remote_subscription_id"))]);
         $braintreePlans = Braintree_Plan::all();
         foreach ($results as $key => $result) {
             foreach ($braintreeSubscriptions as $braintreeSubscription) {
                 if ($braintreeSubscription->id == $result['BillingSubscription']['remote_subscription_id']) {
                     $result['BraintreeSubscription'] = $braintreeSubscription;
                     break;
                 }
                 //$results = Hash::insert($results, "{n}.BillingSubscription[remote_subscription_id=".$braintreeSubscription->id."]", array('BraintreeSubscription' => $braintreeSubscription));
             }
             foreach ($braintreePlans as $braintreePlan) {
                 if ($braintreePlan->id == $result['BillingSubscription']['remote_plan_id']) {
                     $result['BraintreePlan'] = $braintreePlan;
                     break;
                 }
             }
             $results[$key] = $result;
         }
     }
     return $results;
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:26,代码来源:BillingSubscription.php

示例3: testIn_multipleValues

 function testIn_multipleValues()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $triallessPlan = Braintree_SubscriptionTestHelper::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(Braintree_TestHelper::includes($collection, $activeSubscription));
     $this->assertTrue(Braintree_TestHelper::includes($collection, $canceledSubscription));
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:11,代码来源:MultipleValueNodeTest.php

示例4: testContains

 function testContains()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
     $trialPlan = Braintree_SubscriptionTestHelper::trialPlan();
     $trialSubscription = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $trialPlan['id'], 'price' => '9'))->subscription;
     $triallessSubscription = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '9'))->subscription;
     $collection = Braintree_Subscription::search(array(Braintree_SubscriptionSearch::planId()->contains("ration_trial_pl"), Braintree_SubscriptionSearch::price()->is("9")));
     $this->assertTrue(Braintree_TestHelper::includes($collection, $trialSubscription));
     $this->assertFalse(Braintree_TestHelper::includes($collection, $triallessSubscription));
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:11,代码来源:TextNodeTest.php

示例5: testSearch_price

 function testSearch_price()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
     $subscription_850 = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '8.50'))->subscription;
     $subscription_851 = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '8.51'))->subscription;
     $subscription_852 = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id'], 'price' => '8.52'))->subscription;
     $collection = Braintree_Subscription::search(array(Braintree_SubscriptionSearch::price()->between('8.51', '8.52')));
     $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_851));
     $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_852));
     $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription_850));
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:12,代码来源:SubscriptionSearchTest.php

示例6: testSearch_transactionId

 function testSearch_transactionId()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
     $matchingSubscription = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id']))->subscription;
     $nonMatchingSubscription = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $triallessPlan['id']))->subscription;
     $collection = Braintree_Subscription::search(array(Braintree_SubscriptionSearch::transactionId()->is($matchingSubscription->transactions[0]->id)));
     $this->assertTrue(Braintree_TestHelper::includes($collection, $matchingSubscription));
     $this->assertFalse(Braintree_TestHelper::includes($collection, $nonMatchingSubscription));
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:10,代码来源:SubscriptionSearchTest.php

示例7: getSubscriptions

 /**
  * wrapper for getting subscriptions from braintree
  * @param object - user
  * @param string - id of the subscription (default null)
  *
  * @return object - the searched subscriptions OR null if not found OR collection of subscriptions
  */
 private static function getSubscriptions($user, $subscriptionId = null)
 {
     self::setBraintreeCredentials($user);
     $returnVariable = null;
     if ($subscriptionId) {
         try {
             $returnVariable = Braintree_Subscription::find($subscriptionId);
         } catch (Exception $e) {
             return null;
         }
     } else {
         $returnVariable = Braintree_Subscription::search(array(Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::ACTIVE, Braintree_Subscription::PAST_DUE, Braintree_Subscription::PENDING))));
     }
     return $returnVariable;
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:22,代码来源:BraintreeHelper.php


注:本文中的Braintree_Subscription::search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。