本文整理汇总了PHP中Braintree_CreditCard::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_CreditCard::find方法的具体用法?PHP Braintree_CreditCard::find怎么用?PHP Braintree_CreditCard::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Braintree_CreditCard
的用法示例。
在下文中一共展示了Braintree_CreditCard::find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storedCard
public function storedCard($token)
{
try {
return Braintree_CreditCard::find($token);
} catch (Braintree_Exception $e) {
Mage::logException($e);
}
}
示例2: vaultCreditCard
public function vaultCreditCard()
{
$token = $this->creditCardDetails->token;
if (empty($token)) {
return null;
} else {
return Braintree_CreditCard::find($token);
}
}
示例3: testDelete_deletesThePaymentMethod
function testDelete_deletesThePaymentMethod()
{
$customer = Braintree_Customer::createNoValidate(array());
$creditCard = Braintree_CreditCard::createNoValidate(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/12'));
Braintree_CreditCard::find($creditCard->token);
Braintree_CreditCard::delete($creditCard->token);
$this->setExpectedException('Braintree_Exception_NotFound');
Braintree_CreditCard::find($creditCard->token);
}
示例4: testErrorsOnFindWithWhitespaceCharacterArgument
function testErrorsOnFindWithWhitespaceCharacterArgument()
{
$this->setExpectedException('InvalidArgumentException');
Braintree_CreditCard::find('\\t');
}
示例5: testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce
function testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce()
{
$customer = Braintree_Customer::createNoValidate();
$nonce = Braintree_HttpClientApi::nonce_for_new_card(array('credit_card' => array('number' => '4111111111111111', 'expirationMonth' => '12', 'expirationYear' => '2020', 'options' => array('validate' => false))));
$address = Braintree_Address::create(array('customerId' => $customer->id, 'firstName' => 'Bobby', 'lastName' => 'Tables'))->address;
$result = Braintree_PaymentMethod::create(array('paymentMethodNonce' => $nonce, 'customerId' => $customer->id, 'billingAddressId' => $address->id));
$this->assertTrue($result->success);
$this->assertTrue(is_a($result->paymentMethod, 'Braintree_CreditCard'));
$token = $result->paymentMethod->token;
$foundCreditCard = Braintree_CreditCard::find($token);
$this->assertTrue(NULL != $foundCreditCard);
$this->assertEquals('Bobby', $foundCreditCard->billingAddress->firstName);
$this->assertEquals('Tables', $foundCreditCard->billingAddress->lastName);
}
示例6: 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);
}
示例7: testUpdate_canUpdatePaymentMethodWithPaymentMethodNonce
function testUpdate_canUpdatePaymentMethodWithPaymentMethodNonce()
{
$oldCreditCard = Braintree_SubscriptionTestHelper::createCreditCard();
$plan = Braintree_SubscriptionTestHelper::triallessPlan();
$subscription = Braintree_Subscription::create(array('paymentMethodToken' => $oldCreditCard->token, 'price' => '54.99', 'planId' => $plan['id']))->subscription;
$customerId = Braintree_Customer::create()->customer->id;
$nonce = Braintree_HttpClientApi::nonce_for_new_card(array("creditCard" => array("number" => "4111111111111111", "expirationMonth" => "11", "expirationYear" => "2099"), "customerId" => $oldCreditCard->customerId, "share" => true));
$result = Braintree_Subscription::update($subscription->id, array('paymentMethodNonce' => $nonce));
$this->assertTrue($result->success);
$newCreditCard = Braintree_CreditCard::find($result->subscription->paymentMethodToken);
$this->assertEquals("1111", $newCreditCard->last4);
$this->assertNotEquals($oldCreditCard->last4, $newCreditCard->last4);
}
示例8: read
/**
* Reads from the API
*
* @param object $model
* @param array $queryData
* @return array
*/
public function read(Model $model, $queryData = array(), $recursive = NULL)
{
$queryData = array_merge(array('conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => 1, 'offset' => null, 'order' => array(0 => null), 'page' => 1, 'group' => null, 'callbacks' => 1, 'contain' => false, 'recursive' => -1), $queryData);
extract($queryData);
if (!empty($fields) && is_string($fields) && $fields == 'count') {
$is_count = true;
} else {
$is_count = false;
}
if (!$this->_readErrors($model, $queryData, array('is_count' => $is_count))) {
return false;
}
if (!empty($conditions[$model->alias . '.' . $model->primaryKey]) && ($limit == 1 || empty($limit) && $is_count)) {
$entity = $this->_getModelEntity($model);
try {
switch ($entity) {
case 'Customer':
$customer = Braintree_Customer::find($conditions[$model->alias . '.' . $model->primaryKey]);
$result = array(0 => array($model->alias => array('id' => $customer->id, 'first_name' => $customer->firstName, 'last_name' => $customer->lastName, 'company' => $customer->company, 'email' => $customer->email, 'phone' => $customer->phone, 'fax' => $customer->fax, 'website' => $customer->website, 'created' => $customer->createdAt->format('Y-m-d H:i:s'), 'modified' => $customer->updatedAt->format('Y-m-d H:i:s'))));
break;
case 'Transaction':
$exploded = explode('|', $conditions[$model->alias . '.' . $model->primaryKey]);
$braintree_transaction_id = isset($exploded[1]) ? $exploded[1] : $conditions[$model->alias . '.' . $model->primaryKey];
$transaction = Braintree_Transaction::find($braintree_transaction_id);
$result = array(0 => array($model->alias => array('id' => $transaction->customer['id'] . '|' . $transaction->id, 'customer_id' => $transaction->customer['id'], 'payment_method_token' => $transaction->creditCard['token'], 'type' => $transaction->type, 'amount' => $transaction->amount, 'status' => $transaction->status, 'created' => $transaction->createdAt->format('Y-m-d H:i:s'), 'modified' => $transaction->updatedAt->format('Y-m-d H:i:s'))));
$result[0][$model->alias . 'Status'] = array();
$count = 0;
foreach ($transaction->statusHistory as $status) {
$result[0][$model->alias . 'Status'][$count] = array('status' => $status->status, 'amount' => $status->amount, 'user' => $status->user, 'transaction_source' => $status->transactionSource, 'created' => $status->timestamp->format('Y-m-d H:i:s'));
$count++;
}
break;
case 'CreditCard':
$credit_card = Braintree_CreditCard::find($conditions[$model->alias . '.' . $model->primaryKey]);
$result = array(0 => array($model->alias => array('token' => $credit_card->token, 'customer_id' => $credit_card->customerId, 'cardholder_name' => $credit_card->cardholderName, 'card_type' => $credit_card->cardType, 'masked_number' => $credit_card->maskedNumber, 'expiration_date' => date('Y-m', strtotime($credit_card->expirationDate)) . '-01', 'is_default' => $credit_card->default, 'created' => $credit_card->createdAt->format('Y-m-d H:i:s'), 'modified' => $credit_card->updatedAt->format('Y-m-d H:i:s'))));
break;
case 'Address':
$exploded = explode('|', $conditions[$model->alias . '.' . $model->primaryKey]);
if (count($exploded) != 2) {
return false;
}
list($customer_id, $address_id) = $exploded;
$address = Braintree_Address::find($customer_id, $address_id);
$result = array(0 => array($model->alias => array('id' => $address->customerId . '|' . $address->id, 'first_name' => $address->firstName, 'last_name' => $address->lastName, 'company' => $address->company, 'street_address' => $address->streetAddress, 'extended_address' => $address->extendedAddress, 'locality' => $address->locality, 'region' => $address->region, 'postal_code' => $address->postalCode, 'country_code_alpha_2' => $address->countryCodeAlpha2, 'country_code_alpha_3' => $address->countryCodeAlpha3, 'country_code_numeric' => $address->countryCodeNumeric, 'country_name' => $address->countryName, 'created' => $address->createdAt->format('Y-m-d H:i:s'), 'modified' => $address->updatedAt->format('Y-m-d H:i:s'))));
break;
default:
$result = false;
break;
}
} catch (Exception $e) {
$result = false;
}
if ($is_count) {
return array(0 => array(0 => array('count' => $result ? 1 : 0)));
}
return $result;
}
if (empty($conditions)) {
try {
$all_customers = Braintree_Customer::all();
} catch (Exception $e) {
$this->showError(print_r($e, true));
return array();
}
$return = array();
$count = 0;
foreach ($all_customers->_ids as $id) {
$return[$count][$model->alias]['id'] = $id;
$count++;
}
return $return;
}
}
示例9: updateCard
public function updateCard($config, $data)
{
$common = new Common();
$updateData = array();
$oldCardExists = false;
$session = new Container('frontend');
\Braintree_Configuration::environment($config['payment_gateway']['tree_env']);
\Braintree_Configuration::merchantId($config['payment_gateway']['merchant_id']);
\Braintree_Configuration::publicKey($config['payment_gateway']['public_key']);
\Braintree_Configuration::privateKey($config['payment_gateway']['private_key']);
$cardDetails = $common->getUserCardDetails($config['api_url']['value'], array('user_id' => $session->userid));
//print_r($cardDetails); exit;
$card = isset($cardDetails[0]) ? $cardDetails[0] : '';
if (!is_array($data)) {
parse_str($data, $data);
}
if (isset($card) && is_array($card)) {
try {
$result = \Braintree_CreditCard::find($card['creditCardDetails_token']);
$oldCardExists = true;
} catch (\Exception $ex) {
$oldCardExists = false;
//echo $ex->getMessage();
}
try {
$delete = \Braintree_CreditCard::delete($card['creditCardDetails_token']);
} catch (\Exception $ex) {
//echo $ex->getMessage();
}
}
if (!isset($data['creditCardDetails_token']) && !isset($data['customerDetails_id'])) {
$result = \Braintree_CreditCard::create(array('customerId' => isset($card['customerDetails_id']) ? $card['customerDetails_id'] : '', 'number' => $data['card_no'], 'cvv' => $data['cvv'], 'expirationDate' => $data['month'] . '/' . $data['year'], 'cardholderName' => $data['name_on_card'], 'options' => array('makeDefault' => true)));
if ($result->success) {
$data['creditCardDetails_token'] = $result->creditCard->token;
$data['customerDetails_id'] = $result->creditCard->customerId;
} else {
return array('status' => 0, 'msg' => $result->message, 'errors' => $result->errors->deepAll());
}
}
$updateData['user_id'] = $session->userid;
$updateData['card_expiration_hash'] = isset($data['card_expiration_hash']) ? $data['card_expiration_hash'] : md5($data['month'] . '-' . $data['Year']);
$updateData['creditCardDetails_token'] = $data['creditCardDetails_token'];
$updateData['customerDetails_id'] = $data['customerDetails_id'];
isset($card['use_for_renew']) ? $updateData['use_for_renew'] = $card['use_for_renew'] : '';
isset($data['use_for_renew']) ? $updateData['use_for_renew'] = $data['use_for_renew'] : '';
$res = isset($card['id']) ? $this->api->curl($config['api_url']['value'] . '/api/card_details/' . $card['id'] . '/', $updateData, 'PUT') : $this->api->curl($config['api_url']['value'] . '/api/card_details/', $updateData, 'POST');
if ($res->getStatusCode() == 200 || $res->getStatusCode() == 201) {
return array('status' => 1, 'msg' => 'Card details successfully updated..!!');
} else {
return array('status' => 1, 'msg' => 'Failed to update card details..!!', 'errors' => json_decode($res->getBody(), true));
}
}
示例10: get_saved_card
/**
* Get the saved credit card object on file for the given token
*
* @since 2.0
* @param string $token the braintree token for the payment method
* @return object braintree creditCard object
*/
public function get_saved_card($token)
{
try {
return Braintree_CreditCard::find($token);
} catch (Exception $e) {
$this->add_debug_message($e->getMessage());
}
}
示例11: find
/**
* @param string $id
* @return \Braintree_CreditCard
*/
public function find($token)
{
return \Braintree_CreditCard::find($token);
}