transaction() public method

public transaction ( ) : TransactionGateway
return TransactionGateway
 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);
 }
Ejemplo n.º 2
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);
 }