Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
222 additions
and
210 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
15 changes: 0 additions & 15 deletions
15
app/src/main/java/com/kickstarter/mock/factories/CardFactory.kt
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/kickstarter/mock/factories/CardParamsFactory.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,34 @@ | ||
package com.kickstarter.mock.factories | ||
|
||
import com.stripe.android.model.CardParams | ||
import java.util.Calendar | ||
|
||
class CardParamsFactory { | ||
|
||
companion object { | ||
@JvmOverloads | ||
fun params( | ||
number: String? = "4242424242424242", | ||
expMonth: Int? = 1, | ||
expYear: Int? = 2025, | ||
cvc: String? = "555" | ||
): CardParams { | ||
return CardParams( | ||
number = number ?: "", | ||
expMonth = expMonth ?: 1, | ||
expYear = expYear ?: 2025, | ||
cvc = cvc | ||
) | ||
} | ||
|
||
fun unionPay() = params("620", 1, futureYear(), "555") | ||
|
||
fun visa() = params("424", 1, futureYear(), "555") | ||
|
||
fun unknown() = params("000", 1, futureYear(), "555") | ||
|
||
private fun futureYear(): Int { | ||
return Calendar.getInstance().get(Calendar.YEAR) + 2 | ||
} | ||
} | ||
} |
50 changes: 45 additions & 5 deletions
50
app/src/main/java/com/kickstarter/mock/factories/TokenFactory.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 |
---|---|---|
@@ -1,14 +1,54 @@ | ||
package com.kickstarter.mock.factories | ||
|
||
import com.stripe.android.model.Card | ||
import com.stripe.android.model.Token | ||
import java.util.Date | ||
import org.json.JSONObject | ||
|
||
class TokenFactory private constructor() { | ||
companion object { | ||
|
||
fun token(card: Card): Token { | ||
return Token("id", false, Date(), false, card) | ||
private val RAW_TOKEN_NO_ID = JSONObject( | ||
""" | ||
{ | ||
"object": "token", | ||
"card": { | ||
"id": "card_189fi32eZvKYlo2CHK8NPRME", | ||
"object": "card", | ||
"address_city": null, | ||
"address_country": null, | ||
"address_line1": null, | ||
"address_line1_check": null, | ||
"address_line2": null, | ||
"address_state": null, | ||
"address_zip": null, | ||
"address_zip_check": null, | ||
"brand": "Visa", | ||
"country": "US", | ||
"cvc_check": null, | ||
"dynamic_last4": null, | ||
"exp_month": 8, | ||
"exp_year": 2017, | ||
"funding": "credit", | ||
"last4": "4242", | ||
"metadata": {}, | ||
"name": null, | ||
"tokenization_method": null | ||
}, | ||
"client_ip": null, | ||
"created": 1462905355, | ||
"livemode": false, | ||
"type": "card", | ||
"used": false, | ||
"id": "btok_9xJAbronBnS9bH" | ||
} | ||
""".trimIndent() | ||
) | ||
|
||
/** | ||
* Returns a Token | ||
* @return Token | ||
* see: https://github.com/stripe/stripe-android/blob/ad426ca33105e7bc5f17c027f8146354d13f75ae/payments-core/src/test/java/com/stripe/android/model/TokenTest.kt | ||
*/ | ||
fun token(): Token { | ||
return requireNotNull(Token.fromJson(RAW_TOKEN_NO_ID)) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.