Skip to content

Commit

Permalink
Add attribution for payment methods created via Google Pay token (#2739)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshafrir-stripe authored Aug 18, 2020
1 parent 47c1068 commit 8d13e36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,14 @@ data class PaymentMethodCreateParams internal constructor(
@JvmStatic
fun createFromGooglePay(googlePayPaymentData: JSONObject): PaymentMethodCreateParams {
val googlePayResult = GooglePayResult.fromJson(googlePayPaymentData)
val tokenId = requireNotNull(googlePayResult.token?.id)
val token = googlePayResult.token
val tokenId = token?.id.orEmpty()

return create(
Card.create(tokenId),
Card(
token = tokenId,
attribution = setOfNotNull(token?.card?.tokenizationMethod?.toString())
),
PaymentMethod.BillingDetails(
address = googlePayResult.address,
name = googlePayResult.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ class PaymentMethodCreateParamsTest {
GooglePayFixtures.GOOGLE_PAY_RESULT_WITH_NO_BILLING_ADDRESS)
).isEqualTo(
PaymentMethodCreateParams.create(
PaymentMethodCreateParams.Card.create("tok_1F4ACMCRMbs6FrXf6fPqLnN7"),
PaymentMethodCreateParams.Card(
token = "tok_1F4ACMCRMbs6FrXf6fPqLnN7",
attribution = setOf("GooglePay")
),
PaymentMethod.BillingDetails.Builder()
.build()
)
Expand All @@ -41,7 +44,10 @@ class PaymentMethodCreateParamsTest {
GooglePayFixtures.GOOGLE_PAY_RESULT_WITH_FULL_BILLING_ADDRESS)
).isEqualTo(
PaymentMethodCreateParams.create(
PaymentMethodCreateParams.Card.create("tok_1F4VSjBbvEcIpqUbSsbEtBap"),
PaymentMethodCreateParams.Card(
token = "tok_1F4VSjBbvEcIpqUbSsbEtBap",
attribution = setOf("GooglePay")
),
PaymentMethod.BillingDetails(
phone = "1-888-555-1234",
email = "[email protected]",
Expand Down

0 comments on commit 8d13e36

Please sign in to comment.