當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。