Skip to content

Commit

Permalink
Merge pull request #10 from tamojuno/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
diefferson authored Jul 22, 2020
2 parents fa2a6d8 + 604b6d4 commit b5bb94d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Adicione o SDK nas dependências do seu aplicativo

```gradle
dependencies {
implementation "com.github.tamojuno:direct-checkout-android:1.0.1"
implementation "com.github.tamojuno:direct-checkout-android:1.0.2"
}
```

Expand All @@ -45,6 +45,9 @@ No arquivo Manifest adicione a permissão de acesso à internet, e seu token pú
<meta-data
android:name="br.com.juno.directcheckout.public_token"
android:value="YOUR_PUBLIC_TOKEN"/>
<meta-data
android:name="br.com.juno.directcheckout.public_token_sandbox"
android:value="YOUR_PUBLIC_TOKEN_SANDBOX"/>

...

Expand Down
7 changes: 5 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
android:name=".MyApplication">

<meta-data
android:name="br.com.juno.directcheckout.public_token"
android:value="YOUR_TOKEN_HERE"/>
android:name="br.com.juno.directcheckout.public_token"
android:value="YOUR_PUBLIC_TOKEN"/>
<meta-data
android:name="br.com.juno.directcheckout.public_token_sandbox"
android:value="YOUR_PUBLIC_TOKEN_SANDBOX"/>

<activity android:name=".MainActivity">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import br.com.juno.directcheckout.utils.Validate
import br.com.juno.directcheckout.utils.Validate.NO_INITIALIZED
import br.com.juno.directcheckout.utils.encrypt

object DirectCheckout{
object DirectCheckout{

private const val PUBLIC_TOKEN = "br.com.juno.directcheckout.public_token"
private const val PUBLIC_TOKEN_SANDBOX = "br.com.juno.directcheckout.public_token_sandbox"

@JvmStatic private lateinit var applicationContext: Context
@JvmStatic private lateinit var publicToken: String
Expand Down Expand Up @@ -190,7 +191,10 @@ object DirectCheckout{
applicationContext.packageName, PackageManager.GET_META_DATA
)
if (!::publicToken.isInitialized) {
val token = ai.metaData?.get(PUBLIC_TOKEN)
var token = ai.metaData?.get(PUBLIC_TOKEN)
if (!prodEnvironment && ai.metaData.get(PUBLIC_TOKEN_SANDBOX) is String) {
token = ai.metaData.get(PUBLIC_TOKEN_SANDBOX)
}
if (token is String) {
publicToken = token
} else {
Expand Down

0 comments on commit b5bb94d

Please sign in to comment.