本文整理汇总了PHP中Braintree_CreditCard::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_CreditCard::create方法的具体用法?PHP Braintree_CreditCard::create怎么用?PHP Braintree_CreditCard::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Braintree_CreditCard
的用法示例。
在下文中一共展示了Braintree_CreditCard::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: _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;
}
示例4: 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);
}
}
示例5: 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);
}
}
}
示例6: testUnknownCardTypeIndicators
function testUnknownCardTypeIndicators()
{
$customer = Braintree_Customer::createNoValidate();
$result = Braintree_CreditCard::create(array('customerId' => $customer->id, 'cardholderName' => 'Cardholder', 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::UNKNOWN, 'expirationDate' => '05/12', 'options' => array('verifyCard' => true)));
$this->assertEquals(Braintree_CreditCard::PREPAID_UNKNOWN, $result->creditCard->prepaid);
$this->assertEquals(Braintree_CreditCard::DURBIN_REGULATED_UNKNOWN, $result->creditCard->durbinRegulated);
$this->assertEquals(Braintree_CreditCard::PAYROLL_UNKNOWN, $result->creditCard->payroll);
$this->assertEquals(Braintree_CreditCard::DEBIT_UNKNOWN, $result->creditCard->debit);
$this->assertEquals(Braintree_CreditCard::HEALTHCARE_UNKNOWN, $result->creditCard->healthcare);
$this->assertEquals(Braintree_CreditCard::COMMERCIAL_UNKNOWN, $result->creditCard->commercial);
$this->assertEquals(Braintree_CreditCard::COUNTRY_OF_ISSUANCE_UNKNOWN, $result->creditCard->countryOfIssuance);
$this->assertEquals(Braintree_CreditCard::ISSUING_BANK_UNKNOWN, $result->creditCard->issuingBank);
}
示例7: testCreate_throwsIfInvalidKey
function testCreate_throwsIfInvalidKey()
{
$this->setExpectedException('InvalidArgumentException', 'invalid keys: invalidKey');
Braintree_CreditCard::create(array('invalidKey' => 'foo'));
}
示例8: 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);
}
示例9: addCreditCardToBrainTree
private function addCreditCardToBrainTree($arrCCData)
{
$result = Braintree_CreditCard::create($arrCCData);
return $result;
}
示例10: 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();
}
示例11: 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);
}
示例12: testGatewayRejectionIsNullOnProcessorDecline
function testGatewayRejectionIsNullOnProcessorDecline()
{
$old_merchant_id = Braintree_Configuration::merchantId();
$old_public_key = Braintree_Configuration::publicKey();
$old_private_key = Braintree_Configuration::privateKey();
Braintree_Configuration::merchantId('processing_rules_merchant_id');
Braintree_Configuration::publicKey('processing_rules_public_key');
Braintree_Configuration::privateKey('processing_rules_private_key');
$customer = Braintree_Customer::createNoValidate();
$result = Braintree_CreditCard::create(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/2011', 'cvv' => '200', 'options' => array('verifyCard' => true)));
Braintree_Configuration::merchantId($old_merchant_id);
Braintree_Configuration::publicKey($old_public_key);
Braintree_Configuration::privateKey($old_private_key);
$this->assertFalse($result->success);
$this->assertNull($result->creditCardVerification->gatewayRejectionReason);
}
示例13: 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());
}
示例14: createCard
/**
* @param $customer
* @param $data
*
* @return bool
*/
private function createCard($customer, $data)
{
$card = \Braintree_CreditCard::create(array('customerId' => $customer->customer->id, 'number' => $data['creditCardNumber'], 'expirationDate' => "{$data['expirationMonth']}/{$data['expirationYear']}", 'cardholderName' => $data['cardHolderName'], 'cvv' => $data['securityCode'], 'options' => array('makeDefault' => true)));
return $card;
}
示例15: createCard
public function createCard($data)
{
$result = Braintree_CreditCard::create($data);
if ($result->success) {
return array('success' => 1, 'payment_method_token' => $result->creditCard->token);
} else {
return array('success' => 0, 'validation_errors' => $result->errors->deepAll());
}
}