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


PHP Braintree_Customer类代码示例

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


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

示例1: getCustomerCards

 /**
  * Returns customer credit cards if applicable
  * 
  * @return Braintree_Customer | boolean
  */
 public function getCustomerCards()
 {
     $session = Mage::getSingleton('adminhtml/session_quote');
     $applicableCards = array();
     if (Mage::getStoreConfig(self::CONFIG_PATH_VAULT, $session->getStoreId())) {
         $storedCards = false;
         if ($session->getCustomerId()) {
             $customerId = Mage::helper('braintree_payments')->generateCustomerId($session->getCustomerId(), $session->getQuote()->getCustomerEmail());
             try {
                 $storedCards = Braintree_Customer::find($customerId)->creditCards;
             } catch (Braintree_Exception $e) {
                 Mage::logException($e);
             }
         }
         if ($storedCards) {
             $country = $session->getQuote()->getBillingAddress()->getCountryId();
             $types = Mage::getModel('braintree_payments/creditcard')->getApplicableCardTypes($country);
             $applicableCards = array();
             foreach ($storedCards as $card) {
                 if (in_array(Mage::helper('braintree_payments')->getCcTypeCodeByName($card->cardType), $types)) {
                     $applicableCards[] = $card;
                 }
             }
         }
     }
     return $applicableCards;
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:32,代码来源:Createorder.php

示例2: braintree

 function braintree($data)
 {
     foreach ($data as $k => $v) {
         ${$k} = $v;
     }
     try {
         include_once 'config.braintree.php';
         $customer = Braintree_Customer::create(['firstName' => $first_name, 'lastName' => $last_name]);
         if (!isset($nonce) || empty($nonce)) {
             throw new Exception("An unknown error has occurred");
         }
         if ($customer->success) {
             $transaction = Braintree_Transaction::sale(['amount' => $price, 'customerId' => $customer->customer->id, 'paymentMethodNonce' => $nonce]);
             if ($transaction->success) {
                 $this->save($data, __FUNCTION__, $transaction->transaction, 1);
                 return json_encode(["status" => true, "msg" => sprintf("Your payment has been %s", $transaction->transaction->status)]);
             } else {
                 throw new Exception($transaction->message);
             }
         }
     } catch (Exception $e) {
         $this->save($data, __FUNCTION__, (string) $e, 0);
         return json_encode(["status" => false, "msg" => $e->getMessage()]);
     }
 }
开发者ID:aliuadepoju,项目名称:hqpay,代码行数:25,代码来源:Gateway.php

示例3: _createCustomer

 private function _createCustomer($CustomerData)
 {
     $name = explode(' ', $CustomerData['Order']['customer_name']);
     $firstName = $name[0];
     $lastName = $name[1];
     $customerDetails = Braintree_Customer::create(['firstName' => $firstName, 'lastName' => $lastName]);
     return $customerDetails->customer->id;
 }
开发者ID:coder-d,项目名称:payment_library,代码行数:8,代码来源:Braintree.php

示例4: init

 /**
  * create signatures for different call types
  * @ignore
  */
 public static function init()
 {
     self::$_createCustomerSignature = array(self::$_transparentRedirectKeys, array('customer' => Braintree_Customer::createSignature()));
     self::$_updateCustomerSignature = array(self::$_transparentRedirectKeys, 'customerId', array('customer' => Braintree_Customer::updateSignature()));
     self::$_transactionSignature = array(self::$_transparentRedirectKeys, array('transaction' => Braintree_Transaction::createSignature()));
     self::$_createCreditCardSignature = array(self::$_transparentRedirectKeys, array('creditCard' => Braintree_CreditCard::createSignature()));
     self::$_updateCreditCardSignature = array(self::$_transparentRedirectKeys, 'paymentMethodToken', array('creditCard' => Braintree_CreditCard::updateSignature()));
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:12,代码来源:TransparentRedirect.php

示例5: getCustomerById

 /**
  * @param $id
  *
  * @return object
  */
 public function getCustomerById($id)
 {
     try {
         $customer = \Braintree_Customer::find($id);
     } catch (\Braintree_Exception_NotFound $e) {
         return false;
     }
     return $customer;
 }
开发者ID:yii-ext,项目名称:payment,代码行数:14,代码来源:BraintreeRecurringGateway.php

示例6: testUpdateSignature_doesNotAlterOptionsInCreditCardUpdateSignature

 function testUpdateSignature_doesNotAlterOptionsInCreditCardUpdateSignature()
 {
     Braintree_Customer::updateSignature();
     foreach (Braintree_CreditCard::updateSignature() as $key => $value) {
         if (is_array($value) and array_key_exists('options', $value)) {
             $this->assertEquals(array('makeDefault', 'verificationMerchantAccountId', 'verifyCard'), $value['options']);
         }
     }
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:9,代码来源:CustomerTest.php

示例7: saveCustomer

 public function saveCustomer()
 {
     $result = Braintree_Customer::create($this->options['customer']);
     if ($result->success) {
         return array('status' => true, 'result' => $result);
     } else {
         return array('status' => false, 'result' => $result);
     }
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:9,代码来源:BraintreeApi.php

示例8: testValueForHtmlField

 function testValueForHtmlField()
 {
     $result = Braintree_Customer::create(array('email' => 'invalid-email', 'creditCard' => array('number' => 'invalid-number', 'expirationDate' => 'invalid-exp', 'billingAddress' => array('countryName' => 'invalid-country'))));
     $this->assertEquals(false, $result->success);
     $this->assertEquals('invalid-email', $result->valueForHtmlField('customer[email]'));
     $this->assertEquals('', $result->valueForHtmlField('customer[credit_card][number]'));
     $this->assertEquals('invalid-exp', $result->valueForHtmlField('customer[credit_card][expiration_date]'));
     $this->assertEquals('invalid-country', $result->valueForHtmlField('customer[credit_card][billing_address][country_name]'));
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:9,代码来源:ErrorTest.php

示例9: testCreate_fromPaymentMethodToken

 function testCreate_fromPaymentMethodToken()
 {
     $customer = Braintree_Customer::createNoValidate();
     $card = Braintree_CreditCard::create(array('customerId' => $customer->id, 'cardholderName' => 'Cardholder', 'number' => '5105105105105100', 'expirationDate' => '05/12'))->creditCard;
     $result = Braintree_PaymentMethodNonce::create($card->token);
     $this->assertTrue($result->success);
     $this->assertNotNull($result->paymentMethodNonce);
     $this->assertNotNull($result->paymentMethodNonce->nonce);
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:9,代码来源:PaymentMethodNonceTest.php

示例10: testTokenPayment

 /**
  * @depends testCustomerCreate
  */
 public function testTokenPayment()
 {
     $customer = \Braintree_Customer::find(self::$customer->id);
     $this->assertInstanceOf('\\Braintree_Customer', $customer);
     $this->assertArrayHasKey(0, $customer->paymentMethods());
     $model = new BraintreeForm();
     $model->setScenario('saleFromVault');
     $this->assertTrue($model->load(['amount' => rand(1, 200), 'paymentMethodToken' => $customer->paymentMethods()[0]->token], ''));
     $this->assertNotFalse($model->send());
 }
开发者ID:skamnev,项目名称:members,代码行数:13,代码来源:BraintreeFormTest.php

示例11: test_deepAll_givesAllErrorsDeeply

 function test_deepAll_givesAllErrorsDeeply()
 {
     $result = Braintree_Customer::create(array('email' => 'invalid', 'creditCard' => array('number' => '1234123412341234', 'expirationDate' => 'invalid', 'billingAddress' => array('countryName' => 'invalid'))));
     $expectedErrors = array(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, Braintree_Error_Codes::CREDIT_CARD_NUMBER_IS_INVALID, Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED);
     $actualErrors = $result->errors->deepAll();
     $this->assertEquals($expectedErrors, self::mapValidationErrorsToCodes($actualErrors));
     $expectedErrors = array(Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, Braintree_Error_Codes::CREDIT_CARD_NUMBER_IS_INVALID, Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED);
     $actualErrors = $result->errors->forKey('customer')->forKey('creditCard')->deepAll();
     $this->assertEquals($expectedErrors, self::mapValidationErrorsToCodes($actualErrors));
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:10,代码来源:ValidationErrorCollectionTest.php

示例12: saveCustomer

 /**
  * This save customer to braintree and returns result array
  * @return array
  */
 public function saveCustomer()
 {
     if (isset($this->options['customerId'])) {
         $this->options['customer']['id'] = $this->options['customerId'];
     }
     $result = \Braintree_Customer::create($this->options['customer']);
     if ($result->success) {
         return ['status' => true, 'result' => $result];
     } else {
         return ['status' => false, 'result' => $result];
     }
 }
开发者ID:skamnev,项目名称:members,代码行数:16,代码来源:Braintree.php

示例13: test_multipleValueNode_creditCardType

 function test_multipleValueNode_creditCardType()
 {
     $result = Braintree_Customer::create(array('creditCard' => array('cardholderName' => "Joe Smith", 'number' => "4000111111111115", 'expirationDate' => "12/2016", 'options' => array('verifyCard' => true))));
     $creditCardVerification = $result->creditCardVerification;
     $collection = Braintree_CreditCardVerification::search(array(Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), Braintree_CreditCardVerificationSearch::creditCardCardType()->is($creditCardVerification->creditCard['cardType'])));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
     $collection = Braintree_CreditCardVerification::search(array(Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), Braintree_CreditCardVerificationSearch::creditCardCardType()->in(array($creditCardVerification->creditCard['cardType'], Braintree_CreditCard::CHINA_UNION_PAY))));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
     $collection = Braintree_CreditCardVerification::search(array(Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), Braintree_CreditCardVerificationSearch::creditCardCardType()->is(Braintree_CreditCard::CHINA_UNION_PAY)));
     $this->assertEquals(0, $collection->maximumCount());
 }
开发者ID:Flesh192,项目名称:magento,代码行数:13,代码来源:CreditCardVerificationAdvancedSearchTest.php

示例14: create_customer_with_card

 function create_customer_with_card($card_info)
 {
     $names = explode(' ', $card_info['cardholderName']);
     $data['firstName'] = isset($names[0]) ? $names[0] : NULL;
     $data['lastName'] = isset($names[1]) ? $names[1] : NULL;
     $data['creditCard'] = $card_info;
     //var_dump($data);
     $result = Braintree_Customer::create($data);
     if ($result->success === true) {
         return array('cust_id' => $result->customer->id, 'card_token' => $result->customer->creditCards[0]->token);
     }
     $this->_parse_errors($result);
     return false;
 }
开发者ID:sahartak,项目名称:storage,代码行数:14,代码来源:Braintree_lib.php

示例15: test_createdAt

 function test_createdAt()
 {
     $customer = Braintree_Customer::createNoValidate();
     $past = clone $customer->createdAt;
     $past->modify("-1 hour");
     $future = clone $customer->createdAt;
     $future->modify("+1 hour");
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::createdAt()->between($past, $future)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::createdAt()->lessThanOrEqualTo($future)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::createdAt()->greaterThanOrEqualTo($past)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
 }
开发者ID:robelkin,项目名称:braintree_php,代码行数:17,代码来源:CustomerAdvancedSearchTest.php


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