Skip to content

Commit

Permalink
Add diffs to migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahkoop committed Oct 10, 2023
1 parent 68c8c25 commit 9bee3a3
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions v5_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ must be instantiated in the `OnCreate` method of your Activity or Fragment.
`BraintreeClient` and `VenmoClient` no longer require references to Fragment or Activity and do not
need to be instantiated in `OnCreate`.

```kotlin
```diff

class MyActivity : FragmentActivity() {

private lateinit var venmoLauncher: VenmoLauncher
+ private lateinit var venmoLauncher: VenmoLauncher
private lateinit var braintreeClient: BraintreeClient
private lateinit var venmoClient: VenmoClient

@override fun onCreate(savedInstanceState: Bundle?) {
venmoLauncher = VenmoLauncher(this) { authChallengeResult ->
- initializeClients()
+ // can initialize clients outside of onCreate if desired
+ venmoLauncher = VenmoLauncher(this) { authChallengeResult ->
venmoClient.tokenizeVenmoAccount(authChallengeResult) { venmoAccountNonce, error ->
error?.let { /* handle error */ }
venmoAccountNonce?.let { /* handle Venmo account nonce */ }
Expand All @@ -51,15 +53,26 @@ class MyActivity : FragmentActivity() {

fun initializeClients() {
braintreClient = BraintreeClient(context, "TOKENIZATION_KEY_OR_CLIENT_TOKEN")
venmoClient = VenmoClient(braintreeClient)
- venmoClient = VenmoClient(this, braintreeClient)
+ venmoClient = VenmoClient(braintreeClient)
- venmoClient.setListener(this)
}

fun onVenmoButtonClick() {
venmoClient.requestAuthChallenge(this, venmoRequest) { authChallenge, error ->
- venmoClient.tokenizeVenmoAccount(activity, request)
+ venmoClient.requestAuthChallenge(this, venmoRequest) { authChallenge, error ->
error?.let { /* handle error */ }
authChallenge?.let { venmoLauncher.launch(it) }
}
}

- override fun onVenmoSuccess(venmoAccountNonce: VenmoAccountNonce) {
// handle Venmo account nonce
}

- override fun onVenmoFailure(error: java.lang.Exception) {
// handle error
}
}
```

0 comments on commit 9bee3a3

Please sign in to comment.