creditCard() 공개 메소드

public creditCard ( ) : CreditCardGateway
리턴 CreditCardGateway
예제 #1
0
 public function testGatewayCreate()
 {
     $customer = Braintree\Customer::createNoValidate();
     $gateway = new Braintree\Gateway(array('environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key'));
     $result = $gateway->creditCard()->create(array('customerId' => $customer->id, 'cardholderName' => 'Cardholder', 'number' => '5105105105105100', 'expirationDate' => '05/12'));
     $this->assertTrue($result->success);
     $this->assertEquals($customer->id, $result->creditCard->customerId);
     $this->assertEquals('510510', $result->creditCard->bin);
     $this->assertEquals('5100', $result->creditCard->last4);
     $this->assertEquals('Cardholder', $result->creditCard->cardholderName);
     $this->assertEquals('05/2012', $result->creditCard->expirationDate);
 }
 public function testGrant_returnsANonceThatIsVaultable()
 {
     $partnerMerchantGateway = new Braintree\Gateway(['environment' => 'development', 'merchantId' => 'integration_merchant_public_id', 'publicKey' => 'oauth_app_partner_user_public_key', 'privateKey' => 'oauth_app_partner_user_private_key']);
     $customer = $partnerMerchantGateway->customer()->create(['firstName' => 'Joe', 'lastName' => 'Brown'])->customer;
     $creditCard = $partnerMerchantGateway->creditCard()->create(['customerId' => $customer->id, 'cardholderName' => 'Adam Davis', 'number' => '4111111111111111', 'expirationDate' => '05/2009'])->creditCard;
     $oauthAppGateway = new Braintree\Gateway(['clientId' => 'client_id$development$integration_client_id', 'clientSecret' => 'client_secret$development$integration_client_secret']);
     $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, ['merchant_public_id' => 'integration_merchant_id', 'scope' => 'grant_payment_method']);
     $credentials = $oauthAppGateway->oauth()->createTokenFromCode(['code' => $code]);
     $grantingGateway = new Braintree\Gateway(['accessToken' => $credentials->accessToken]);
     $grantResult = $grantingGateway->paymentMethod()->grant($creditCard->token, true);
     $customer = Braintree\Customer::create(['firstName' => 'Bob', 'lastName' => 'Rob'])->customer;
     $result = Braintree\PaymentMethod::create(['customerId' => $customer->id, 'paymentMethodNonce' => $grantResult->nonce]);
     $this->assertTrue($result->success);
 }
예제 #3
0
 public function testTransactionsCanBeCreatedWithSharedParams()
 {
     $partnerMerchantGateway = new Braintree\Gateway(['environment' => 'development', 'merchantId' => 'integration_merchant_public_id', 'publicKey' => 'oauth_app_partner_user_public_key', 'privateKey' => 'oauth_app_partner_user_private_key']);
     $customer = $partnerMerchantGateway->customer()->create(['firstName' => 'Joe', 'lastName' => 'Brown'])->customer;
     $address = $partnerMerchantGateway->address()->create(['customerId' => $customer->id, 'firstName' => 'Dan', 'lastName' => 'Smith'])->address;
     $creditCard = $partnerMerchantGateway->creditCard()->create(['customerId' => $customer->id, 'cardholderName' => 'Adam Davis', 'number' => '4111111111111111', 'expirationDate' => '05/2009'])->creditCard;
     $oauthAppGateway = new Braintree\Gateway(['clientId' => 'client_id$development$integration_client_id', 'clientSecret' => 'client_secret$development$integration_client_secret']);
     $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, ['merchant_public_id' => 'integration_merchant_id', 'scope' => 'read_write,shared_vault_transactions']);
     $credentials = $oauthAppGateway->oauth()->createTokenFromCode(['code' => $code]);
     $oauthAccesTokenGateway = new Braintree\Gateway(['accessToken' => $credentials->accessToken]);
     $result = $oauthAccesTokenGateway->transaction()->sale(['amount' => '100.00', 'sharedPaymentMethodToken' => $creditCard->token, 'sharedCustomerId' => $customer->id, 'sharedShippingAddressId' => $address->id, 'sharedBillingAddressId' => $address->id]);
     $this->assertEquals($result->transaction->shippingDetails->firstName, $address->firstName);
     $this->assertEquals($result->transaction->billingDetails->firstName, $address->firstName);
 }