customer() публичный Метод

public customer ( ) : CustomerGateway
Результат CustomerGateway
Пример #1
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);
 }
Пример #2
0
 public function testRevokeAccessToken()
 {
     $gateway = new Braintree\Gateway(['clientId' => 'client_id$development$integration_client_id', 'clientSecret' => 'client_secret$development$integration_client_secret']);
     $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, ['merchant_public_id' => 'integration_merchant_id', 'scope' => 'read_write']);
     $result = $gateway->oauth()->createTokenFromCode(['code' => $code, 'scope' => 'read_write']);
     $revokeAccessTokenResult = $gateway->oauth()->revokeAccessToken($result->accessToken);
     $this->assertTrue($revokeAccessTokenResult->success);
     $this->assertTrue($revokeAccessTokenResult->result->success);
     $gateway = new Braintree\Gateway(['accessToken' => $result->accessToken]);
     $this->setExpectedException('Braintree\\Exception\\Authentication');
     $gateway->customer()->create();
 }
 public function testCanExchangeNonceForEuropeBankAccount()
 {
     $gateway = new Braintree\Gateway(array('environment' => 'development', 'merchantId' => 'altpay_merchant', 'publicKey' => 'altpay_merchant_public_key', 'privateKey' => 'altpay_merchant_private_key'));
     $result = $gateway->customer()->create();
     $this->assertTrue($result->success);
     $customer = $result->customer;
     $clientApi = new HttpClientApi($gateway->config);
     $nonce = $clientApi->nonceForNewEuropeanBankAccount(array("customerId" => $customer->id, "sepa_mandate" => array("locale" => "de-DE", "bic" => "DEUTDEFF", "iban" => "DE89370400440532013000", "accountHolderName" => "Bob Holder", "billingAddress" => array("streetAddress" => "123 Currywurst Way", "extendedAddress" => "Lager Suite", "firstName" => "Wilhelm", "lastName" => "Dix", "locality" => "Frankfurt", "postalCode" => "60001", "countryCodeAlpha2" => "DE", "region" => "Hesse"))));
     $result = $gateway->paymentMethod()->create(array("customerId" => $customer->id, "paymentMethodNonce" => $nonce));
     $this->assertTrue($result->success);
     $paymentMethod = $result->paymentMethod;
     $account = $gateway->paymentMethod()->find($paymentMethod->token);
     $this->assertEquals($paymentMethod->token, $account->token);
     $this->assertEquals($account->bic, "DEUTDEFF");
 }
 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);
 }
 public function testHandlesEuropeBankAccounts()
 {
     $gateway = new Braintree\Gateway(['environment' => 'development', 'merchantId' => 'altpay_merchant', 'publicKey' => 'altpay_merchant_public_key', 'privateKey' => 'altpay_merchant_private_key']);
     $result = $gateway->customer()->create();
     $this->assertTrue($result->success);
     $customer = $result->customer;
     $clientApi = new HttpClientApi($gateway->config);
     $nonce = $clientApi->nonceForNewEuropeanBankAccount(["customerId" => $customer->id, "sepa_mandate" => ["locale" => "de-DE", "bic" => "DEUTDEFF", "iban" => "DE89370400440532013000", "accountHolderName" => "Bob Holder", "billingAddress" => ["streetAddress" => "123 Currywurst Way", "extendedAddress" => "Lager Suite", "firstName" => "Wilhelm", "lastName" => "Dix", "locality" => "Frankfurt", "postalCode" => "60001", "countryCodeAlpha2" => "DE", "region" => "Hesse"]]]);
     $transactionResult = $gateway->transaction()->sale(["customerId" => $customer->id, "paymentMethodNonce" => $nonce, "merchantAccountId" => "fake_sepa_ma", "amount" => 100]);
     $this->assertTrue($transactionResult->success);
     $collection = $gateway->transaction()->search([Braintree\TransactionSearch::customerId()->is($customer->id), Braintree\TransactionSearch::europeBankAccountIban()->is("DE89370400440532013000")]);
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($transactionResult->transaction->id, $collection->firstItem()->id);
 }
Пример #6
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);
 }