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 UPI Payment method support #2955

Merged
merged 10 commits into from
Oct 28, 2020
Merged

Add UPI Payment method support #2955

merged 10 commits into from
Oct 28, 2020

Conversation

anirudh-stripe
Copy link
Contributor

Summary

Motivation

Testing

<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
<package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert

@@ -13,7 +13,6 @@
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/appName"
android:name=".ExampleApplication"
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
Copy link
Collaborator

Choose a reason for hiding this comment

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

use <FrameLayout>

@@ -89,6 +89,13 @@ internal object PaymentMethodCreateParamsFixtures {
billingDetails = BILLING_DETAILS
)

internal val UPI = PaymentMethodCreateParams.create(
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove extra space

}.orEmpty()
}

class Builder : ObjectBuilder<Upi> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove Builder

)

stripe = Stripe(applicationContext, "pk_live_51H7wmsBte6TMTRd45LsWj9e3Kfkw6Kzlf5KhSrewsRydlElo8VarJxoIalKr5ielPeKf8erWZmt0qihjlwNux03y00c1zZpnxb")
// stripe = Stripe(applicationContext, "pk_test_51H7wmsBte6TMTRd4gph9Wm7gnQOKJwdVTCj30AhtB8MhWtlYj6v9xDn1vdCtKYGAE7cybr6fQdbQQtgvzBihE9cl00tOnrTpL9")
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment



class UPIPaymentActivity : AppCompatActivity() {
private lateinit var stripe: Stripe
Copy link
Collaborator

Choose a reason for hiding this comment

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

private val stripe by lazy { ... }

import com.stripe.example.databinding.UpiPaymentActivityBinding


class UPIPaymentActivity : AppCompatActivity() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename to UpiPaymentActivity

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(viewBinding.root)
stripe = Stripe(applicationContext, "pk_live_51H7wmsBte6TMTRd45LsWj9e3Kfkw6Kzlf5KhSrewsRydlElo8VarJxoIalKr5ielPeKf8erWZmt0qihjlwNux03y00c1zZpnxb")
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove hardcoded key

)
)

stripe = Stripe(applicationContext, "pk_live_51H7wmsBte6TMTRd45LsWj9e3Kfkw6Kzlf5KhSrewsRydlElo8VarJxoIalKr5ielPeKf8erWZmt0qihjlwNux03y00c1zZpnxb")
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove hardcoded key

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove android:orientation

android:layout_height="match_parent">

<TextView
android:id="@+id/paymentStatus"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@+id/payment_status


class UpiPaymentActivity : AppCompatActivity() {
private val stripe by lazy {
Stripe(applicationContext, "pk_live_51H7wmsBte6TMTRd45LsWj9e3Kfkw6Kzlf5KhSrewsRydlElo8VarJxoIalKr5ielPeKf8erWZmt0qihjlwNux03y00c1zZpnxb")
Copy link
Collaborator

Choose a reason for hiding this comment

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

StripeFactory(application).create()

upi = PaymentMethodCreateParams.Upi(
vpa = viewBinding.vpa.text.toString()
), billingDetails = PaymentMethod.BillingDetails(
name = "Anirudh Bhargava",
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Jenny Rosen"

import com.stripe.example.databinding.UpiPaymentActivityBinding


class UpiPaymentActivity : AppCompatActivity() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

StripeIntentActivity

Comment on lines 47 to 50
val confirmParams = ConfirmPaymentIntentParams
.createWithPaymentMethodCreateParams(params, "pi_1HekzlBte6TMTRd4ndk9lqQv_secret_gYrLPEgcRO3PMg7E1wEC1CJRC")

stripe.confirmPayment(this, confirmParams)
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace with

createAndConfirmPaymentIntent("in", params)

import com.stripe.example.databinding.UpiWaitingActivityBinding

class UpiWaitingActivity : AppCompatActivity() {
private lateinit var stripe: Stripe
Copy link
Collaborator

Choose a reason for hiding this comment

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

private val stripe by lazy { StripeFactory(application).create() }

}
}).start()

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can implement onResume() (similar to onCreate()) to query for the PaymentIntent whenever the activity is foregrounded.

Comment on lines 66 to 69
if (!(paymentIntent.clientSecret.isNullOrBlank())) {
val intent = Intent(applicationContext, UpiWaitingActivity::class.java)
startActivity(intent)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

                    startActivity(
                        Intent(this@UpiPaymentActivity, UpiWaitingActivity::class.java)
                            .putExtra(EXTRA_CLIENT_SECRET, paymentIntent.clientSecret)
                    )


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(viewBinding.root)
Copy link
Collaborator

Choose a reason for hiding this comment

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

add

        val clientSecret = intent.extras?.getString(EXTRA_CLIENT_SECRET)
        if (clientSecret == null) {
            finish()
            return
        }

@anirudh-stripe anirudh-stripe changed the title UPI integration Add UPI Payment method support Oct 26, 2020
@anirudh-stripe anirudh-stripe marked this pull request as ready for review October 27, 2020 02:25
…-integration

# Conflicts:
#	stripe/src/main/java/com/stripe/android/model/PaymentMethod.kt
#	stripe/src/main/java/com/stripe/android/model/PaymentMethodCreateParams.kt
#	stripe/src/main/java/com/stripe/android/model/parsers/PaymentMethodJsonParser.kt
#	stripe/src/test/java/com/stripe/android/ApiKeyFixtures.kt
#	stripe/src/test/java/com/stripe/android/model/PaymentMethodCreateParamsFixtures.kt
@@ -541,6 +570,16 @@ data class PaymentMethodCreateParams internal constructor(
return PaymentMethodCreateParams(sofort, billingDetails, metadata)
}

@JvmSynthetic
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean @JvmStatic?

@anirudh-stripe anirudh-stripe merged commit 25a092b into master Oct 28, 2020
@anirudh-stripe anirudh-stripe deleted the anirudh/upi-integration branch October 28, 2020 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants