/home/desid573/public_html/app/braintree/tests/integration
NameSizeModeActions
Error/-0755rm
Result/-0755rm
AddOnsTest.php29530644editdlrm
AddressTest.php128330644editdlrm
ApplePayTest.php25950644editdlrm
ClientTokenTest.php70160644editdlrm
CreditCardTest.php564890644editdlrm
CreditCardVerificationAdvancedSearchTest.php112090644editdlrm
CreditCardVerificationTest.php22660644editdlrm
CustomerAdvancedSearchTest.php76690644editdlrm
CustomerTest.php706950644editdlrm
DisbursementTest.php12060644editdlrm
DiscountTest.php30720644editdlrm
DisputeSearchTest.php37070644editdlrm
DisputeTest.php155170644editdlrm
DocumentUploadTest.php41850644editdlrm
GraphQLTest.php27850644editdlrm
HttpClientApi.php41700644editdlrm
HttpTest.php62380644editdlrm
IdealPaymentTest.php41410644editdlrm
MasterpassCardTest.php60220644editdlrm
MerchantAccountTest.php300400644editdlrm
MerchantTest.php101600644editdlrm
MultipleValueNodeTest.php33390644editdlrm
OAuthTest.php137320644editdlrm
PaymentMethodNonceTest.php79650644editdlrm
PaymentMethodTest.php696180644editdlrm
PaymentMethodWithUsBankAccountTest.php64830644editdlrm
PayPalAccountTest.php113000644editdlrm
PlanTest.php47570644editdlrm
SamsungPayCardTest.php87580644editdlrm
SettlementBatchSummaryTest.php34970644editdlrm
SubscriptionHelper.php24600644editdlrm
SubscriptionSearchTest.php178430644editdlrm
SubscriptionTest.php553940644editdlrm
TestTransactionTest.php28890644editdlrm
TextNodeTest.php53790644editdlrm
TransactionAdvancedSearchTest.php657420644editdlrm
TransactionLineItemTest.php14010644editdlrm
TransactionTest.php2413430644editdlrm
TransactionWithUsBankAccountTest.php118920644editdlrm
TransparentRedirectTest.php124570644editdlrm
UsBankAccountTest.php46910644editdlrm
UsBankAccountVerificationTest.php98960644editdlrm
VisaCheckoutCardTest.php70770644editdlrm
Edit: /home/desid573/public_html/app/braintree/tests/integration/PayPalAccountTest.php (11300B)
nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken ] ]); Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $nonce ]); $foundPayPalAccount = Braintree\PayPalAccount::find($paymentMethodToken); $this->assertSame('jane.doe@example.com', $foundPayPalAccount->email); $this->assertSame($paymentMethodToken, $foundPayPalAccount->token); $this->assertNotNull($foundPayPalAccount->imageUrl); } public function testGatewayFind() { $paymentMethodToken = 'PAYPALToken-' . strval(rand()); $customer = Braintree\Customer::createNoValidate(); $http = new HttpClientApi(Braintree\Configuration::$global); $nonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken ] ]); Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $nonce ]); $gateway = new Braintree\Gateway([ 'environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key' ]); $foundPayPalAccount = $gateway->paypalAccount()->find($paymentMethodToken); $this->assertSame('jane.doe@example.com', $foundPayPalAccount->email); $this->assertSame($paymentMethodToken, $foundPayPalAccount->token); $this->assertNotNull($foundPayPalAccount->imageUrl); } public function testFind_doesNotReturnIncorrectPaymentMethodType() { $creditCardToken = 'creditCardToken-' . strval(rand()); $customer = Braintree\Customer::createNoValidate(); $result = Braintree\CreditCard::create([ 'customerId' => $customer->id, 'cardholderName' => 'Cardholder', 'number' => '5105105105105100', 'expirationDate' => '05/12', 'token' => $creditCardToken ]); $this->assertTrue($result->success); $this->setExpectedException('Braintree\Exception\NotFound'); Braintree\PayPalAccount::find($creditCardToken); } public function test_PayPalAccountExposesTimestamps() { $customer = Braintree\Customer::createNoValidate(); $result = Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => Braintree\Test\Nonces::$paypalFuturePayment, ]); $this->assertTrue($result->success); $this->assertNotNull($result->paymentMethod->createdAt); $this->assertNotNull($result->paymentMethod->updatedAt); } public function test_PayPalAccountExposesBillingAgreementId() { $customer = Braintree\Customer::createNoValidate(); $result = Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => Braintree\Test\Nonces::$paypalBillingAgreement ]); $this->assertTrue($result->success); $foundPayPalAccount = Braintree\PayPalAccount::find($result->paymentMethod->token); $this->assertNotNull($foundPayPalAccount->billingAgreementId); } public function testFind_throwsIfCannotBeFound() { $this->setExpectedException('Braintree\Exception\NotFound'); Braintree\PayPalAccount::find('invalid-token'); } public function testFind_throwsUsefulErrorMessagesWhenEmpty() { $this->setExpectedException('InvalidArgumentException', 'expected paypal account id to be set'); Braintree\PayPalAccount::find(''); } public function testFind_throwsUsefulErrorMessagesWhenInvalid() { $this->setExpectedException('InvalidArgumentException', '@ is an invalid paypal account token'); Braintree\PayPalAccount::find('@'); } public function testFind_returnsSubscriptionsAssociatedWithAPaypalAccount() { $customer = Braintree\Customer::createNoValidate(); $paymentMethodToken = 'paypal-account-' . strval(rand()); $http = new HttpClientApi(Braintree\Configuration::$global); $nonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'consent-code', 'token' => $paymentMethodToken ] ]); $result = Braintree\PaymentMethod::create([ 'paymentMethodNonce' => $nonce, 'customerId' => $customer->id ]); $this->assertTrue($result->success); $token = $result->paymentMethod->token; $triallessPlan = SubscriptionHelper::triallessPlan(); $subscription1 = Braintree\Subscription::create([ 'paymentMethodToken' => $token, 'planId' => $triallessPlan['id'] ])->subscription; $subscription2 = Braintree\Subscription::create([ 'paymentMethodToken' => $token, 'planId' => $triallessPlan['id'] ])->subscription; $paypalAccount = Braintree\PayPalAccount::find($token); $getIds = function($sub) { return $sub->id; }; $subIds = array_map($getIds, $paypalAccount->subscriptions); $this->assertTrue(in_array($subscription1->id, $subIds)); $this->assertTrue(in_array($subscription2->id, $subIds)); } public function testUpdate() { $originalToken = 'ORIGINAL_PAYPALToken-' . strval(rand()); $customer = Braintree\Customer::createNoValidate(); $http = new HttpClientApi(Braintree\Configuration::$global); $nonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $originalToken ] ]); $createResult = Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $nonce ]); $this->assertTrue($createResult->success); $newToken = 'NEW_PAYPALToken-' . strval(rand()); $updateResult = Braintree\PayPalAccount::update($originalToken, [ 'token' => $newToken ]); $this->assertTrue($updateResult->success); $this->assertEquals($newToken, $updateResult->paypalAccount->token); $this->setExpectedException('Braintree\Exception\NotFound'); Braintree\PayPalAccount::find($originalToken); } public function testUpdateAndMakeDefault() { $customer = Braintree\Customer::createNoValidate(); $creditCardResult = Braintree\CreditCard::create([ 'customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/12' ]); $this->assertTrue($creditCardResult->success); $http = new HttpClientApi(Braintree\Configuration::$global); $nonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE' ] ]); $createResult = Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $nonce ]); $this->assertTrue($createResult->success); $updateResult = Braintree\PayPalAccount::update($createResult->paymentMethod->token, [ 'options' => ['makeDefault' => true] ]); $this->assertTrue($updateResult->success); $this->assertTrue($updateResult->paypalAccount->isDefault()); } public function testUpdate_handleErrors() { $customer = Braintree\Customer::createNoValidate(); $firstToken = 'FIRST_PAYPALToken-' . strval(rand()); $http = new HttpClientApi(Braintree\Configuration::$global); $firstNonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $firstToken ] ]); $firstPaypalAccount = Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $firstNonce ]); $this->assertTrue($firstPaypalAccount->success); $secondToken = 'SECOND_PAYPALToken-' . strval(rand()); $http = new HttpClientApi(Braintree\Configuration::$global); $secondNonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $secondToken ] ]); $secondPaypalAccount = Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $secondNonce ]); $this->assertTrue($secondPaypalAccount->success); $updateResult = Braintree\PayPalAccount::update($firstToken, [ 'token' => $secondToken ]); $this->assertFalse($updateResult->success); $errors = $updateResult->errors->forKey('paypalAccount')->errors; $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_TOKEN_IS_IN_USE, $errors[0]->code); } public function testDelete() { $paymentMethodToken = 'PAYPALToken-' . strval(rand()); $customer = Braintree\Customer::createNoValidate(); $http = new HttpClientApi(Braintree\Configuration::$global); $nonce = $http->nonceForPayPalAccount([ 'paypal_account' => [ 'consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $paymentMethodToken ] ]); Braintree\PaymentMethod::create([ 'customerId' => $customer->id, 'paymentMethodNonce' => $nonce ]); Braintree\PayPalAccount::delete($paymentMethodToken); $this->setExpectedException('Braintree\Exception\NotFound'); Braintree\PayPalAccount::find($paymentMethodToken); } public function testSale_createsASaleUsingGivenToken() { $nonce = Braintree\Test\Nonces::$paypalFuturePayment; $customer = Braintree\Customer::createNoValidate([ 'paymentMethodNonce' => $nonce ]); $paypalAccount = $customer->paypalAccounts[0]; $result = Braintree\PayPalAccount::sale($paypalAccount->token, [ 'amount' => '100.00' ]); $this->assertTrue($result->success); $this->assertEquals('100.00', $result->transaction->amount); $this->assertEquals($customer->id, $result->transaction->customerDetails->id); $this->assertEquals($paypalAccount->token, $result->transaction->paypalDetails->token); } }