-
Notifications
You must be signed in to change notification settings - Fork 992
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Only showing edit profile and payment methods on debug builds. * Updated Stripe library. Updated strings. First pass of new card screen. Does basic card validation. * Moved add new card form to fragment. Added focus listeners and text watchers to properly disable and enable save button * added todo * Added mutation and Stripe object to config. * Successfully adding cards woohoo. * merging in settings-v3 and adding fake stripe keys * moved mutation * checkstyle and refactored payment method row because it was breaking AS and it was easier to just do it as a LinearLayout * starting NewCardActivity for result and fixing import * actually starting NewCardActivity for result * some more refactoring and refreshing list after card is saved * Added MockStripe and CardFactory for testing. Finished tests. * cleanup, bizarre error handling and actually emitting something after saving the card * PR feedback from Rashad
- Loading branch information
Showing
35 changed files
with
905 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/kickstarter/mock/factories/CardFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.kickstarter.mock.factories | ||
|
||
import com.stripe.android.model.Card | ||
|
||
class CardFactory { | ||
|
||
companion object { | ||
@JvmOverloads | ||
fun card(number: String? = "4242424242424242", expMonth: Int? = 1, expYear: Int? = 2025, cvc: String? = "555"): Card { | ||
return Card.Builder(number, expMonth, expYear, cvc) | ||
.id("3") | ||
.build() | ||
} | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
app/src/main/java/com/kickstarter/mock/services/MockApolloClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/kickstarter/mock/services/MockStripe.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.kickstarter.mock.services | ||
|
||
import android.content.Context | ||
import android.support.annotation.NonNull | ||
import com.kickstarter.mock.factories.CardFactory | ||
import com.stripe.android.Stripe | ||
import com.stripe.android.TokenCallback | ||
import com.stripe.android.model.Card | ||
import com.stripe.android.model.Token | ||
import java.util.* | ||
|
||
class MockStripe(@NonNull val context: Context, private val withErrors: Boolean) : Stripe(context) { | ||
override fun createToken(card: Card, callback: TokenCallback) { | ||
when { | ||
this.withErrors -> callback.onError(Exception("Stripe error")) | ||
else -> callback.onSuccess(Token("25", false, Date(), false, CardFactory.card())) | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/kickstarter/services/ApolloClientType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/kickstarter/ui/activities/NewCardActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.kickstarter.ui.activities | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import com.kickstarter.R | ||
import com.kickstarter.libs.BaseActivity | ||
import com.kickstarter.libs.qualifiers.RequiresActivityViewModel | ||
import com.kickstarter.ui.fragments.NewCardFragment | ||
import com.kickstarter.viewmodels.NewCardViewModel | ||
|
||
@RequiresActivityViewModel(NewCardViewModel.ViewModel::class) | ||
class NewCardActivity : BaseActivity<NewCardViewModel.ViewModel>(), NewCardFragment.OnCardSavedListener { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_new_card) | ||
} | ||
|
||
override fun cardSaved() { | ||
setResult(Activity.RESULT_OK) | ||
finish() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.