Skip to content

Commit

Permalink
1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Jul 9, 2014
0 parents commit 238f30f
Show file tree
Hide file tree
Showing 211 changed files with 12,995 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.gradle
/gradle.properties
/local.properties
/.idea
.DS_Store
.bundle
*.iml
/build
94 changes: 94 additions & 0 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
braintree-android
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.0.0-p353
100 changes: 100 additions & 0 deletions ACKNOWLEDGEMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Summary
-------

The Braintree SDK uses code from the following libraries:

* [PayPal Android SDK](https://github.com/paypal/paypal-android-sdk/)
* Google [Gson](https://code.google.com/p/google-gson/)
* Square [OkHttp](http://square.github.io/okhttp/)
* [Mockito](https://github.com/mockito/mockito)
* [Dexmaker](https://code.google.com/p/dexmaker/)
* [Espresso](https://code.google.com/p/android-test-kit/)

Full Licenses
-------------

PayPal Android SDK, BSD License
Copyright (c) 2013, PayPal
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

Google Gson, [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0)

Square OkHTTP, Apache 2.0 License
Copyright 2014 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Mockito, MIT License
The MIT License

Copyright (c) 2007 Mockito contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Dexmaker, Apache 2.0 License
Copyright (C) 2012 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Espresso, [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0)

1 change: 1 addition & 0 deletions BraintreeApi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
109 changes: 109 additions & 0 deletions BraintreeApi/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'signing'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 3
versionName "1.0.0"
}
}

dependencies {
compile 'com.google.code.gson:gson:[2.2.4,3.0)'
compile 'com.squareup.okhttp:okhttp:[1.5,2.0)'
compile 'com.braintreepayments.api:data:1.0.0'
compile files('libs/PayPalAndroidSDK.jar')

androidTestCompile project(':TestUtils')
}

task runAllTests {
/*
* Empty task to run via command line Rakefile or ci.sh to indicate that tests that depend on
* setting up external services (like the test invalid https server) are set up correctly.
* Otherwise, these tests will be skipped
*/
}

gradle.taskGraph.whenReady { taskGraph ->
def RUN_ALL_TESTS = taskGraph.hasTask(':BraintreeApi:runAllTests')
android.buildTypes.debug.buildConfigField("boolean", "RUN_ALL_TESTS", "" + RUN_ALL_TESTS)
}

/* maven deploy + signing */
task javadocs(type: Javadoc) {
source = android.sourceSets.main.java
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocsJar(type: Jar, dependsOn: javadocs) {
classifier = 'javadoc'
from javadocs.destinationDir
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java
}

artifacts {
archives javadocsJar
archives sourcesJar
}

signing {
sign configurations.archives
}

def sonatypeUsername = System.properties.containsKey("sonatypeUsername") ? System.properties["sonatypeUsername"] : ''
def sonatypePassword = System.properties.containsKey("sonatypePassword") ? System.properties["sonatypePassword"] : ''

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

pom.setArtifactId 'braintree-api'

pom.project {
name 'braintree-api'
groupId = "com.braintreepayments.api"
version = "${android.defaultConfig.versionName}"
packaging 'aar'
description "This is Braintree's v.zero SDK for Android. Integrate this library to accept payments in your Android app."
url 'https://github.com/braintree/braintree_android'

scm {
url 'scm:[email protected]:braintree/braintree_android.git'
connection 'scm:[email protected]:braintree/braintree_android.git'
developerConnection 'scm:[email protected]:braintree/braintree_android.git'
}

developers {
developer {
id 'devs'
name 'Braintree Payments'
}
}

licenses {
license {
name 'MIT'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
}
}
}
}
Binary file added BraintreeApi/libs/PayPalAndroidSDK.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.braintreepayments.api;

import android.test.AndroidTestCase;

import com.braintreepayments.api.exceptions.BraintreeException;
import com.braintreepayments.api.exceptions.ErrorWithResponse;
import com.braintreepayments.api.models.Card;
import com.braintreepayments.api.models.CardBuilder;

public class AddCardTest extends AndroidTestCase {

private BraintreeApi mBraintreeApi;

public void setUp() {
TestUtils.setUp(getContext());
mBraintreeApi = new BraintreeApi(getContext(),
new TestClientTokenBuilder().build());
}

public void testCanAddCard() throws ErrorWithResponse, BraintreeException {
CardBuilder cardBuilder = new CardBuilder()
.cardNumber("4111111111111111")
.expirationMonth("01")
.expirationYear("2017");

Card addedCard = mBraintreeApi.create(cardBuilder);

assertNotNull(addedCard.getNonce());
}

public void testCanTokenizeInvalidCard() throws ErrorWithResponse, BraintreeException {
CardBuilder cardBuilder = new CardBuilder()
.cardNumber("This is a credit card");

String nonce = mBraintreeApi.tokenize(cardBuilder);

assertNotNull(nonce);
}

public void testThrowsErrorOnServerFailure() throws BraintreeException {
CardBuilder cardBuilder = new CardBuilder()
.expirationMonth("01");

try {
mBraintreeApi.create(cardBuilder);
fail("Expected an exception");
} catch (ErrorWithResponse e) {
assertEquals(422, e.getStatusCode());
assertNotNull(e.getFieldErrors());

// @formatter:off
assertEquals("Credit card is invalid", e.getMessage());
assertEquals(1, e.getFieldErrors().size());
assertEquals(3, e.errorFor("creditCard").getFieldErrors().size());
assertEquals("Credit card must include number, payment_method_nonce, or venmo_sdk_payment_method_code", e.errorFor("creditCard").errorFor("base").getMessage());
assertEquals("Expiration year is invalid", e.errorFor("creditCard").errorFor("expirationYear").getMessage());
assertEquals("Credit card number is required", e.errorFor("creditCard").errorFor("number").getMessage());
assertNull(e.errorFor("creditCard").errorFor("expirationMonth"));
// @formatter:on
}
}
}
Loading

0 comments on commit 238f30f

Please sign in to comment.