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


PHP Braintree_CreditCard::sale方法代码示例

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


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

示例1: testSale_createsASaleUsingGivenToken

 function testSale_createsASaleUsingGivenToken()
 {
     $customer = Braintree_Customer::createNoValidate(array('creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12')));
     $creditCard = $customer->creditCards[0];
     $result = Braintree_CreditCard::sale($creditCard->token, array('amount' => '100.00'));
     $this->assertTrue($result->success);
     $this->assertEquals('100.00', $result->transaction->amount);
     $this->assertEquals($customer->id, $result->transaction->customerDetails->id);
     $this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token);
 }
开发者ID:buga1234,项目名称:buga_segforours,代码行数:10,代码来源:CreditCardTest.php

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