android - Telr 支付集成 Android
问题描述
我在我的安卓应用程序中集成了 Telr 支付网关。我参考了此链接https://telr.com/support/knowledge-base/mobile-sdks/进行集成。
当我调用 telr 的付款视图时,它显示一个空白页。这是我用过的代码
val intent = Intent(this, WebviewActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(WebviewActivity.EXTRA_MESSAGE, getMobileRequestTelr())
intent.putExtra(
WebviewActivity.SUCCESS_ACTIVTY_CLASS_NAME,
"com.myApp.SuccessTransationActivity"
)
intent.putExtra(
WebviewActivity.FAILED_ACTIVTY_CLASS_NAME,
"com.myApp.FailedTransationActivity"
)
intent.putExtra(WebviewActivity.IS_SECURITY_ENABLED, false)
startActivity(intent)
private fun getMobileRequestTelr(): MobileRequest {
var mobile = MobileRequest()
mobile.store = TELR_STORE_ID
mobile.key = TELR_KEY
var app = App()
app.id = "123456789"
app.name = "Ahlan"
app.user = SharedPreferenceHelper(this).getString(Constants.SharedPrefs.USER_ID,"12345")
app.version = "0.0.1"
app.sdk = "123"
mobile.app = app
var tran = Tran()
tran.test = "1"
tran.type = "auth"
tran.clazz = "paypage"
tran.cartid = BigInteger(128, Random()).toString()
tran.description = "Test Mobile API"
tran.currency = "AED"
tran.amount = amountPay
tran.langauge = "en"
mobile.tran = tran
var billing = Billing()
var address = Address()
address.city = "Dubai"
address.country = "AE"
address.region = "Dubai"
address.line1 = "SIT G=Towe"
billing.address = address
var name = Name()
name.first =SharedPreferenceHelper(this).getString(Constants.SharedPrefs.USER_NAME, "")
name.last = "Sakr"
name.title = "Mr"
billing.name = name
billing.email = SharedPreferenceHelper(this).getString(Constants.SharedPrefs.USER_EMAIL, "")
billing.phone = SharedPreferenceHelper(this).getString(
Constants.SharedPrefs.USER_MOBILE, "")
mobile.billing = billing
return mobile
}
建议我一些解决方案
解决方案
尝试这个
public static void callPaymentMethod(Context context,String price) {
Intent intent = new Intent(context, WebviewActivity.class);
intent.putExtra(WebviewActivity.EXTRA_MESSAGE, Utils.getMobileRequest(context, price));
intent.putExtra(WebviewActivity.SUCCESS_ACTIVTY_CLASS_NAME, "your class name");
intent.putExtra(WebviewActivity.FAILED_ACTIVTY_CLASS_NAME, "your class name");
intent.putExtra(WebviewActivity.IS_SECURITY_ENABLED, isSecurityEnabled);
context.startActivity(intent);
}
public static MobileRequest getMobileRequest(Context context, String Price) {
MobileRequest mobile = new MobileRequest();
mobile.setStore(AppConstants.STOREID); // Store ID
mobile.setKey(AppConstants.KEY); // Authentication Key : The Authentication Key will be supplied by Telr as part of the Mobile API setup process after you request that this integration type is enabled for your account. This should not be stored permanently within the App.
App app = new App();
app.setId("123456789"); // Application installation ID
app.setName("App Name"); // Application name
app.setUser(preferences.getPreferences(context, AppConstants.userId)); // Application user ID : Your reference for the customer/user that is running the App. This should relate to their account within your systems.
app.setVersion(AppConstants.currentVersion); // Application version
mobile.setApp(app);
Tran tran = new Tran();
tran.setTest("1"); // Test mode : Test mode of zero indicates a live transaction. If this is set to any other value the transaction will be treated as a test.
tran.setType("sale"); /* Transaction type
'auth' : Seek authorisation from the card issuer for the amount specified. If authorised, the funds will be reserved but will not be debited until such time as a corresponding capture command is made. This is sometimes known as pre-authorisation.
'sale' : Immediate purchase request. This has the same effect as would be had by performing an auth transaction followed by a capture transaction for the full amount. No additional capture stage is required.
'verify' : Confirm that the card details given are valid. No funds are reserved or taken from the card.
*/
tran.setClazz("paypage"); // Transaction class only 'paypage' is allowed on mobile, which means 'use the hosted payment page to capture and process the card details'
tran.setCartid(String.valueOf(new BigInteger(128, new Random()))); //// Transaction cart ID : An example use of the cart ID field would be your own transaction or order reference.
tran.setDescription("Testing Mobile API"); // Transaction description
tran.setCurrency("AED"); // Transaction currency : Currency must be sent as a 3 character ISO code. A list of currency codes can be found at the end of this document. For voids or refunds, this must match the currency of the original transaction.
tran.setAmount(Price);
// Transaction amount : The transaction amount must be sent in major units, for example 9 dollars 50 cents must be sent as 9.50 not 950. There must be no currency symbol, and no thousands separators. Thedecimal part must be separated using a dot.
//tran.setRef(); // (Optinal) Previous transaction reference : The previous transaction reference is required for any continuous authority transaction. It must contain the reference that was supplied in the response for the original transaction.
mobile.setTran(tran);
Billing billing = new Billing();
Address address = new Address();
address.setCity(""); // City : the minimum required details for a transaction to be processed
address.setCountry(preferences.getPreferences(context, AppConstants.COUNTRY_FLAG)); // Country : Country must be sent as a 2 character ISO code. A list of country codes can be found at the end of this document. the minimum required details for a transaction to be processed
address.setRegion(""); // Region
address.setLine1(""); // Street address – line 1: the minimum required details for a transaction to be processed
//address.setLine2("SIT G=Towe"); // (Optinal)
//address.setLine3("SIT G=Towe"); // (Optinal)
//address.setZip("SIT G=Towe"); // (Optinal)
billing.setAddress(address);
Name name = new Name();
name.setFirst(preferences.getPreferences(context, AppConstants.fName)); // Forename : the minimum required details for a transaction to be processed
name.setLast(preferences.getPreferences(context, AppConstants.lName)); // Surname : the minimum required details for a transaction to be processed
name.setTitle(""); // Title
billing.setName(name);
billing.setEmail(preferences.getPreferences(context, AppConstants.emailId)); // : the minimum required details for a transaction to be processed
mobile.setBilling(billing);
return mobile;
}
推荐阅读
- asp.net - ASP.NET DataAnnotations 是否阻止将密码作为纯文本保存在内存中?
- intellij-idea - 使用节点驱动程序时,流程中的公证会因握手失败而挂起
- javascript - how do you pass the value to anchor tag on every click using jquery?
- forms - 角度 5,如何获取选定对象的 id
- google-analytics - 谷歌分析没有跟踪事件上下文中的自定义维度
- javascript - 如何在特定事件后渲染/创建 Vue 组件(例如 @click @change)
- kubernetes - Kubernetes 持久卷数据在多个 pod 删除后损坏
- html - 响应式马赛克图像作为 CSS/HTML 中的背景 - 需要边框和捕获文本
- c# - 使用 LINQ 查询 EF Core 中的复杂数据类型
- listview - Xamarin Froms:标签文本和图像在单击 Listview 的视单元内的标签时未在 UI 上更新