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 GrabPay to PaymentSheet #7198

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

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

### CustomerSheet
Copy link
Collaborator

Choose a reason for hiding this comment

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

CustomerSheet less important than payment sheet?

* [ADDED] [CustomerSheet](https://stripe.com/docs/elements/customer-sheet?platform=android) is now available in private beta.

### PaymentSheet
* [ADDED][7198](https://github.com/stripe/stripe-android/pull/7198) PaymentSheet now supports GrabPay for PaymentIntents.
* [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.

### CustomerSheet
* [ADDED] [CustomerSheet](https://stripe.com/docs/elements/customer-sheet?platform=android) is now available in private beta.

## 20.28.3 - 2023-08-21

### Financial Connections
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="16dp"
android:viewportWidth="12"
android:viewportHeight="16">
<path
android:pathData="M0,8.138v-0.345C0,4.11 3.33,1 7.272,1c1.482,0 2.539,0.169 3.422,0.545v1.2c-0.849,-0.514 -1.905,-0.744 -3.422,-0.744a6.365,6.365 0,0 0,-4.368 1.731C1.738,4.828 1.069,6.31 1.069,7.792v0.346c0,1.572 0.584,3.032 1.646,4.111 1.066,1.085 2.513,1.68 4.076,1.68 2.397,0 3.62,-0.863 4.136,-1.38l0.004,-0.003V8.19h-4.4V7.12H12v5.757c-0.035,0.05 -0.436,0.596 -1.341,1.136 -1.098,0.653 -2.4,0.986 -3.868,0.986a6.723,6.723 0,0 1,-4.81 -1.99C0.703,11.723 0,9.993 0,8.138Z"
android:fillColor="#1AAE48"/>
<path
android:pathData="M10.694,3.539v1.265c-0.829,-0.682 -1.793,-0.946 -3.422,-0.946 -2.356,0 -4.346,1.802 -4.346,3.935v0.345c0,1.065 0.4,2.058 1.13,2.796a3.813,3.813 0,0 0,2.735 1.139c1.306,0 2.004,-0.278 2.34,-0.413h0.003l0.01,-0.004v-1.609H6.53V8.978h3.613v3.211c-0.232,0.23 -1.14,0.954 -3.353,0.954 -2.721,0 -4.934,-2.245 -4.934,-5.005v-0.345c0,-1.324 0.569,-2.577 1.601,-3.53a5.608,5.608 0,0 1,3.814 -1.475c1.4,0 2.455,0.232 3.422,0.751Z"
android:fillColor="#1AAE48"/>
</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 @@ -14,6 +14,7 @@
<string name="stripe_paymentsheet_payment_method_us_bank_account">US Bank Account</string>
<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_affirm">Affirm</string>
<string name="stripe_paymentsheet_payment_method_revolut_pay">Revolut Pay</string>
Expand Down
9 changes: 9 additions & 0 deletions payments-ui-core/src/main/assets/lpms.json
Original file line number Diff line number Diff line change
Expand Up @@ -820,5 +820,14 @@
"type": "us_bank_account",
"async": true,
"fields": []
},
{
"type": "grabpay",
"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"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,9 @@ internal val CashAppPayRequirement = PaymentMethodRequirements(
siRequirements = null,
confirmPMFromCustomer = false,
)

internal val GrabPayRequirement = PaymentMethodRequirements(
piRequirements = emptySet(),
siRequirements = null,
confirmPMFromCustomer = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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.GiropayRequirement
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.MandateRequirement
Expand Down Expand Up @@ -91,6 +92,7 @@ class LpmRepository constructor(
PaymentMethod.Type.AuBecsDebit.code,
PaymentMethod.Type.Upi.code,
PaymentMethod.Type.CashAppPay.code,
PaymentMethod.Type.GrabPay.code,
)
}

Expand Down Expand Up @@ -501,6 +503,18 @@ class LpmRepository constructor(
requirement = CashAppPayRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields),
)
PaymentMethod.Type.GrabPay.code -> SupportedPaymentMethod(
code = "grabpay",
requiresMandate = false,
mandateRequirement = MandateRequirement.Never,
displayNameResource = R.string.stripe_paymentsheet_payment_method_grabpay,
iconResource = R.drawable.stripe_ic_paymentsheet_pm_grabpay,
lightThemeIconUrl = sharedDataSpec.selectorIcon?.lightThemePng,
darkThemeIconUrl = sharedDataSpec.selectorIcon?.darkThemePng,
tintIconOnSelection = false,
requirement = GrabPayRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields),
)
else -> null
}

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

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

@RunWith(AndroidJUnit4::class)
internal class TestGrabPay : BaseLpmTest() {

private val grabPay = newUser.copy(
paymentMethod = lpmRepository.fromCode("grabpay")!!,
currency = Currency.SGD,
merchantCountryCode = "SG",
authorizationAction = AuthorizeAction.Authorize,
)

@Test
fun testGrabPay() {
testDriver.confirmNewOrGuestComplete(grabPay)
}

@Test
fun testGrabPayFailure() {
testDriver.confirmNewOrGuestComplete(
grabPay.copy(
authorizationAction = AuthorizeAction.Fail(
expectedError = "We are unable to authenticate your payment method. Please " +
"choose a different payment method and try again.",
),
)
)
}

@Test
fun testGrabPayInCustomFlow() {
testDriver.confirmCustom(grabPay)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ enum class Currency {
AUD,
GBP,
INR,
SGD,
}

/**
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")
country.code.value in setOf("US", "GB", "AU", "FR", "IN", "SG")
}.map { country ->
/**
* Modify this statement to change the default currency associated with each
Expand All @@ -904,6 +904,9 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
"IN" -> {
country to "INR"
}
"SG" -> {
country to "SGD"
}
else -> {
country to "USD"
}
Expand All @@ -912,7 +915,7 @@ 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")
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",
Expand Down