• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Braintree_Customer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_GatewayRespectsMakeDefault

 function test_GatewayRespectsMakeDefault()
 {
     $result = Braintree_Customer::create();
     $this->assertTrue($result->success);
     $customerId = $result->customer->id;
     $result = Braintree_CreditCard::create(array('customerId' => $customerId, 'number' => '4111111111111111', 'expirationDate' => '11/2099'));
     $this->assertTrue($result->success);
     $clientToken = Braintree_ClientToken::generate(array("customerId" => $customerId, "options" => array("makeDefault" => true)));
     $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
     $response = Braintree_HttpClientApi::post('/client_api/nonces.json', json_encode(array("credit_card" => array("number" => "4242424242424242", "expirationDate" => "11/2099"), "authorization_fingerprint" => $authorizationFingerprint, "shared_customer_identifier" => "fake_identifier", "shared_customer_identifier_type" => "testing")));
     $this->assertEquals(201, $response["status"]);
     $customer = Braintree_Customer::find($customerId);
     $this->assertEquals(2, count($customer->creditCards));
     foreach ($customer->creditCards as $creditCard) {
         if ($creditCard->last4 == "4242") {
             $this->assertTrue($creditCard->default);
         }
     }
 }
开发者ID:riteshkmr33,项目名称:ovessnce,代码行数:19,代码来源:ClientTokenTest.php


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


示例18: check

 public function check($customer)
 {
     if (empty($customer)) {
         $customer = $this->_controller->currUser;
     }
     $firstName = $lastName = '';
     $name = explode(' ', $customer['User']['full_name']);
     if (count($name) > 0) {
         $firstName = array_shift($name);
         $lastName = implode(' ', $name);
     }
     $customerData = array('firstName' => $firstName, 'lastName' => $lastName, 'email' => $customer['User']['username'], 'phone' => $customer['User']['phone']);
     try {
         $_customer = Braintree_Customer::find('konstruktor-' . $customer['User']['id']);
         $_customer = Braintree_Customer::update('konstruktor-' . $customer['User']['id'], $customerData);
     } catch (Exception $e) {
         $_customer = Braintree_Customer::create(Hash::merge(array('id' => 'konstruktor-' . $customer['User']['id']), $customerData));
     }
     if ($_customer->success) {
         return $_customer->customer;
     }
     return array();
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:23,代码来源:BraintreeCustomerComponent.php


示例19: array

<?php

require_once "PATH_TO_BRAINTREE/lib/Braintree.php";
Braintree_Configuration::environment("sandbox");
Braintree_Configuration::merchantId("your_merchant_id");
Braintree_Configuration::publicKey("your_public_key");
Braintree_Configuration::privateKey("your_private_key");
$result = Braintree_Customer::create(array("firstName" => $_POST["first_name"], "lastName" => $_POST["last_name"], "creditCard" => array("number" => $_POST["number"], "expirationMonth" => $_POST["month"], "expirationYear" => $_POST["year"], "cvv" => $_POST["cvv"], "billingAddress" => array("postalCode" => $_POST["postal_code"]))));
if ($result->success) {
    echo "Success! Customer ID: " . $result->customer->id;
} else {
    echo "Validation errors:<br/>";
    foreach ($result->errors->deepAll() as $error) {
        echo "- " . $error->message . "<br/>";
    }
}
开发者ID:Justin-Leung,项目名称:braintree_php_guide,代码行数:16,代码来源:customer.php


示例20: test_rangeNode_amount

 function test_rangeNode_amount()
 {
     $customer = Braintree_Customer::createNoValidate();
     $creditCard = Braintree_CreditCard::create(array('customerId' => $customer->id, 'cardholderName' => 'Jane Everywoman' . rand(), 'number' => '5105105105105100', 'expirationDate' => '05/12'))->creditCard;
     $t_1000 = Braintree_Transaction::saleNoValidate(array('amount' => '1000.00', 'paymentMethodToken' => $creditCard->token));
     $t_1500 = Braintree_Transaction::saleNoValidate(array('amount' => '1500.00', 'paymentMethodToken' => $creditCard->token));
     $t_1800 = Braintree_Transaction::saleNoValidate(array('amount' => '1800.00', 'paymentMethodToken' => $creditCard->token));
     $collection = Braintree_Transaction::search(array(Braintree_TransactionSearch::creditCardCardholderName()->is($creditCard->cardholderName), Braintree_TransactionSearch::amount()->greaterThanOrEqualTo('1700')));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($t_1800->id, $collection->firstItem()->id);
     $collection = Braintree_Transaction::search(array(Braintree_TransactionSearch::creditCardCardholderName()->is($creditCard->cardholderName), Braintree_TransactionSearch::amount()->lessThanOrEqualTo('1250')));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($t_1000->id, $collection->firstItem()->id);
     $collection = Braintree_Transaction::search(array(Braintree_TransactionSearch::creditCardCardholderName()->is($creditCard->cardholderName), Braintree_TransactionSearch::amount()->between('1100', '1600')));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($t_1500->id, $collection->firstItem()->id);
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:17,代码来源:TransactionAdvancedSearchTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Braintree_Http类代码示例发布时间:2022-05-23
下一篇:
PHP Braintree_CreditCard类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap