Skip to content

Commit

Permalink
[SMARTI-301] Actualizar flujo de cobro (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojamezquitap authored Feb 15, 2023
1 parent 140ffdc commit d20b627
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 66 deletions.
Binary file modified app/libs/nativesdk-0.1.0.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ class MainApplication : Application() {
override fun onCreate() {
super.onCreate()

val config = MPConfigBuilder(this)
val config = MPConfigBuilder(this, DEMO_APP_CLIENT_ID)
.withBluetoothConfig()
.withBluetoothUIConfig()
.build()

MPManager.initialize(this, config)
}

companion object {
private const val DEMO_APP_CLIENT_ID = "0011223344"
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.mercadolibre.android.point_mainapp_demo.app.view.payment.launcher
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mercadolibre.android.point_integration_sdk.nativesdk.payment.PaymentFlow
import com.mercadolibre.android.point_integration_sdk.nativesdk.MPManager
import com.mercadolibre.android.point_mainapp_demo.app.databinding.PointMainappDemoAppActivityPaymentLauncherBinding

/** Main activity class */
class PaymentLauncherActivity : AppCompatActivity() {

private var binding: PointMainappDemoAppActivityPaymentLauncherBinding? = null
private val paymentFlow = PaymentFlow()
private val paymentFlow = MPManager.paymentFlow

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -24,7 +24,7 @@ class PaymentLauncherActivity : AppCompatActivity() {
binding?.sendPaymentActionButton?.setOnClickListener {
val amount = binding?.amountEditText?.text?.toString()
val description = binding?.descriptionEditText?.text?.toString()
if (!amount.isNullOrEmpty() && !description.isNullOrEmpty()) {
if (!amount.isNullOrEmpty()) {
val intent = launchPaymentFlowIntent(
amount = amount,
description = description,
Expand All @@ -36,10 +36,20 @@ class PaymentLauncherActivity : AppCompatActivity() {

private fun launchPaymentFlowIntent(
amount: String,
description: String
description: String?
): Intent {
val uriSuccess = paymentFlow.buildUri("https://success", "callback_success", "{\"attr\": \"123\"}", "demo_app")
val uriError = paymentFlow.buildUri("https://error", "callback_error", "{\"attr\": \"345\"}", "demo_app")
return paymentFlow.launchPaymentFlowIntent(amount, description, uriSuccess, uriError, "123456")
val uriSuccess = paymentFlow.buildCallbackUri(
"mercadopago://launcher_native_app",
"callback_success",
hashMapOf("attr" to "123"),
"demo_app"
)
val uriError = paymentFlow.buildCallbackUri(
"mercadopago://launcher_native_app",
"callback_error",
hashMapOf("attr" to "456"),
"demo_app"
)
return paymentFlow.launchPaymentFlowIntent(amount, description, uriSuccess, uriError)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.mercadolibre.android.point_mainapp_demo.app.view.payment.result
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.gson.Gson
import androidx.core.content.ContextCompat
import com.mercadolibre.android.point_integration_sdk.nativesdk.MPManager
import com.mercadolibre.android.point_mainapp_demo.app.R
import com.mercadolibre.android.point_mainapp_demo.app.data.PaymentSuccessResponse
import com.mercadolibre.android.point_mainapp_demo.app.databinding.PointMainappDemoAppActivityPaymentResultBinding
import com.mercadolibre.android.point_mainapp_demo.app.view.home.HomeActivity

Expand All @@ -24,11 +24,20 @@ class PaymentResultActivity : AppCompatActivity() {

private fun configPaymentResult() {
intent.data?.let { data ->
val queryPaymentSuccess = data.getQueryParameter("payment_success")
queryPaymentSuccess?.let {
val paymentResult = Gson().fromJson(it, PaymentSuccessResponse::class.java)
binding?.run {
val reference = "${getString(R.string.point_mainapp_demo_app_lab_reference)}: ${paymentResult.paymentReference}"
val paymentFlowResult = MPManager.paymentFlow.parseResponse(data)
binding?.run {
if (paymentFlowResult.paymentStatusError.isEmpty()) {
val reference =
"${getString(R.string.point_mainapp_demo_app_lab_reference)}: ${paymentFlowResult.paymentReference}"
pointMainappDemoAppReferenceText.text = reference
} else {
pointMainappDemoAppTextview.text = getString(R.string.point_mainapp_demo_app_payment_error)
with(pointMainappDemoAppImageview) {
setImageResource(R.drawable.point_mainapp_demo_app_ic_error)
setColorFilter(ContextCompat.getColor(context, android.R.color.holo_red_light), android.graphics.PorterDuff.Mode.SRC_IN);
}
val reference =
"${getString(R.string.point_mainapp_demo_app_lab_error_reference)}: ${paymentFlowResult.paymentStatusError}"
pointMainappDemoAppReferenceText.text = reference
}
}
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/point_mainapp_demo_app_ic_error.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector android:height="24dp" android:viewportHeight="256"
android:viewportWidth="256" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#EC0000" android:fillType="nonZero"
android:pathData="M71.54,192.6c-2.16,0 -4.32,-0.82 -5.96,-2.47c-3.29,-3.29 -3.29,-8.63 0,-11.92l112.63,-112.63c3.29,-3.29 8.63,-3.29 11.92,0c3.29,3.29 3.29,8.63 0,11.92L77.5,190.13C75.86,191.78 73.7,192.6 71.54,192.6z"
android:strokeColor="#00000000" android:strokeLineCap="butt"
android:strokeLineJoin="miter" android:strokeWidth="2.81"/>
<path android:fillColor="#EC0000" android:fillType="nonZero"
android:pathData="M184.17,192.6c-2.16,0 -4.31,-0.82 -5.96,-2.47L65.58,77.5c-3.29,-3.29 -3.29,-8.63 0,-11.92c3.29,-3.29 8.63,-3.29 11.92,0l112.63,112.63c3.29,3.29 3.29,8.63 0,11.92C188.48,191.78 186.33,192.6 184.17,192.6z"
android:strokeColor="#00000000" android:strokeLineCap="butt"
android:strokeLineJoin="miter" android:strokeWidth="2.81"/>
<path android:fillColor="#EC0000" android:fillType="nonZero"
android:pathData="M127.86,254.31C58.13,254.31 1.41,197.58 1.41,127.86C1.41,58.13 58.13,1.41 127.86,1.41c69.72,0 126.45,56.73 126.45,126.45C254.31,197.58 197.58,254.31 127.86,254.31zM127.86,18.27C67.43,18.27 18.27,67.43 18.27,127.86s49.16,109.59 109.59,109.59s109.59,-49.16 109.59,-109.59S188.29,18.27 127.86,18.27z"
android:strokeColor="#00000000" android:strokeLineCap="butt"
android:strokeLineJoin="miter" android:strokeWidth="2.81"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:id="@+id/amountEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:inputType="numberDecimal"
android:textColor="@color/primaryTextColor" />

</com.google.android.material.textfield.TextInputLayout>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<string name="point_mainapp_demo_app_go_to_payment">Go to payment</string>
<string name="point_mainapp_demo_app_payment_success">The payment has been successful</string>
<string name="point_mainapp_demo_app_lab_reference">Reference</string>
<string name="point_mainapp_demo_app_payment_error">The payment failed</string>
<string name="point_mainapp_demo_app_lab_error_reference">Error </string>
<string name="point_mainapp_demo_app_lab_back_to_home_action">Back to home</string>

<!-- Bluetooth -->
Expand Down

0 comments on commit d20b627

Please sign in to comment.