paymentMethod() public method

public paymentMethod ( ) : PaymentMethodGateway
return PaymentMethodGateway
コード例 #1
0
 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");
 }
コード例 #2
0
 public function testGatewayCreate_fromVaultedCreditCardNonce()
 {
     $customer = Braintree\Customer::createNoValidate();
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonce_for_new_card(array('credit_card' => array('number' => '4111111111111111', 'expirationMonth' => '11', 'expirationYear' => '2099'), 'share' => true));
     $gateway = new Braintree\Gateway(array('environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key'));
     $result = $gateway->paymentMethod()->create(array('customerId' => $customer->id, 'paymentMethodNonce' => $nonce));
     $this->assertSame('411111', $result->paymentMethod->bin);
     $this->assertSame('1111', $result->paymentMethod->last4);
     $this->assertNotNull($result->paymentMethod->token);
     $this->assertNotNull($result->paymentMethod->imageUrl);
     $this->assertSame($customer->id, $result->paymentMethod->customerId);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 public function testBillingPostalCodeIsReturnedWhenRequestedOnTransactionsCreatedViaNonceGranting()
 {
     $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', 'billingAddress' => ['firstName' => 'Adam', 'lastName' => 'Davis', 'postalCode' => '95131']])->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, ['allow_vaulting' => false, 'include_billing_postal_code' => true]);
     $result = Braintree\Transaction::sale(['amount' => '100.00', 'paymentMethodNonce' => $grantResult->paymentMethodNonce->nonce]);
     $this->assertEquals($result->transaction->billing["postalCode"], "95131");
 }