Skip to content
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

Add support for OXXO #7281

Merged
merged 9 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## XX.XX.XX - 2023-XX-XX

### PaymentSheet

* [ADDED] PaymentSheet now supports the following payment methods for PaymentIntents:
* [7281](https://github.com/stripe/stripe-android/pull/7281) OXXO

## 20.30.1 - 2023-09-11

### Financial Connections
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="16dp"
android:viewportWidth="20"
android:viewportHeight="16">
<path
android:pathData="M0,2.81C0,2.366 0.28,2 0.623,2h18.754c0.343,0 0.623,0.365 0.623,0.81v10.38c0,0.445 -0.28,0.81 -0.623,0.81H0.623C0.28,14 0,13.635 0,13.19V2.81Z"
android:fillColor="#F0A929"
android:fillType="evenOdd"/>
<path
android:pathData="M0,4h20v8H0V4Z"
android:fillColor="#fff"
android:fillType="evenOdd"/>
<path
android:pathData="M16.943,6.227c-0.914,0 -1.66,0.754 -1.66,1.678 0,0.924 0.746,1.677 1.66,1.677 0.915,0 1.66,-0.753 1.66,-1.677s-0.745,-1.678 -1.66,-1.678ZM3.258,6.227c-0.915,0 -1.66,0.754 -1.66,1.678 0,0.924 0.745,1.677 1.66,1.677 0.914,0 1.66,-0.753 1.66,-1.677s-0.746,-1.678 -1.66,-1.678Z"
android:fillColor="#E21C2A"
android:fillType="evenOdd"/>
<path
android:pathData="M16.813,4.75c-1.537,-0.035 -2.26,0.961 -3.308,2.19l-0.99,1.158 1.567,1.894c0.373,0.583 -0.34,1.16 -0.781,0.628l-1.449,-1.746 -1.41,1.653c-0.45,0.526 -1.155,-0.062 -0.773,-0.638l1.532,-1.8 -1.004,-1.21 0.646,-0.808 1.02,1.239 0.88,-1.034c0.432,-0.508 0.873,-1.18 1.444,-1.525L0,4.751v6.548h3.317c1.537,0 2.235,-0.928 3.255,-2.18l0.963,-1.182 -1.61,-1.858c-0.386,-0.573 0.313,-1.167 0.767,-0.645L8.18,7.146 9.553,5.46c0.438,-0.537 1.155,0.035 0.787,0.62L8.85,7.916l1.03,1.186 -0.65,0.777 -1.026,-1.17 -0.856,1.055c-0.42,0.517 -0.845,1.176 -1.408,1.535h14.053L19.993,4.751h-3.18ZM5.881,7.906c0,1.46 -1.178,2.65 -2.623,2.65 -1.445,0 -2.623,-1.19 -2.623,-2.65s1.178,-2.65 2.623,-2.65c1.445,0 2.623,1.19 2.623,2.65ZM16.944,10.556c-1.445,0 -2.624,-1.19 -2.624,-2.65s1.179,-2.65 2.623,-2.65c1.445,0 2.624,1.19 2.624,2.65s-1.178,2.65 -2.623,2.65Z"
android:fillColor="#E21C2A"
android:fillType="evenOdd"/>
</vector>
1 change: 1 addition & 0 deletions payments-ui-core/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="stripe_paymentsheet_payment_method_zip">Zip</string>
<string name="stripe_paymentsheet_payment_method_blik">BLIK</string>
<string name="stripe_paymentsheet_payment_method_alipay">Alipay</string>
<string name="stripe_paymentsheet_payment_method_oxxo">OXXO</string>
<!-- <string name="paymentsheet_payment_method_item_card_number">····%1$s</string>-->

<!-- &lt;!&ndash; Label indicating the payment intent is in testmode &ndash;&gt;-->
Expand Down
18 changes: 18 additions & 0 deletions payments-ui-core/src/main/assets/lpms.json
Original file line number Diff line number Diff line change
Expand Up @@ -993,5 +993,23 @@
"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-alipay@3x-d216a94882c3c5422274faaec75a3c81.png"
},
"fields": []
},
{
"type": "oxxo",
"async": true,
"fields": [
{
"type": "name",
"api_path": {
"v1": "billing_details[name]"
}
},
{
"type": "email",
"api_path": {
"v1": "billing_details[email]"
}
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,9 @@ internal val AlipayRequirement = PaymentMethodRequirements(
siRequirements = null,
confirmPMFromCustomer = false,
)

internal val OxxoRequirement = PaymentMethodRequirements(
piRequirements = setOf(Delayed),
siRequirements = null,
confirmPMFromCustomer = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.stripe.android.paymentsheet.forms.GrabPayRequirement
import com.stripe.android.paymentsheet.forms.IdealRequirement
import com.stripe.android.paymentsheet.forms.KlarnaRequirement
import com.stripe.android.paymentsheet.forms.MobilePayRequirement
import com.stripe.android.paymentsheet.forms.OxxoRequirement
import com.stripe.android.paymentsheet.forms.P24Requirement
import com.stripe.android.paymentsheet.forms.PaymentMethodRequirements
import com.stripe.android.paymentsheet.forms.PaypalRequirement
Expand Down Expand Up @@ -72,7 +73,6 @@ class LpmRepository constructor(
private val lpmInitialFormData: LpmInitialFormData = LpmInitialFormData.Instance,
private val lpmPostConfirmData: LuxePostConfirmActionRepository = LuxePostConfirmActionRepository.Instance
) {

fun fromCode(code: PaymentMethodCode?) = lpmInitialFormData.fromCode(code)

fun values(): List<SupportedPaymentMethod> = lpmInitialFormData.values()
Expand Down Expand Up @@ -543,6 +543,17 @@ class LpmRepository constructor(
requirement = AlipayRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields),
)
PaymentMethod.Type.Oxxo.code -> SupportedPaymentMethod(
code = "oxxo",
requiresMandate = false,
displayNameResource = R.string.stripe_paymentsheet_payment_method_oxxo,
iconResource = R.drawable.stripe_ic_paymentsheet_pm_oxxo,
lightThemeIconUrl = null,
darkThemeIconUrl = null,
tintIconOnSelection = false,
requirement = OxxoRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields),
)
else -> null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
/**
* Modify this list if you want to change the countries displayed in the playground.
*/
country.code.value in setOf("US", "GB", "AU", "FR", "IN", "SG", "MY")
country.code.value in setOf("US", "GB", "AU", "FR", "IN", "SG", "MY", "MX")
}.map { country ->
/**
* Modify this statement to change the default currency associated with each
Expand Down Expand Up @@ -910,6 +910,9 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
"MY" -> {
country to "MYR"
}
"MX" -> {
country to "MXN"
}
else -> {
country to "USD"
}
Expand All @@ -918,6 +921,6 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {

// List was created from: https://stripe.com/docs/currencies
/** Modify this list if you want to change the currencies displayed in the playground **/
private val stripeSupportedCurrencies = listOf("AUD", "EUR", "GBP", "USD", "INR", "PLN", "SGD", "MYR")
private val stripeSupportedCurrencies = listOf("AUD", "EUR", "GBP", "USD", "INR", "PLN", "SGD", "MYR", "MXN")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ internal class PaymentSheetPage(
.performClick()
}

fun clickViewWithText(text: String) {
composeTestRule.onNode(hasText(text))
.performScrollTo()
.performClick()
}

fun waitForText(text: String, substring: Boolean = false) {
composeTestRule.waitUntil(timeoutMillis = 5_000) {
composeTestRule
Expand Down
49 changes: 49 additions & 0 deletions paymentsheet/src/test/resources/oxxo-support.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
lpm, hasCustomer, allowsDelayedPayment, intentSetupFutureUsage, intentHasShipping, intentLpms, supportCustomerSavedCard, formExists, formType, supportsAdding
oxxo, true, true, off_session, false, card/oxxo, false, false, not available, false
oxxo, true, true, off_session, false, card/eps/oxxo, false, false, not available, false
oxxo, true, false, off_session, false, card/oxxo, false, false, not available, false
oxxo, true, false, off_session, false, card/eps/oxxo, false, false, not available, false
oxxo, true, true, on_session, false, card/oxxo, false, false, not available, false
oxxo, true, true, on_session, false, card/eps/oxxo, false, false, not available, false
oxxo, true, false, on_session, false, card/oxxo, false, false, not available, false
oxxo, true, false, on_session, false, card/eps/oxxo, false, false, not available, false
oxxo, true, true, null, false, card/oxxo, false, true, oneTime, true
oxxo, true, true, null, false, card/eps/oxxo, false, true, oneTime, true
oxxo, true, false, null, false, card/oxxo, false, false, not available, false
oxxo, true, false, null, false, card/eps/oxxo, false, false, not available, false
oxxo, false, true, off_session, false, card/oxxo, false, false, not available, false
oxxo, false, true, off_session, false, card/eps/oxxo, false, false, not available, false
oxxo, false, false, off_session, false, card/oxxo, false, false, not available, false
oxxo, false, false, off_session, false, card/eps/oxxo, false, false, not available, false
oxxo, false, true, on_session, false, card/oxxo, false, false, not available, false
oxxo, false, true, on_session, false, card/eps/oxxo, false, false, not available, false
oxxo, false, false, on_session, false, card/oxxo, false, false, not available, false
oxxo, false, false, on_session, false, card/eps/oxxo, false, false, not available, false
oxxo, false, true, null, false, card/oxxo, false, true, oneTime, true
oxxo, false, true, null, false, card/eps/oxxo, false, true, oneTime, true
oxxo, false, false, null, false, card/oxxo, false, false, not available, false
oxxo, false, false, null, false, card/eps/oxxo, false, false, not available, false
oxxo, true, true, off_session, true, card/oxxo, false, false, not available, false
oxxo, true, true, off_session, true, card/eps/oxxo, false, false, not available, false
oxxo, true, false, off_session, true, card/oxxo, false, false, not available, false
oxxo, true, false, off_session, true, card/eps/oxxo, false, false, not available, false
oxxo, true, true, on_session, true, card/oxxo, false, false, not available, false
oxxo, true, true, on_session, true, card/eps/oxxo, false, false, not available, false
oxxo, true, false, on_session, true, card/oxxo, false, false, not available, false
oxxo, true, false, on_session, true, card/eps/oxxo, false, false, not available, false
oxxo, true, true, null, true, card/oxxo, false, true, oneTime, true
oxxo, true, true, null, true, card/eps/oxxo, false, true, oneTime, true
oxxo, true, false, null, true, card/oxxo, false, false, not available, false
oxxo, true, false, null, true, card/eps/oxxo, false, false, not available, false
oxxo, false, true, off_session, true, card/oxxo, false, false, not available, false
oxxo, false, true, off_session, true, card/eps/oxxo, false, false, not available, false
oxxo, false, false, off_session, true, card/oxxo, false, false, not available, false
oxxo, false, false, off_session, true, card/eps/oxxo, false, false, not available, false
oxxo, false, true, on_session, true, card/oxxo, false, false, not available, false
oxxo, false, true, on_session, true, card/eps/oxxo, false, false, not available, false
oxxo, false, false, on_session, true, card/oxxo, false, false, not available, false
oxxo, false, false, on_session, true, card/eps/oxxo, false, false, not available, false
oxxo, false, true, null, true, card/oxxo, false, true, oneTime, true
oxxo, false, true, null, true, card/eps/oxxo, false, true, oneTime, true
oxxo, false, false, null, true, card/oxxo, false, false, not available, false
oxxo, false, false, null, true, card/eps/oxxo, false, false, not available, false