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

Adding GrabPay PaymentMethod support #2715

Merged
merged 3 commits into from
Aug 14, 2020
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
15 changes: 15 additions & 0 deletions example/res/drawable/ic_brandicon_grabpay.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="38.45dp"
android:height="24dp"
android:viewportWidth="38.45"
android:viewportHeight="24">
<path
android:pathData="M36.62,24H1.83C0.82,24 0,23.18 0,22.17V1.83C0,0.82 0.82,0 1.83,0h34.79c1.01,0 1.83,0.82 1.83,1.83v20.34C38.45,23.18 37.63,24 36.62,24z"
android:fillColor="#00B14F"/>
<path
android:pathData="M12.81,11.78v0.37c0,1.98 0.75,3.83 2.12,5.2c1.36,1.37 3.19,2.13 5.14,2.13c1.57,0 2.96,-0.35 4.13,-1.05c0.97,-0.58 1.4,-1.16 1.43,-1.21v-6.15h-5.84v1.14h4.7v4.65l0,0c-0.55,0.55 -1.86,1.47 -4.42,1.47c-1.67,0 -3.22,-0.64 -4.36,-1.8c-1.14,-1.15 -1.76,-2.71 -1.76,-4.39v-0.37c0,-1.59 0.71,-3.17 1.96,-4.34c1.27,-1.19 2.93,-1.85 4.67,-1.85c1.62,0 2.75,0.25 3.66,0.79V5.11c-0.94,-0.4 -2.07,-0.58 -3.66,-0.58C16.37,4.52 12.81,7.85 12.81,11.78"
android:fillColor="#FFFFFF"/>
<path
android:pathData="M24.24,8.59V7.24c-1.03,-0.55 -2.16,-0.8 -3.66,-0.8c-1.53,0 -2.97,0.56 -4.07,1.58c-1.1,1.02 -1.71,2.36 -1.71,3.77v0.37c0,2.95 2.36,5.35 5.27,5.35c2.36,0 3.34,-0.77 3.58,-1.02v-3.43h-3.86v1.14h2.79v1.72l-0.01,0c-0.36,0.14 -1.11,0.44 -2.5,0.44c-1.11,0 -2.15,-0.43 -2.92,-1.22c-0.78,-0.79 -1.21,-1.85 -1.21,-2.99v-0.37c0,-2.28 2.13,-4.2 4.64,-4.2C22.33,7.58 23.36,7.86 24.24,8.59"
android:fillColor="#FFFFFF"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class SimplePaymentMethodConfirmationActivity : StripeIntentActivity() {
Giropay(
"de", R.drawable.ic_brandicon__giropay,
PaymentMethodCreateParams.Companion::createGiropay
),
GrabPay(
"sg", R.drawable.ic_brandicon_grabpay,
PaymentMethodCreateParams.Companion::createGrabPay
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ data class PaymentMethod internal constructor(
Giropay("giropay", isReusable = false),
Eps("eps", isReusable = false),
Oxxo("oxxo", isReusable = false),
Alipay("alipay", isReusable = false);
Alipay("alipay", isReusable = false),
GrabPay("grabpay", isReusable = false);

override fun toString(): String {
return code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ data class PaymentMethodCreateParams internal constructor(
Giropay("giropay"),
Eps("eps"),
Oxxo("oxxo"),
Alipay("alipay")
Alipay("alipay"),
GrabPay("grabpay"),
}

@Parcelize
Expand Down Expand Up @@ -534,6 +535,22 @@ data class PaymentMethodCreateParams internal constructor(
)
}

/**
* @return params for creating a [PaymentMethod.Type.GrabPay] payment method
*/
@JvmStatic
@JvmOverloads
fun createGrabPay(
billingDetails: PaymentMethod.BillingDetails,
metadata: Map<String, String>? = null
): PaymentMethodCreateParams {
return PaymentMethodCreateParams(
type = Type.GrabPay,
billingDetails = billingDetails,
metadata = metadata
)
}

/**
* @return params for creating a [PaymentMethod.Type.Eps] payment method
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ internal object ApiKeyFixtures {
const val OXXO_PUBLISHABLE_KEY = "pk_test_bjqpeDIsfh4Bnwok0rtnrS7200PY7PLRfb"
const val ALIPAY_PUBLISHABLE_KEY = "pk_test_vOo1umqsYxSrP5UXfOeL3ecm"
const val CB_PUBLISHABLE_KEY = "pk_test_51Gsr5VLtxFHECmaoeyWTxRKLZZiks5QKbg5H0IeGd8yt7OzQhA7807thLrHayMOeDRmJv3ara1VYy6AvBXAnUGcB00QAZheC0Z"
const val GRABPAY_PUBLISHABLE_KEY = "pk_test_TP0eh0buhedbg787icFUy83H00i9fh4Auj"
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,20 @@ class PaymentMethodEndToEndTest {
assertThat(paymentMethod?.type)
.isEqualTo(PaymentMethod.Type.Alipay)
}

@Test
fun createPaymentMethod_withGrabPay_shouldCreateObject() {
val repository = StripeApiRepository(
context,
ApiKeyFixtures.GRABPAY_PUBLISHABLE_KEY
)

val params = PaymentMethodCreateParamsFixtures.GRABPAY
val paymentMethod = repository.createPaymentMethod(
params,
ApiRequest.Options(ApiKeyFixtures.GRABPAY_PUBLISHABLE_KEY)
)
assertThat(paymentMethod?.type)
.isEqualTo(PaymentMethod.Type.GrabPay)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ internal object PaymentMethodCreateParamsFixtures {
billingDetails = BILLING_DETAILS
)

internal val GRABPAY = PaymentMethodCreateParams.createGrabPay(
billingDetails = BILLING_DETAILS
)

@JvmStatic
fun createWith(metadata: Map<String, String>): PaymentMethodCreateParams {
return PaymentMethodCreateParams.create(
Expand Down