本文整理汇总了PHP中Braintree_CreditCard类的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_CreditCard类的具体用法?PHP Braintree_CreditCard怎么用?PHP Braintree_CreditCard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Braintree_CreditCard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()));
}
示例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);
}
示例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']);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例10: testErrorsOnFindWithWhitespaceCharacterArgument
function testErrorsOnFindWithWhitespaceCharacterArgument()
{
$this->setExpectedException('InvalidArgumentException');
Braintree_CreditCard::find('\\t');
}
示例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');
}
}
}
}
}
示例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();
}
示例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);
}
示例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;
}
示例15: vaultCreditCard
public function vaultCreditCard()
{
$token = $this->creditCardDetails->token;
if (empty($token)) {
return null;
} else {
return Braintree_CreditCard::find($token);
}
}