Exemplo n.º 1
0
 public static function createCredentials($params)
 {
     $gateway = new Braintree\Gateway(array('clientId' => $params['clientId'], 'clientSecret' => $params['clientSecret']));
     $code = OAuthTestHelper::createGrant($gateway, array('merchant_public_id' => $params['merchantId'], 'scope' => 'read_write'));
     $credentials = $gateway->oauth()->createTokenFromCode(array('code' => $code, 'scope' => 'read_write'));
     return $credentials;
 }
Exemplo n.º 2
0
 public function testCreateWithAccessToken()
 {
     $credentials = Test\Braintree\OAuthTestHelper::createCredentials(['clientId' => 'client_id$development$integration_client_id', 'clientSecret' => 'client_secret$development$integration_client_secret', 'merchantId' => 'integration_merchant_id']);
     $gateway = new Braintree\Gateway(['accessToken' => $credentials->accessToken]);
     $result = $gateway->customer()->create(['firstName' => 'Mike', 'lastName' => 'Jones']);
     $this->assertEquals(true, $result->success);
     $customer = $result->customer;
     $this->assertEquals('Mike', $customer->firstName);
     $this->assertEquals('Jones', $customer->lastName);
     $this->assertNotNull($customer->merchantId);
 }
Exemplo n.º 3
0
 public function testCreateTokenFromRefreshToken()
 {
     $gateway = new Braintree\Gateway(array('clientId' => 'client_id$development$integration_client_id', 'clientSecret' => 'client_secret$development$integration_client_secret'));
     $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, array('merchant_public_id' => 'integration_merchant_id', 'scope' => 'read_write'));
     $refreshToken = $gateway->oauth()->createTokenFromCode(array('code' => $code, 'scope' => 'read_write'))->credentials->refreshToken;
     $result = $gateway->oauth()->createTokenFromRefreshToken(array('refreshToken' => $refreshToken, 'scope' => 'read_write'));
     $this->assertEquals(true, $result->success);
     $credentials = $result->credentials;
     $this->assertNotNull($credentials->accessToken);
     $this->assertNotNull($credentials->refreshToken);
     $this->assertEquals('bearer', $credentials->tokenType);
     $this->assertNotNull($credentials->expiresAt);
 }
 public function testGrant_raisesAnErrorIfTokenIsNotFound()
 {
     $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]);
     $this->setExpectedException('Braintree\\Exception\\NotFound');
     $grantResult = $grantingGateway->paymentMethod()->grant("not_a_real_token", false);
 }
Exemplo n.º 5
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);
 }