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

PHP Braintree_CreditCard类代码示例

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

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



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

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


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


示例3: 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:robelkin,项目名称:braintree_php,代码行数:9,代码来源:CustomerTest.php


示例4: create_card

 function create_card($card_info)
 {
     $result = Braintree_CreditCard::create($card_info);
     if ($result->success === true) {
         # Generated credit card token
         return $result->creditCard->token;
     }
     $this->_parse_errors($result);
     return false;
 }
开发者ID:sahartak,项目名称:storage,代码行数:10,代码来源:Braintree_lib.php


示例5: _createPaymentToken

 private function _createPaymentToken($postFormData, $customerId)
 {
     $ccNumber = $postFormData['Order']['cc_number'];
     $ccHolderName = $postFormData['Order']['cc_holder_name'];
     $expiration = str_split($postFormData['Order']['cc_expiration'], 2);
     $expirationMonth = $expiration[0];
     $expirationYear = $expiration[2];
     $cvv = $postFormData['Order']['cc_cvv'];
     $payment = Braintree_CreditCard::create(['number' => $ccNumber, 'cardholderName' => $ccHolderName, 'expirationMonth' => $expirationMonth, 'expirationYear' => $expirationYear, 'cvv' => $cvv, 'customerId' => $customerId]);
     return $payment->creditCard->token;
 }
开发者ID:coder-d,项目名称:payment_library,代码行数:11,代码来源:Braintree.php


示例6: saveCreditCard

 public function saveCreditCard()
 {
     $send_array = $this->options['creditCard'];
     if (isset($this->options['billing'])) {
         $send_array['billingAddress'] = $this->options['billing'];
     }
     if (isset($this->options['customerId'])) {
         $send_array['customerId'] = $this->options['customerId'];
     }
     $result = Braintree_CreditCard::create($send_array);
     if ($result->success) {
         return array('status' => true, 'result' => $result);
     } else {
         return array('status' => false, 'result' => $result);
     }
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:16,代码来源:BraintreeApi.php


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


示例8: delete

 /**
  * Deletes a record via the API
  *
  * @param   object  $model
  * @param   mixed   $conditions
  * @return  bool
  */
 public function delete(Model $model, $conditions = null)
 {
     $ids = $this->_getIdsToBeDeleted($model, $conditions);
     if ($ids === false) {
         return false;
     }
     $entity = $this->_getModelEntity($model);
     if (!empty($ids)) {
         foreach ($ids as $id) {
             try {
                 switch ($entity) {
                     case 'Customer':
                         Braintree_Customer::delete($id);
                         break;
                     case 'Transaction':
                         $this->showError(__('Transactions cannot be deleted', true));
                         return false;
                         break;
                     case 'CreditCard':
                         Braintree_CreditCard::delete($id);
                         break;
                     case 'Address':
                         $exploded = explode('|', $id);
                         if (count($exploded) != 2) {
                             return false;
                         }
                         list($customer_id, $address_id) = $exploded;
                         Braintree_Address::delete($customer_id, $address_id);
                         break;
                     default:
                         return false;
                         break;
                 }
             } catch (Exception $e) {
                 $this->showError(print_r($e, true));
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:sime,项目名称:cakephp-braintree-plugin,代码行数:48,代码来源:BraintreeSource.php


示例9: _initialize

 /**
  * sets instance properties from an array of values
  *
  * @ignore
  * @access protected
  * @param array $customerAttribs array of customer data
  * @return none
  */
 protected function _initialize($customerAttribs)
 {
     // set the attributes
     $this->_attributes = $customerAttribs;
     // map each address into its own object
     $addressArray = array();
     if (isset($customerAttribs['addresses'])) {
         foreach ($customerAttribs['addresses'] as $address) {
             $addressArray[] = Braintree_Address::factory($address);
         }
     }
     $this->_set('addresses', $addressArray);
     // map each creditcard into its own object
     $ccArray = array();
     if (isset($customerAttribs['creditCards'])) {
         foreach ($customerAttribs['creditCards'] as $creditCard) {
             $ccArray[] = Braintree_CreditCard::factory($creditCard);
         }
     }
     $this->_set('creditCards', $ccArray);
 }
开发者ID:othreed,项目名称:osCommerce-234-bootstrap-wADDONS,代码行数:29,代码来源:Customer.php


示例10: testErrorsOnFindWithWhitespaceCharacterArgument

 function testErrorsOnFindWithWhitespaceCharacterArgument()
 {
     $this->setExpectedException('InvalidArgumentException');
     Braintree_CreditCard::find('\\t');
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:5,代码来源:CreditCardTest.php


示例11: _verifyGatewayResponse

 /**
  * generic method for validating incoming gateway responses
  *
  * creates a new Braintree_CreditCard or Braintree_PayPalAccount object
  * and encapsulates it inside a Braintree_Result_Successful object, or
  * encapsulates a Braintree_Errors object inside a Result_Error
  * alternatively, throws an Unexpected exception if the response is invalid.
  *
  * @ignore
  * @param array $response gateway response values
  * @return object Result_Successful or Result_Error
  * @throws Braintree_Exception_Unexpected
  */
 private static function _verifyGatewayResponse($response)
 {
     if (isset($response['creditCard'])) {
         // return a populated instance of Braintree_CreditCard
         return new Braintree_Result_Successful(Braintree_CreditCard::factory($response['creditCard']), "paymentMethod");
     } else {
         if (isset($response['paypalAccount'])) {
             // return a populated instance of Braintree_PayPalAccount
             return new Braintree_Result_Successful(Braintree_PayPalAccount::factory($response['paypalAccount']), "paymentMethod");
         } else {
             if (isset($response['apiErrorResponse'])) {
                 return new Braintree_Result_Error($response['apiErrorResponse']);
             } else {
                 if (is_array($response)) {
                     return Braintree_UnknownPaymentMethod::factory($response);
                 } else {
                     throw new Braintree_Exception_Unexpected('Expected credit card, paypal account or apiErrorResponse');
                 }
             }
         }
     }
 }
开发者ID:bala223344,项目名称:wordpress-bear,代码行数:35,代码来源:PaymentMethod.php


示例12: testDelete_worksWithCreditCards

 function testDelete_worksWithCreditCards()
 {
     $paymentMethodToken = 'CREDIT_CARD_TOKEN-' . strval(rand());
     $customer = Braintree_Customer::createNoValidate();
     $creditCardResult = Braintree_CreditCard::create(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/2011', 'token' => $paymentMethodToken));
     $this->assertTrue($creditCardResult->success);
     Braintree_PaymentMethod::delete($paymentMethodToken);
     $this->setExpectedException('Braintree_Exception_NotFound');
     Braintree_PaymentMethod::find($paymentMethodToken);
     integrationMerchantConfig();
 }
开发者ID:dhaupin,项目名称:braintree-payments,代码行数:11,代码来源:PaymentMethodTest.php


示例13: testUpdateCreditCardFromTransparentRedirect

 function testUpdateCreditCardFromTransparentRedirect()
 {
     $customer = Braintree_Customer::create(array('firstName' => 'Mike', 'lastName' => 'Jonez'))->customer;
     $creditCard = Braintree_CreditCard::create(array('customerId' => $customer->id, 'number' => Braintree_Test_CreditCardNumbers::$masterCard, 'expirationMonth' => '10', 'expirationYear' => '10'))->creditCard;
     $params = array('credit_card' => array('number' => Braintree_Test_CreditCardNumbers::$visa));
     $trParams = array('paymentMethodToken' => $creditCard->token, 'creditCard' => array('expirationMonth' => '11', 'expirationYear' => '11'));
     $trData = Braintree_TransparentRedirect::updateCreditCardData(array_merge($trParams, array("redirectUrl" => "http://www.example.com")));
     $queryString = Braintree_TestHelper::submitTrRequest(Braintree_TransparentRedirect::url(), $params, $trData);
     Braintree_TransparentRedirect::confirm($queryString);
     $creditCard = Braintree_CreditCard::find($creditCard->token);
     $this->assertequals('401288', $creditCard->bin);
     $this->assertequals('1881', $creditCard->last4);
     $this->assertequals('11/2011', $creditCard->expirationDate);
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:14,代码来源:TransparentRedirectTest.php


示例14: deleteCard

 function deleteCard($token, $token_id)
 {
     $OSCOM_Db = Registry::get('Db');
     Braintree_Configuration::environment(MODULE_PAYMENT_BRAINTREE_CC_TRANSACTION_SERVER == 'Live' ? 'production' : 'sandbox');
     Braintree_Configuration::merchantId(MODULE_PAYMENT_BRAINTREE_CC_MERCHANT_ID);
     Braintree_Configuration::publicKey(MODULE_PAYMENT_BRAINTREE_CC_PUBLIC_KEY);
     Braintree_Configuration::privateKey(MODULE_PAYMENT_BRAINTREE_CC_PRIVATE_KEY);
     try {
         Braintree_CreditCard::delete($token);
     } catch (Exception $e) {
     }
     return $OSCOM_Db->delete('customers_braintree_tokens', ['id' => $token_id, 'customers_id' => $_SESSION['customer_id'], 'braintree_token' => $token]) === 1;
 }
开发者ID:Akofelaz,项目名称:oscommerce2,代码行数:13,代码来源:braintree_cc.php


示例15: vaultCreditCard

 public function vaultCreditCard()
 {
     $token = $this->creditCardDetails->token;
     if (empty($token)) {
         return null;
     } else {
         return Braintree_CreditCard::find($token);
     }
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:9,代码来源:Transaction.php


示例16: testVerificationIsLatestVerification

 function testVerificationIsLatestVerification()
 {
     $creditCard = Braintree_CreditCard::factory(array('verifications' => array(array('id' => '123', 'createdAt' => DateTime::createFromFormat('Ymd', '20121212')), array('id' => '932', 'createdAt' => DateTime::createFromFormat('Ymd', '20121215')), array('id' => '456', 'createdAt' => DateTime::createFromFormat('Ymd', '20121213')))));
     $this->assertEquals('932', $creditCard->verification->id);
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:5,代码来源:CreditCardTest.php


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


示例18: updateCreditCardViaTr

 function updateCreditCardViaTr($regularParams, $trParams)
 {
     $trData = Braintree_TransparentRedirect::updateCreditCardData(array_merge($trParams, array("redirectUrl" => "http://www.example.com")));
     return Braintree_TestHelper::submitTrRequest(Braintree_CreditCard::updateCreditCardUrl(), $regularParams, $trData);
 }
开发者ID:rayku,项目名称:rayku,代码行数:5,代码来源:CreditCardTest.php


示例19: testUpdateAndMakeDefault

 function testUpdateAndMakeDefault()
 {
     $customer = Braintree_Customer::createNoValidate();
     $creditCardResult = Braintree_CreditCard::create(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/12'));
     $this->assertTrue($creditCardResult->success);
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE')));
     $createResult = Braintree_PaymentMethod::create(array('customerId' => $customer->id, 'paymentMethodNonce' => $nonce));
     $this->assertTrue($createResult->success);
     $updateResult = Braintree_PayPalAccount::update($createResult->paymentMethod->token, array('options' => array('makeDefault' => true)));
     $this->assertTrue($updateResult->success);
     $this->assertTrue($updateResult->paypalAccount->isDefault());
 }
开发者ID:beevo,项目名称:disruptivestrong,代码行数:13,代码来源:PayPalAccountTest.php


示例20: executePaypal

 public function executePaypal()
 {
     $this->user = $this->getUser()->getRaykuUser();
     $this->userId = $this->user->getId();
     if (sfWebRequest::POST === $this->getRequest()->getMethod() && $this->hasRequestParameter('submit_card')) {
         $expiration = substr($this->getRequestParameter('expiry_date'), 0, 2) . '/' . substr($this->getRequestParameter('expiry_date'), -2);
         require_once $_SERVER['DOCUMENT_ROOT'] . '/braintree_environment.php';
         $result = Braintree_Customer::create(array('firstName' => $this->user->getName(), 'lastName' => '', 'creditCard' => array('cardholderName' => $this->getRequestParameter('realname'), 'number' => $this->getRequestParameter('credit_card'), 'cvv' => $this->getRequestParameter('cvv'), 'expirationDate' => $expiration, 'options' => array('verifyCard' => true))));
         error_log($result->customer->creditCards[0]->token, 0);
         if (!$result->success) {
             $this->error = 'Your credit card is invalid.';
             //return sfView::SUCCESS;
         } else {
             //should only save last 4 digit
             $this->user->setCreditCard(substr($this->getRequestParameter('credit_card'), -4));
             $this->user->setCreditCardToken($result->customer->creditCards[0]->token);
             $this->user->save();
             //return sfView::SUCCESS;
         }
     }
     if (sfWebRequest::POST === $this->getRequest()->getMethod() && $this->hasRequestParameter('pay_balance')) {
         $this->points = $this->user->getPoints();
         $this->token = $this->user->getCreditCardToken();
         if ($this->points < 0) {
             $amount = '' . $this->points * -1;
             require_once $_SERVER['DOCUMENT_ROOT'] . '/braintree_environment.php';
             $result = Braintree_CreditCard::sale($this->token, array('amount' => $amount, 'credit_card' => array()));
             // error_log($result->customer->creditCards[0]->token, 0);
             if (!$result->success) {
                 //error_log("invalid", 0);
                 $this->error = 'Your credit card is invalid.';
             } else {
                 //should pay all balance
                 $this->user->setPoints(0);
                 $this->user->save();
             }
         }
     }
     $this->token = $this->user->getCreditCardToken();
     $this->cardNum = $this->user->getCreditCard();
     return sfView::SUCCESS;
 }
开发者ID:rayku,项目名称:rayku,代码行数:42,代码来源:actions.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Braintree_Customer类代码示例发布时间:2022-05-23
下一篇:
PHP Braintree_Configuration类代码示例发布时间: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