-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Sunbit on PaymentSheet #8595
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a3faa86
Integrate Sunbit on PaymentSheet
egeniesse-stripe 2455f36
Fix lint and PR feedback
egeniesse-stripe 97ac925
Fix screenshot test and lint
egeniesse-stripe 50340ae
Re-enable the test
egeniesse-stripe e648287
Remove unused import
egeniesse-stripe dd29547
update the screenshot tests to freeze the payment method list
egeniesse-stripe 99974f4
Fix lint
egeniesse-stripe ef58bf7
ensure amazon pay is ordered before Klarna
egeniesse-stripe 66872b1
Merge branch 'master' into egeniesse/add-sunbit-payment-method
egeniesse-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
90 changes: 90 additions & 0 deletions
90
example/src/main/java/com/stripe/example/activity/SunbitActivity.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,90 @@ | ||
package com.stripe.example.activity | ||
|
||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.CircularProgressIndicator | ||
import androidx.compose.material.Divider | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.livedata.observeAsState | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.google.accompanist.themeadapter.material.MdcTheme | ||
import com.stripe.android.model.PaymentMethod | ||
import com.stripe.android.model.PaymentMethodCreateParams | ||
|
||
class SunbitActivity : StripeIntentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
val isProcessing by viewModel.inProgress.observeAsState(initial = false) | ||
val status by viewModel.status.observeAsState(initial = "") | ||
|
||
SunbitPayScreen( | ||
isProcessing = isProcessing, | ||
status = status, | ||
onButtonPressed = { payWithSunbit() } | ||
) | ||
} | ||
} | ||
|
||
private fun payWithSunbit() { | ||
val params = PaymentMethodCreateParams.createSunbit() | ||
createAndConfirmPaymentIntent( | ||
country = "US", | ||
paymentMethodCreateParams = params, | ||
supportedPaymentMethods = PaymentMethod.Type.Sunbit.code, | ||
currency = "USD", | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SunbitPayScreen( | ||
isProcessing: Boolean, | ||
status: String, | ||
onButtonPressed: () -> Unit | ||
) { | ||
MdcTheme { | ||
Column(modifier = Modifier.fillMaxSize()) { | ||
Row(verticalAlignment = Alignment.CenterVertically) { | ||
Button( | ||
onClick = onButtonPressed, | ||
enabled = !isProcessing, | ||
modifier = Modifier.padding(16.dp) | ||
) { | ||
Text("Pay with Sunbit") | ||
} | ||
|
||
if (isProcessing) { | ||
CircularProgressIndicator(modifier = Modifier.size(24.dp)) | ||
} | ||
} | ||
|
||
if (status.isNotBlank()) { | ||
Divider( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp), | ||
) | ||
|
||
Text( | ||
text = status, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you know why this is showing the fully qualified type name here (
PaymentMethod.Type.Sunbit
)? Can it showSunbit
instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time of this comment, we didn't have a
Sunbit
method. I added it in here (and piped it through in a few places), but I'm not sure if we get much value out of it.Here's the commit, let me know if you think we should take this approach for the other payment methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm agreed that it doesn't seem like we get much value out of it and it looks like we didn't do this for Multibanco or Amazon Pay, so I don't think we need it here either or for the other payment methods. Sorry for the churn!