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


PHP Braintree_Customer::create方法代码示例

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


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

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

示例2: payment

 public function payment()
 {
     $this->request->allowMethod('post');
     if (!isset($this->request->data['amount']) || empty($this->request->data['amount'])) {
         $this->redirect($this->referer());
     }
     $firstName = $lastName = '';
     $name = explode(' ', $this->currUser['User']['full_name']);
     if (count($name) > 0) {
         $firstName = array_shift($name);
         $lastName = implode(' ', $name);
     }
     $customerData = array('firstName' => $firstName, 'lastName' => $lastName, 'email' => $this->currUser['User']['username'], 'phone' => $this->currUser['User']['phone']);
     try {
         $customer = Braintree_Customer::find('konstruktor-' . $this->currUser['User']['id']);
         $customer = Braintree_Customer::update('konstruktor-' . $this->currUser['User']['id'], $customerData);
     } catch (Exception $e) {
         $customer = Braintree_Customer::create(Hash::merge(array('id' => 'konstruktor-' . $this->currUser['User']['id']), $customerData));
     }
     if ($customer->success) {
         $customer = $customer->customer;
     } else {
         throw new NotFoundException(__d('billing', 'Invalid billing group'));
     }
     $this->Session->write('Billing', array('amount' => $this->request->data['amount']));
     $this->layout = 'profile_new';
     $clientToken = Braintree_ClientToken::generate();
     $this->set('clientToken', $clientToken);
     $this->set('customer', $customer);
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:30,代码来源:BillingUserController.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: getCustomer

 /**
  * @param $data
  *
  * @return object
  */
 private function getCustomer($data)
 {
     $customer = $this->getCustomerById($data['customerId']);
     if ($customer == false) {
         $customer = \Braintree_Customer::create(array('id' => $data['customerId'], 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone']));
     }
     return $customer;
 }
开发者ID:yii-ext,项目名称:payment,代码行数:13,代码来源:BraintreeRecurringGateway.php

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

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

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

示例8: test_paypalAccountEmail

 function test_paypalAccountEmail()
 {
     $nonce = Braintree_HttpClientApi::nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE')));
     $customerId = 'UNIQUE_CUSTOMER_ID-' . strval(rand());
     $customerResult = Braintree_Customer::create(array('paymentMethodNonce' => $nonce, 'id' => $customerId));
     $this->assertTrue($customerResult->success);
     $customer = $customerResult->customer;
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::paypalAccountEmail()->is('jane.doe@example.com')));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
 }
开发者ID:kingsj,项目名称:shopping-cart-lite,代码行数:11,代码来源:CustomerAdvancedSearchTest.php

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

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

示例11: test_findDuplicateCardsGivenPaymentMethodToken

 function test_findDuplicateCardsGivenPaymentMethodToken()
 {
     $creditCardRequest = array('number' => '63049580000009', 'expirationDate' => '05/2012');
     $jim = Braintree_Customer::create(array('firstName' => 'Jim', 'creditCard' => $creditCardRequest))->customer;
     $joe = Braintree_Customer::create(array('firstName' => 'Joe', 'creditCard' => $creditCardRequest))->customer;
     $query = array(Braintree_CustomerSearch::paymentMethodTokenWithDuplicates()->is($jim->creditCards[0]->token));
     $collection = Braintree_Customer::search($query);
     $customerIds = array();
     foreach ($collection as $customer) {
         $customerIds[] = $customer->id;
     }
     $this->assertTrue(in_array($jim->id, $customerIds));
     $this->assertTrue(in_array($joe->id, $customerIds));
 }
开发者ID:robelkin,项目名称:braintree_php,代码行数:14,代码来源:CustomerAdvancedSearchTest.php

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

示例13: createCustomer

 public function createCustomer($data)
 {
     $result = Braintree_Customer::create($data);
     echo "<pre>";
     print_r($result);
     echo "</pre>";
     if ($result->success) {
         return array('success' => 1, 'customer_id' => $result->customer->id);
     } else {
         $errors = $result->errors->deepAll();
         if (count($errors) > 0 && ($errors[0]->code == 91609 || $errors[0]->message == 'Customer ID has already been taken.')) {
             return array('success' => 1, 'customer_id' => $data['id']);
         }
         return array('success' => 0, 'validation_errors' => $errors);
     }
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:16,代码来源:YiiBraintree.php

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

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


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