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


PHP Braintree_Subscription类代码示例

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


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

示例1: _initialize

 protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     if (isset($attributes['subject']['apiErrorResponse'])) {
         $wrapperNode = $attributes['subject']['apiErrorResponse'];
     } else {
         $wrapperNode = $attributes['subject'];
     }
     if (isset($wrapperNode['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
     }
     if (isset($wrapperNode['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount']));
     }
     if (isset($wrapperNode['transaction'])) {
         $this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction']));
     }
     if (isset($wrapperNode['disbursement'])) {
         $this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement']));
     }
     if (isset($wrapperNode['partnerMerchant'])) {
         $this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant']));
     }
     if (isset($wrapperNode['errors'])) {
         $this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors']));
         $this->_set('message', $wrapperNode['message']);
     }
 }
开发者ID:bobstermyang,项目名称:communityfoodshare,代码行数:28,代码来源:WebhookNotification.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: _initialize

 protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     if (isset($attributes['subject']) && isset($attributes['subject']['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
     }
 }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:7,代码来源:WebhookNotification.php

示例4: 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

示例5: __construct

 /**
  * overrides default constructor
  * @ignore
  * @param array $response gateway response array
  */
 public function __construct($response)
 {
     $this->_attributes = $response;
     $this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
     if (isset($response['verification'])) {
         $this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
     } else {
         $this->_set('creditCardVerification', null);
     }
     if (isset($response['transaction'])) {
         $this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
     } else {
         $this->_set('transaction', null);
     }
     if (isset($response['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($response['subscription']));
     } else {
         $this->_set('subscription', null);
     }
     if (isset($response['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount']));
     } else {
         $this->_set('merchantAccount', null);
     }
 }
开发者ID:Flesh192,项目名称:magento,代码行数:30,代码来源:Error.php

示例6: 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

示例7: 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

示例8: _initialize

 /**
  * sets instance properties from an array of values
  *
  * @access protected
  * @param array $paypalAccountAttribs array of paypalAccount data
  * @return none
  */
 protected function _initialize($paypalAccountAttribs)
 {
     // set the attributes
     $this->_attributes = $paypalAccountAttribs;
     $subscriptionArray = array();
     if (isset($paypalAccountAttribs['subscriptions'])) {
         foreach ($paypalAccountAttribs['subscriptions'] as $subscription) {
             $subscriptionArray[] = Braintree_Subscription::factory($subscription);
         }
     }
     $this->_set('subscriptions', $subscriptionArray);
 }
开发者ID:Flesh192,项目名称:magento,代码行数:19,代码来源:PayPalAccount.php

示例9: _initialize

 /**
  * sets instance properties from an array of values
  *
  * @access protected
  * @param array $applePayCardAttribs array of Apple Pay card properties
  * @return none
  */
 protected function _initialize($applePayCardAttribs)
 {
     // set the attributes
     $this->_attributes = $applePayCardAttribs;
     $subscriptionArray = array();
     if (isset($applePayCardAttribs['subscriptions'])) {
         foreach ($applePayCardAttribs['subscriptions'] as $subscription) {
             $subscriptionArray[] = Braintree_Subscription::factory($subscription);
         }
     }
     $this->_set('subscriptions', $subscriptionArray);
     $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
 }
开发者ID:nstungxd,项目名称:F2CA5,代码行数:20,代码来源:ApplePayCard.php

示例10: createSubscription

 public function createSubscription($customer_id, $package_code, $monthly_price)
 {
     try {
         $customer = Braintree_Customer::find($customer_id);
         $payment_method_token = $customer->creditCards[0]->token;
         $result = Braintree_Subscription::create(array('paymentMethodToken' => $payment_method_token, 'planId' => $package_code, 'price' => $monthly_price));
         return $result;
     } catch (Braintree_Exception_NotFound $e) {
         $bexcption = print_r($e, true);
         log_message('error', date('Y-m-d H:i:s') . ' ' . $bexcption, true);
         $result = new stdClass();
         $result->success = false;
         return $result;
     }
 }
开发者ID:agency2016,项目名称:rothy_cloudynote,代码行数:15,代码来源:braintree_ci.php

示例11: sendSubscription

 /**
  * Braintree sale function
  * @param bool|true $submitForSettlement
  * @param bool|true $storeInVaultOnSuccess
  * @return array
  */
 public function sendSubscription()
 {
     //$customer = \Braintree_Customer::find($this->options['customerId']);
     $subscriptionData = array('paymentMethodToken' => $this->options['paymentMethodToken'], 'planId' => $this->options['planId']);
     $result = \Braintree_Subscription::create($subscriptionData);
     if ($result->success) {
         return ['status' => true, 'result' => $result];
     } else {
         if ($result->transaction) {
             return ['status' => false, 'result' => $result];
         } else {
             return ['status' => false, 'result' => $result];
         }
     }
 }
开发者ID:skamnev,项目名称:members,代码行数:21,代码来源:Braintree.php

示例12: testFind_returnsSubscriptionsAssociatedWithAPaypalAccount

 function testFind_returnsSubscriptionsAssociatedWithAPaypalAccount()
 {
     $customer = Braintree_Customer::createNoValidate();
     $paymentMethodToken = 'paypal-account-' . strval(rand());
     $nonce = Braintree_HttpClientApi::nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'consent-code', 'token' => $paymentMethodToken)));
     $result = Braintree_PaymentMethod::create(array('paymentMethodNonce' => $nonce, 'customerId' => $customer->id));
     $this->assertTrue($result->success);
     $token = $result->paymentMethod->token;
     $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
     $subscription1 = Braintree_Subscription::create(array('paymentMethodToken' => $token, 'planId' => $triallessPlan['id']))->subscription;
     $subscription2 = Braintree_Subscription::create(array('paymentMethodToken' => $token, 'planId' => $triallessPlan['id']))->subscription;
     $paypalAccount = Braintree_PayPalAccount::find($token);
     $getIds = function ($sub) {
         return $sub->id;
     };
     $subIds = array_map($getIds, $paypalAccount->subscriptions);
     $this->assertTrue(in_array($subscription1->id, $subIds));
     $this->assertTrue(in_array($subscription2->id, $subIds));
 }
开发者ID:kingsj,项目名称:shopping-cart-lite,代码行数:19,代码来源:PayPalAccountTest.php

示例13: subscribe

 function subscribe($nonce, $info)
 {
     $customerResult;
     $subscriptionResult;
     $customerResult = Braintree_Customer::create(['firstName' => $info['fname'], 'lastName' => $info['lname'], 'email' => $info['email'], 'paymentMethodNonce' => $nonce]);
     if (!$customerResult->success) {
         return $this->processErrors('subscription', $customerResult->errors->deepAll());
     }
     $r = $customerResult->customer;
     $a = $r->addresses[0];
     $sql = 'INSERT INTO users (first_name, last_name, address, city, state, zip, braintree_customer_id, created_date, email) ';
     $sql .= "VALUES ('" . $r->firstName . "','" . $r->lastName . "','" . $a->streetAddress . "','" . $a->locality . "','" . $a->region . "','" . $a->postalCode . "','" . $r->id . "', now(),'" . $r->email . "');";
     $info['userId'] = MysqlAccess::insert($sql);
     $subscriptionResult = Braintree_Subscription::create(['paymentMethodToken' => $customerResult->customer->paymentMethods[0]->token, 'planId' => 'donation', 'price' => $info['amount']]);
     if (!isset($subscriptionResult->subscription) || !$subscriptionResult->subscription) {
         return $this->processErrors('subscription', $subscriptionResult->errors->deepAll());
     }
     return $this->retrieveSubscriptionResults($subscriptionResult->success, $subscriptionResult->subscription, $info);
 }
开发者ID:Slimshavy,项目名称:tiferesrachamim-temp,代码行数:19,代码来源:BraintreeHelper.php

示例14: testRetryCharge_WithAmount

 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);
 }
开发者ID:robelkin,项目名称:braintree_php,代码行数:12,代码来源:SubscriptionTest.php

示例15: testFindReturnsAssociatedSubscriptions

 function testFindReturnsAssociatedSubscriptions()
 {
     $customer = Braintree_Customer::createNoValidate();
     $result = Braintree_CreditCard::create(array('customerId' => $customer->id, 'cardholderName' => 'Cardholder', 'number' => '5105105105105100', 'expirationDate' => '05/12', 'billingAddress' => array('firstName' => 'Drew', 'lastName' => 'Smith', 'company' => 'Smith Co.', 'streetAddress' => '1 E Main St', 'extendedAddress' => 'Suite 101', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622', 'countryName' => 'United States of America')));
     $id = strval(rand());
     Braintree_Subscription::create(array('id' => $id, 'paymentMethodToken' => $result->creditCard->token, 'planId' => 'integration_trialless_plan', 'price' => '1.00'));
     $creditCard = Braintree_CreditCard::find($result->creditCard->token);
     $this->assertEquals($id, $creditCard->subscriptions[0]->id);
     $this->assertEquals('integration_trialless_plan', $creditCard->subscriptions[0]->planId);
     $this->assertEquals('1.00', $creditCard->subscriptions[0]->price);
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:11,代码来源:CreditCardTest.php


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