Skip to content

Commit

Permalink
Add support for FPX
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Aug 28, 2023
1 parent 8103aa6 commit 993908d
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 16 deletions.
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
2 changes: 2 additions & 0 deletions payments-ui-core/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<string name="stripe_continue_button_label">Continue</string>
<!-- Label for the field containing the dropdown of EPS Banks -->
<string name="stripe_eps_bank">EPS Bank</string>
<!-- Label for the field containing the dropdown of FPX Banks -->
<string name="stripe_fpx_bank">FPX Bank</string>
<!-- An error message displayed when the customer's IBAN is incomplete. -->
<string name="stripe_iban_incomplete">The IBAN you entered is incomplete.</string>
<!-- An error message displayed when the IBAN country code is not supported. -->
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/[email protected]",
"light_theme_svg": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-grabpay-97ee78fdbbf1890bdf19986e997e685d.svg"
"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/[email protected]"
}
},
{
"type": "fpx",
"async": false,
"selector_icon": {
"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/[email protected]"
},
"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_grabpay,
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
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")
}
}

0 comments on commit 993908d

Please sign in to comment.