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 FPX #7214

Merged
merged 7 commits into from
Aug 28, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### PaymentSheet
* [ADDED][7198](https://github.com/stripe/stripe-android/pull/7198) PaymentSheet now supports GrabPay for PaymentIntents.
* [ADDED][7214](https://github.com/stripe/stripe-android/pull/7214) PaymentSheet now supports FPX for PaymentIntents.
* [ADDED][7199](https://github.com/stripe/stripe-android/pull/7199) PaymentSheet now supports AmazonPay for PaymentIntents in private beta.
* [CHANGED][7144](https://github.com/stripe/stripe-android/pull/7144) PaymentSheet now features rounded corners with the radius provided in `PaymentSheet.Shapes.cornerRadiusDp`.
* [FIXED][7190](https://github.com/stripe/stripe-android/pull/7190) Fixed an issue where amounts in Laotian Kip were displayed incorrectly.
Expand Down
14 changes: 14 additions & 0 deletions payments-ui-core/res/drawable/stripe_ic_paymentsheet_pm_fpx.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="16dp"
android:viewportWidth="14"
android:viewportHeight="16">
<path
android:pathData="M13.587,6.988C12.161,5.147 10.717,3.319 9.265,1.496C9.035,1.207 8.699,0.861 8.307,1.058C8.042,1.19 7.801,1.583 7.774,1.879C7.685,2.847 7.692,3.823 7.682,4.796C7.681,4.906 7.793,5.026 7.872,5.127C8.476,5.898 9.09,6.662 9.69,7.435C9.857,7.65 9.951,7.824 9.98,7.992C9.951,8.226 9.857,8.344 9.69,8.559C9.09,9.332 8.476,10.1 7.872,10.87C7.793,10.972 7.681,11.096 7.682,11.206C7.692,12.179 7.685,13.155 7.774,14.123C7.801,14.418 8.042,14.811 8.307,14.943C8.699,15.139 9.035,14.791 9.265,14.502C10.717,12.679 12.161,10.846 13.587,9.006C13.84,8.679 13.975,8.46 14,7.992C13.975,7.652 13.84,7.315 13.587,6.988Z"
android:fillColor="#1F2C5C"
android:fillType="evenOdd" />
<path
android:pathData="M0.413,6.988C1.839,5.147 3.283,3.319 4.735,1.496C4.965,1.207 5.301,0.861 5.693,1.058C5.958,1.19 6.199,1.583 6.226,1.879C6.315,2.847 6.308,3.823 6.318,4.796C6.319,4.906 6.207,5.026 6.128,5.127C5.524,5.898 4.91,6.662 4.31,7.435C4.143,7.65 4.049,7.824 4.02,7.992C4.049,8.226 4.143,8.344 4.31,8.559C4.91,9.332 5.524,10.1 6.128,10.87C6.207,10.972 6.319,11.096 6.318,11.206C6.308,12.179 6.315,13.155 6.226,14.123C6.199,14.418 5.958,14.811 5.693,14.943C5.301,15.139 4.965,14.791 4.735,14.502C3.283,12.679 1.839,10.846 0.413,9.006C0.159,8.679 0.025,8.46 0,7.992C0.025,7.652 0.159,7.315 0.413,6.988Z"
android:fillColor="#1A8ACB"
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 @@ -15,6 +15,7 @@
<string name="stripe_paymentsheet_payment_method_upi">UPI</string>
<string name="stripe_paymentsheet_payment_method_cashapp">Cash App Pay</string>
<string name="stripe_paymentsheet_payment_method_grabpay">GrabPay</string>
<string name="stripe_paymentsheet_payment_method_fpx">FPX Bank</string>

<string name="stripe_paymentsheet_payment_method_affirm">Affirm</string>
<string name="stripe_paymentsheet_payment_method_revolut_pay">Revolut Pay</string>
Expand Down
112 changes: 110 additions & 2 deletions payments-ui-core/src/main/assets/lpms.json
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,116 @@
"async": false,
"fields": [],
"selector_icon": {
"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-grabpay@3x-e54da1d788668a5909e4801d5c243198.png",
"light_theme_svg": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-grabpay-97ee78fdbbf1890bdf19986e997e685d.svg"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the SVG because we don’t use them.

"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-grabpay@3x-e54da1d788668a5909e4801d5c243198.png"
}
},
{
"type": "fpx",
"async": false,
"selector_icon": {
"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-fpx@3x-305453711338125d9cb4f86ff866ba6a.png"
},
"fields": [
{
"type": "selector",
"translation_id": "upe.labels.fpx.bank",
"items": [
{
"display_text": "Affin Bank",
"api_value": "affin_bank"
},
{
"display_text": "Alliance Bank",
"api_value": "alliance_bank"
},
{
"display_text": "AmBank",
"api_value": "ambank"
},
{
"display_text": "Bank Islam",
"api_value": "bank_islam"
},
{
"display_text": "Bank Muamalat",
"api_value": "bank_muamalat"
},
{
"display_text": "Bank Rakyat",
"api_value": "bank_rakyat"
},
{
"display_text": "BSN",
"api_value": "bsn"
},
{
"display_text": "CIMB Clicks",
"api_value": "cimb"
},
{
"display_text": "Hong Leong Bank",
"api_value": "hong_leong_bank"
},
{
"display_text": "HSBC BANK",
"api_value": "hsbc"
},
{
"display_text": "KFH",
"api_value": "kfh"
},
{
"display_text": "Maybank2E",
"api_value": "maybank2e"
},
{
"display_text": "Maybank2U",
"api_value": "maybank2u"
},
{
"display_text": "OCBC Bank",
"api_value": "ocbc"
},
{
"display_text": "Public Bank",
"api_value": "public_bank"
},
{
"display_text": "RHB Bank",
"api_value": "rhb"
},
{
"display_text": "Standard Chartered",
"api_value": "standard_chartered"
},
{
"display_text": "UOB Bank",
"api_value": "uob"
}
],
"api_path": {
"v1": "fpx[bank]"
}
},
{
"type": "placeholder",
"for": "billing_address"
}
],
"next_action_spec": {
"confirm_response_status_specs": {
"requires_action": {
"type": "redirect_to_url"
}
},
"post_confirm_handling_pi_status_specs": {
"succeeded": {
"type": "finished"
},
"requires_action": {
"type": "canceled"
}
}
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,9 @@ internal val GrabPayRequirement = PaymentMethodRequirements(
siRequirements = null,
confirmPMFromCustomer = false,
)

internal val FpxRequirement = PaymentMethodRequirements(
piRequirements = emptySet(),
siRequirements = null,
confirmPMFromCustomer = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ enum class TranslationId(val resourceId: Int) {
@SerialName("upe.labels.eps.bank")
EpsBank(R.string.stripe_eps_bank),

@SerialName("upe.labels.fpx.bank")
FpxBank(R.string.stripe_fpx_bank),

@SerialName("address.label.name")
AddressName(CoreR.string.stripe_address_label_full_name),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.stripe.android.paymentsheet.forms.BancontactRequirement
import com.stripe.android.paymentsheet.forms.CardRequirement
import com.stripe.android.paymentsheet.forms.CashAppPayRequirement
import com.stripe.android.paymentsheet.forms.EpsRequirement
import com.stripe.android.paymentsheet.forms.FpxRequirement
import com.stripe.android.paymentsheet.forms.GiropayRequirement
import com.stripe.android.paymentsheet.forms.GrabPayRequirement
import com.stripe.android.paymentsheet.forms.IdealRequirement
Expand Down Expand Up @@ -95,6 +96,7 @@ class LpmRepository constructor(
PaymentMethod.Type.Upi.code,
PaymentMethod.Type.CashAppPay.code,
PaymentMethod.Type.GrabPay.code,
PaymentMethod.Type.Fpx.code,
)
}

Expand Down Expand Up @@ -529,6 +531,18 @@ class LpmRepository constructor(
requirement = GrabPayRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields),
)
PaymentMethod.Type.Fpx.code -> SupportedPaymentMethod(
code = "fpx",
requiresMandate = false,
mandateRequirement = MandateRequirement.Never,
displayNameResource = R.string.stripe_paymentsheet_payment_method_fpx,
iconResource = R.drawable.stripe_ic_paymentsheet_pm_fpx,
lightThemeIconUrl = sharedDataSpec.selectorIcon?.lightThemePng,
darkThemeIconUrl = sharedDataSpec.selectorIcon?.darkThemePng,
tintIconOnSelection = false,
requirement = FpxRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields),
)
else -> null
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.stripe.android.lpm

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.stripe.android.BaseLpmTest
import com.stripe.android.test.core.Automatic
import com.stripe.android.test.core.Currency
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
internal class TestFpx : BaseLpmTest() {
private val fpx = newUser.copy(
paymentMethod = lpmRepository.fromCode("fpx")!!,
currency = Currency.MYR,
merchantCountryCode = "MY",
automatic = Automatic.On,
)

@Test
fun testFpx() {
testDriver.confirmNewOrGuestComplete(
testParameters = fpx,
)
}

@Test
fun testFpxInCustomFlow() {
testDriver.confirmCustom(
testParameters = fpx,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ enum class Currency {
GBP,
INR,
SGD,
MYR,
}

/**
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")
country.code.value in setOf("US", "GB", "AU", "FR", "IN", "SG", "MY")
}.map { country ->
/**
* Modify this statement to change the default currency associated with each
Expand All @@ -907,6 +907,9 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
"SG" -> {
country to "SGD"
}
"MY" -> {
country to "MYR"
}
else -> {
country to "USD"
}
Expand All @@ -915,18 +918,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")
// "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AWG", "AZN", "BAM",
// "BBD", "BDT", "BGN", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BWP", "BYN", "BZD",
// "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CVE", "CZK", "DJF", "DKK", "DOP",
// "DZD", "EGP", "ETB", "FJD", "FKP", "GEL", "GIP", "GMD", "GNF", "GTQ",
// "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "ISK", "JMD", "JPY",
// "KES", "KGS", "KHR", "KMF", "KRW", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL",
// "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN",
// "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "PAB", "PEN", "PGK", "PHP",
// "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SEK",
// "SGD", "SHP", "SLL", "SOS", "SRD", "STD", "SZL", "THB", "TJS", "TOP", "TRY", "TTD",
// "TWD", "TZS", "UAH", "UGX", "UYU", "UZS", "VND", "VUV", "WST", "XAF", "XCD", "XOF",
// "XPF", "YER", "ZAR", "ZMW"
private val stripeSupportedCurrencies = listOf("AUD", "EUR", "GBP", "USD", "INR", "PLN", "SGD", "MYR")
}
}
49 changes: 49 additions & 0 deletions paymentsheet/src/test/resources/fpx-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
fpx, true, true, off_session, false, card/fpx, false, false, not available, false
fpx, true, true, off_session, false, card/eps/fpx, false, false, not available, false
fpx, true, false, off_session, false, card/fpx, false, false, not available, false
fpx, true, false, off_session, false, card/eps/fpx, false, false, not available, false
fpx, true, true, on_session, false, card/fpx, false, false, not available, false
fpx, true, true, on_session, false, card/eps/fpx, false, false, not available, false
fpx, true, false, on_session, false, card/fpx, false, false, not available, false
fpx, true, false, on_session, false, card/eps/fpx, false, false, not available, false
fpx, true, true, null, false, card/fpx, false, true, oneTime, true
fpx, true, true, null, false, card/eps/fpx, false, true, oneTime, true
fpx, true, false, null, false, card/fpx, false, true, oneTime, true
fpx, true, false, null, false, card/eps/fpx, false, true, oneTime, true
fpx, false, true, off_session, false, card/fpx, false, false, not available, false
fpx, false, true, off_session, false, card/eps/fpx, false, false, not available, false
fpx, false, false, off_session, false, card/fpx, false, false, not available, false
fpx, false, false, off_session, false, card/eps/fpx, false, false, not available, false
fpx, false, true, on_session, false, card/fpx, false, false, not available, false
fpx, false, true, on_session, false, card/eps/fpx, false, false, not available, false
fpx, false, false, on_session, false, card/fpx, false, false, not available, false
fpx, false, false, on_session, false, card/eps/fpx, false, false, not available, false
fpx, false, true, null, false, card/fpx, false, true, oneTime, true
fpx, false, true, null, false, card/eps/fpx, false, true, oneTime, true
fpx, false, false, null, false, card/fpx, false, true, oneTime, true
fpx, false, false, null, false, card/eps/fpx, false, true, oneTime, true
fpx, true, true, off_session, true, card/fpx, false, false, not available, false
fpx, true, true, off_session, true, card/eps/fpx, false, false, not available, false
fpx, true, false, off_session, true, card/fpx, false, false, not available, false
fpx, true, false, off_session, true, card/eps/fpx, false, false, not available, false
fpx, true, true, on_session, true, card/fpx, false, false, not available, false
fpx, true, true, on_session, true, card/eps/fpx, false, false, not available, false
fpx, true, false, on_session, true, card/fpx, false, false, not available, false
fpx, true, false, on_session, true, card/eps/fpx, false, false, not available, false
fpx, true, true, null, true, card/fpx, false, true, oneTime, true
fpx, true, true, null, true, card/eps/fpx, false, true, oneTime, true
fpx, true, false, null, true, card/fpx, false, true, oneTime, true
fpx, true, false, null, true, card/eps/fpx, false, true, oneTime, true
fpx, false, true, off_session, true, card/fpx, false, false, not available, false
fpx, false, true, off_session, true, card/eps/fpx, false, false, not available, false
fpx, false, false, off_session, true, card/fpx, false, false, not available, false
fpx, false, false, off_session, true, card/eps/fpx, false, false, not available, false
fpx, false, true, on_session, true, card/fpx, false, false, not available, false
fpx, false, true, on_session, true, card/eps/fpx, false, false, not available, false
fpx, false, false, on_session, true, card/fpx, false, false, not available, false
fpx, false, false, on_session, true, card/eps/fpx, false, false, not available, false
fpx, false, true, null, true, card/fpx, false, true, oneTime, true
fpx, false, true, null, true, card/eps/fpx, false, true, oneTime, true
fpx, false, false, null, true, card/fpx, false, true, oneTime, true
fpx, false, false, null, true, card/eps/fpx, false, true, oneTime, true
3 changes: 3 additions & 0 deletions scripts/lokalise/lokalise_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def create_key(key_object)
{
"key_name": {
"android": key_object[:key_name],
"ios": key_object[:key_name],
"web": key_object[:key_name],
"other": key_object[:key_name],
Comment on lines +34 to +36
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this in the initial Lokalise work: When we create a new key, Lokalise seems to expect values for all platforms.

},
"platforms": ["android"],
"filenames": {
Expand Down