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


PHP Braintree_Subscription::create方法代码示例

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


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

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

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

示例3: create_subscription

 function create_subscription($card_token, $plan_id, $custom = '')
 {
     $result = Braintree_Subscription::create(array('paymentMethodToken' => $card_token, 'planId' => $plan_id));
     if ($result->success === true) {
         $this->_log_subscription($result->subscription, $custom);
         /*var_dump($result->subscription);
         		die();*/
         return true;
     }
     /*$subscription = $result->subscription;
     		$transaction = $subscription->transactions[0];*/
     $this->_parse_errors($result);
     return false;
 }
开发者ID:aceofspades19,项目名称:CodeIgniter-BrainTree-Wrapper,代码行数:14,代码来源:Braintree_lib.php

示例4: createSubscription

 /**
  * @param $data array
  *
  * @return mixed
  */
 public function createSubscription($data)
 {
     $customer = $this->getCustomer($data);
     if ($customer->success == false) {
     }
     $card = $this->getCard($customer, $data);
     if ($card->success == false) {
     }
     $subscription = \Braintree_Subscription::create(array('paymentMethodToken' => $card->token, 'planId' => $data['planId']));
     if ($subscription->success == false) {
     } else {
         return true;
     }
 }
开发者ID:yii-ext,项目名称:payment,代码行数:19,代码来源:BraintreeRecurringGateway.php

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

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

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

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

示例9: testUpdate_withDescriptor

 function testUpdate_withDescriptor()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $plan = Braintree_SubscriptionTestHelper::triallessPlan();
     $subscription = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $plan['id'], 'descriptor' => array('name' => '123*123456789012345678', 'phone' => '3334445555')))->subscription;
     $result = Braintree_Subscription::update($subscription->id, array('descriptor' => array('name' => '999*9999999', 'phone' => '8887776666')));
     $updatedSubscription = $result->subscription;
     $this->assertEquals('999*9999999', $updatedSubscription->descriptor->name);
     $this->assertEquals('8887776666', $updatedSubscription->descriptor->phone);
 }
开发者ID:robelkin,项目名称:braintree_php,代码行数:10,代码来源:SubscriptionTest.php

示例10: setcookie

<?php

include '../brainTreePhp/lib/Braintree.php';
$nonceFromTheClient = $_POST['payment_method_nonce'];
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('zn8d4c74dbnp5ntw');
Braintree_Configuration::publicKey('ttwrprnsj83thjjz');
Braintree_Configuration::privateKey('a818cb5f3164585f31f4f03066f308c8');
$customer = Braintree_Customer::create(array("firstName" => $_POST["first_name"], "lastName" => $_POST["last_name"], "company" => $_POST["company"], "paymentMethodNonce" => $nonceFromTheClient));
if ($customer->success) {
    $subscription = Braintree_Subscription::create(['paymentMethodToken' => $customer->customer->paymentMethods[0]->token, 'planId' => 'qtzg']);
    //echo $subscription->subscription->id;
    $opts = [CURLOPT_URL => 'https://api.concertian.com/agents/auth/subscription', CURLOPT_HTTPHEADER => ['Authorization: ' . $_COOKIE["apiKey"]], CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => ['subscriptionId' => $subscription->subscription->id], CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE, CURLOPT_CONNECTTIMEOUT => 25, CURLOPT_TIMEOUT => 3600, CURLOPT_HEADER => TRUE, CURLOPT_VERBOSE => TRUE];
    $curl = curl_init();
    curl_setopt_array($curl, $opts);
    curl_exec($curl);
    setcookie('successfull', 3, time() + 86400 * 30, "/");
    header('Location: ../response.html');
} else {
    setcookie('successfull', 4, time() + 86400 * 30, "/");
    header('Location: ../response.html');
}
开发者ID:concertianteam,项目名称:concertian-1.0,代码行数:22,代码来源:transactionCheckout.php

示例11: foreach

<?php

require_once 'environment.php';
$customerID = $_POST['customerID'];
try {
    $customer_id = $customerID;
    $customer = Braintree_Customer::find($customer_id);
    $payment_method_token = $customer->creditCards[0]->token;
    $result = Braintree_Subscription::create(array('paymentMethodToken' => $payment_method_token, 'planId' => 'test_plan_1'));
    if ($result->success) {
        echo "Success! Subscription " . $result->subscription->id . " is " . $result->subscription->status;
    } else {
        echo "Validation errors:<br/>";
        foreach ($result->errors->deepAll() as $error) {
            echo "- " . $error->message . "<br/>";
        }
    }
} catch (Braintree_Exception_NotFound $e) {
    echo "Failure: no customer found with ID " . $_GET["customer_id"];
}
开发者ID:ajlangsdonpp,项目名称:paypal_api_testing,代码行数:20,代码来源:subscription.php

示例12: createBraintreeSubscription

 /**
  * createBraintreeSubscription
  * --------------------------------------------------
  * @param (Plan) ($newPlan) The new plan
  * @return Creates a Braintree Subscription, from this object.
  * --------------------------------------------------
  */
 private function createBraintreeSubscription($newPlan)
 {
     /* Initialize variables */
     $result = ['errors' => FALSE, 'messages' => ''];
     /* The function assumes, that everything is OK to charge the user on Braintree */
     /* Create Braintree subscription */
     $subscriptionResult = Braintree_Subscription::create(['paymentMethodToken' => $this->braintree_payment_method_token, 'planId' => $newPlan->braintree_plan_id]);
     /* Success */
     if ($subscriptionResult->success) {
         Log::info($subscriptionResult);
         /* Change the subscription plan and dates to the new in our DB */
         $this->plan()->associate($newPlan);
         $this->braintree_subscription_id = $subscriptionResult->subscription->id;
         $this->current_period_start = Carbon::now();
         $this->current_period_end = Carbon::now()->addMonth();
         /* Save object */
         $this->save();
         /* Error */
     } else {
         /* Get and store errors */
         foreach ($subscriptionResult->errors->deepAll() as $error) {
             $result['errors'] |= TRUE;
             $result['messages'] .= $error->code . ": " . $error->message . ' ';
         }
     }
     /* Return result */
     return $result;
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:35,代码来源:Subscription.php

示例13: testFind_returnsCreditCardsWithSubscriptions

 function testFind_returnsCreditCardsWithSubscriptions()
 {
     $customer = Braintree_Customer::createNoValidate();
     $creditCardResult = Braintree_CreditCard::create(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/2011'));
     $this->assertTrue($creditCardResult->success);
     $subscriptionId = strval(rand());
     Braintree_Subscription::create(array('id' => $subscriptionId, 'paymentMethodToken' => $creditCardResult->creditCard->token, 'planId' => 'integration_trialless_plan', 'price' => '1.00'));
     $foundCreditCard = Braintree_PaymentMethod::find($creditCardResult->creditCard->token);
     $this->assertEquals($subscriptionId, $foundCreditCard->subscriptions[0]->id);
     $this->assertEquals('integration_trialless_plan', $foundCreditCard->subscriptions[0]->planId);
     $this->assertEquals('1.00', $foundCreditCard->subscriptions[0]->price);
 }
开发者ID:dhaupin,项目名称:braintree-payments,代码行数:12,代码来源:PaymentMethodTest.php

示例14: doPayPlan

 public function doPayPlan($planId)
 {
     if (Input::has('payment_method_nonce')) {
         // get the detials of the plan
         $plans = Braintree_Plan::all();
         $user = Auth::user();
         // find the correct plan to show
         // no way currently to get only one plan
         foreach ($plans as $plan) {
             if ($plan->id == 'fruit_analytics_plan_' . $planId) {
                 $planName = $plan->name;
             }
         }
         // lets see, if the user already has a subscripton
         if ($user->subscriptionId) {
             try {
                 $result = Braintree_Subscription::cancel($user->subscriptionId);
             } catch (Exception $e) {
                 return Redirect::route('auth.plan')->with('error', "Couldn't process subscription, try again later.");
             }
         }
         // create the new subscription
         $result = Braintree_Subscription::create(array('planId' => 'fruit_analytics_plan_' . $planId, 'paymentMethodNonce' => Input::get('payment_method_nonce')));
         if ($result->success) {
             // update user plan to subscrition
             $user->plan = $planId;
             $user->subscriptionId = $result->subscription->id;
             $user->save();
             IntercomHelper::subscribed($user, $planId);
             return Redirect::route('auth.dashboard')->with('success', 'Subscribed to ' . $planName);
         } else {
             return Redirect::route('auth.plan')->with('error', "Couldn't process subscription, try again later.");
         }
     }
 }
开发者ID:raschan,项目名称:fruit-dashboard,代码行数:35,代码来源:AuthController.php

示例15: testSnapshotPlanIdAddOnsAndDiscountsFromSubscription

 function testSnapshotPlanIdAddOnsAndDiscountsFromSubscription()
 {
     $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
     $plan = Braintree_SubscriptionTestHelper::triallessPlan();
     $result = Braintree_Subscription::create(array('paymentMethodToken' => $creditCard->token, 'planId' => $plan['id'], 'addOns' => array('add' => array(array('amount' => '11.00', 'inheritedFromId' => 'increase_10', 'quantity' => 2, 'numberOfBillingCycles' => 5), array('amount' => '21.00', 'inheritedFromId' => 'increase_20', 'quantity' => 3, 'numberOfBillingCycles' => 6))), 'discounts' => array('add' => array(array('amount' => '7.50', 'inheritedFromId' => 'discount_7', 'quantity' => 2, 'neverExpires' => true)))));
     $transaction = $result->subscription->transactions[0];
     $this->assertEquals($transaction->planId, $plan['id']);
     $addOns = $transaction->addOns;
     Braintree_SubscriptionTestHelper::sortModificationsById($addOns);
     $this->assertEquals($addOns[0]->amount, "11.00");
     $this->assertEquals($addOns[0]->id, "increase_10");
     $this->assertEquals($addOns[0]->quantity, 2);
     $this->assertEquals($addOns[0]->numberOfBillingCycles, 5);
     $this->assertFalse($addOns[0]->neverExpires);
     $this->assertEquals($addOns[1]->amount, "21.00");
     $this->assertEquals($addOns[1]->id, "increase_20");
     $this->assertEquals($addOns[1]->quantity, 3);
     $this->assertEquals($addOns[1]->numberOfBillingCycles, 6);
     $this->assertFalse($addOns[1]->neverExpires);
     $discounts = $transaction->discounts;
     $this->assertEquals($discounts[0]->amount, "7.50");
     $this->assertEquals($discounts[0]->id, "discount_7");
     $this->assertEquals($discounts[0]->quantity, 2);
     $this->assertEquals($discounts[0]->numberOfBillingCycles, null);
     $this->assertTrue($discounts[0]->neverExpires);
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:26,代码来源:TransactionTest.php


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