<commit_before># BitPay Android SDK

This SDK allows your application to quickly create an invoice, show the user an option to pay you,
and track the status of the payment. Accept bitcoins in your app with 10 lines of code!

## Installing

You'll need to add this SDK as a dependency to your Android project. This process varies according
to the build system you're using.

### Gradle

If you're using Android Studio or gradle to build your app, add the following
to your `build.gradle` file:

    compile 'com.bitpay:sdk-android:0.1.1@aar'

Remember to add the maven central repository at the beginning of the file:

    repositories {
        mavenCentral()
    }


### Maven dependency

If you're using maven, add the following dependency:
```xml
<dependency>
  <groupId>com.bitpay</groupId>
  <artifactId>sdk-android</artifactId>
  <version>0.1.1</version>
  <packaging>aar</packaging>
</dependency>
```

### AAR library

A `.aar` library is provided in the `dist` folder, so you can include it in your Android proyect.

## Setup credentials

### 1. Create a Bitpay Account
Please go to https://bitpay.com to create an account.

### 2. Generate an Application Token

Go to [*My Account* > *API Tokens*](https://bitpay.com/api-tokens) section. Under *Tokens* create a new token with label `mobile` and facade `Point-of-Sale`.

Open the bin folder and excecute the pairing utility using the created token.
```bash
    $ cd bin
    $ npm install bitauth
    $ ./getClientToken <pairing code, 7 letters>
    Successfully paired. Your client token is: <KEY>
```
This token can now be used to instantiate a Bitpay client object.

## Sample Code and Usage

### Creating a BitPayClient
```java
String clientToken = "0<PASSWORD>";
new BitPayAndroid.GetBitPayClientTask() {
    @Override
    protected void onPostExecute(BitPayAndroid bitpay) {
        // ...
    }
}.execute(clientToken);
```

Inside the `onPostExecute` method, you can use all of the [BitPay Java SDK](https://github.com/unChaz/BitPayJavaClient)
(the original BitPay object is accessed through `bitpay.mBitpay`).

#### Using promises
```java
String clientToken = "0<PASSWORD>";
BitPayAndroid.getClient(clientToken).then(new BitpayPromiseCallback() {

    public void onSuccess(BitPayAndroid bitpay) {
        // ...
    }

    public void onError(BitPayException e) {
        // ...
    }
});
```

### Creating a new invoice
```java
Invoice invoice = new Invoice(200, "USD");
new BitPayAndroid.CreateInvoiceTask(bitpay) {
    @Override
    protected void onPostExecute(Invoice invoice) {
        // ...
    }
}.execute(invoice);
```

#### Using promises
```java
bitpay.createInvoice(new Invoice(200, "USD")).then(new InvoicePromiseCallback() {

    public void onSuccess(Invoice invoice) {
        // ...
    }
    public void onError(BitPayException e) {
        // ...
    }
});
```

### The InvoiceActivity class

This class helps your customer track the status of his payment, shows a QR
code and a button to send him to his wallet, so he can pay.
```java
Intent invoiceIntent = new Intent(this, InvoiceActivity.class);
invoiceIntent.putExtra(InvoiceActivity.INVOICE_ID, invoice.getId());
startActivity(invoiceIntent);
```

## More Samples and Documentation

### Sample Project
Take a look at [this project](https://github.com/eordano/bitpay-android-sample)
where an integration with a mock application is shown.

### BitPay's API docs
To read more about invoices refer to the BitPay's [API documentation](https://test.bitpay.com/downloads/bitpayApi.pdf)


## Troubleshooting

Contact support via [our official helpdesk](https://support.bitpay.com) or [ask the community](https://bitpay.com/bitpay/android-sdk/issues).

## License

Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).<commit_msg>Fixes README with last changes<commit_after># BitPay Android SDK

This SDK allows your application to quickly create an invoice, show the user an option to pay you,
and track the status of the payment. Accept bitcoins in your app with 10 lines of code!

## Installing

You'll need to add this SDK as a dependency to your Android project. This process varies according
to the build system you're using.

### Gradle

If you're using Android Studio or gradle to build your app, add the following
to your `build.gradle` file:

    compile 'com.bitpay:sdk-android:0.2.1@aar'

Additionaly, you'll have to specify these dependencies (soon to be bundled together with the sdk):

    compile 'com.google:bitcoinj:0.11.3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.3'
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
    compile 'commons-codec:commons-codec:1.9'

Remember to add the maven central repository at the beginning of the file:

    repositories {
        mavenCentral()
    }


### Maven dependency

If you're using maven, add the following dependency:
```xml
<dependency>
  <groupId>com.bitpay</groupId>
  <artifactId>sdk-android</artifactId>
  <version>0.2.1</version>
  <packaging>aar</packaging>
</dependency>
```

### AAR library

A `.aar` library is provided in the `dist` folder, so you can include it in your Android proyect.

## Setup credentials

### 1. Create a Bitpay Account
Please go to https://bitpay.com to create an account.

### 2. Generate an Application Token

Go to [*My Account* > *API Tokens*](https://bitpay.com/api-tokens) section. Click on the _Add New Token_ button and make a token with the `Point-of-Sale` capability for multiple clients. You can then include this token with your application.

Open the bin folder and excecute the pairing utility using the created token.
```bash
    $ cd bin
    $ npm install bitauth
    $ ./getClientToken <pairing code, 7 letters>
    Successfully paired. Your client token is: <KEY>
```
This token can now be used to instantiate a Bitpay client object.

## Sample Code and Usage

### Creating a BitPayClient
```java
String clientToken = "00000000000000000000000";
new BitPayAndroid.GetClientWithTokenTask() {
    @Override
    protected void onPostExecute(BitPayAndroid bitpay) {
        // ...
    }
}.execute(clientToken);
```

Inside the `onPostExecute` method, you can use all of the [BitPay Java SDK](https://github.com/unChaz/BitPayJavaClient)
(the original BitPay object is accessed through `bitpay.mBitpay`).

#### Using promises
```java
String clientToken = "00000000000000000000000";
BitPayAndroid.withToken(clientToken).then(new BitpayPromiseCallback() {

    public void onSuccess(BitPayAndroid bitpay) {
        // ...
    }

    public void onError(BitPayException e) {
        // ...
    }
});
```

### Creating a new invoice
```java
Invoice invoice = new Invoice(200, "USD");
new BitPayAndroid.CreateInvoiceTask(bitpay) {
    @Override
    protected void onPostExecute(Invoice invoice) {
        // ...
    }
}.execute(invoice);
```

#### Using promises
```java
bitpay.createInvoice(new Invoice(200, "USD")).then(new InvoicePromiseCallback() {

    public void onSuccess(Invoice invoice) {
        // ...
    }
    public void onError(BitPayException e) {
        // ...
    }
});
```

### The InvoiceActivity class

This class helps your customer track the status of his payment, shows a QR
code and a button to send him to his wallet, so he can pay.
```java
Intent invoiceIntent = new Intent(this, InvoiceActivity.class);
invoiceIntent.putExtra(InvoiceActivity.INVOICE_ID, invoice.getId());
startActivity(invoiceIntent);
```

## More Samples and Documentation

### Sample Project
Take a look at [this project](https://github.com/eordano/bitpay-android-sample)
where an integration with a mock application is shown.

### BitPay's API docs
To read more about invoices refer to the BitPay's [API documentation](https://bitpay.com/api)


## Troubleshooting

Contact support via [our official helpdesk](https://support.bitpay.com) or [ask the community](https://bitpay.com/bitpay/android-sdk/issues).

## License

Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).
{'fraction_non_alphanumeric': 0.11142680667078443, 'fraction_numerical': 0.011982705373687461, 'mean_word_length': 3.9486552567237165, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '696018', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2329, 'n_words': 843}