-
Notifications
You must be signed in to change notification settings - Fork 629
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
Conversation
.idea/codestyles/Project.xml
Outdated
<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" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert
example/AndroidManifest.xml
Outdated
@@ -13,7 +13,6 @@ | |||
<application | |||
android:icon="@mipmap/ic_launcher" | |||
android:label="@string/appName" | |||
android:name=".ExampleApplication" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove hardcoded key
ed6a088
to
17d5fe5
Compare
@@ -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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StripeIntentActivity
val confirmParams = ConfirmPaymentIntentParams | ||
.createWithPaymentMethodCreateParams(params, "pi_1HekzlBte6TMTRd4ndk9lqQv_secret_gYrLPEgcRO3PMg7E1wEC1CJRC") | ||
|
||
stripe.confirmPayment(this, confirmParams) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() | ||
|
||
} |
There was a problem hiding this comment.
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.
if (!(paymentIntent.clientSecret.isNullOrBlank())) { | ||
val intent = Intent(applicationContext, UpiWaitingActivity::class.java) | ||
startActivity(intent) | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
}
stripe/src/test/java/com/stripe/android/model/PaymentMethodCreateParamsFixtures.kt
Outdated
Show resolved
Hide resolved
…-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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean @JvmStatic
?
Summary
Motivation
Testing