address() public method

public address ( ) : AddressGateway
return AddressGateway
Esempio n. 1
0
 public function testGatewayCreate()
 {
     $customer = Braintree\Customer::createNoValidate();
     $gateway = new Braintree\Gateway(['environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key']);
     $result = $gateway->address()->create(['customerId' => $customer->id, 'streetAddress' => '1 E Main St', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622']);
     $this->assertTrue($result->success);
     $address = $result->address;
     $this->assertEquals('1 E Main St', $address->streetAddress);
     $this->assertEquals('Chicago', $address->locality);
     $this->assertEquals('IL', $address->region);
     $this->assertEquals('60622', $address->postalCode);
 }
 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);
 }