1

I had integrated Telr payment gateway in my android app. I referred this link https://telr.com/support/knowledge-base/mobile-sdks/ to integrate.

When i am calling the payment view for telr it is showing a blank page. This is the code i've used

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

}

Suggest me some solution

Jawad Malik
  • 608
  • 5
  • 21
Arun PK
  • 119
  • 1
  • 8

2 Answers2

0

Try this

 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;

}
0

I was working on it for 4 month ago and i had find the solution that the running face is available for just on simulator/emulator the live version is not provided from TELR.com

Screenshot

tomerpacific
  • 4,704
  • 13
  • 34
  • 52