Retrofit continue work in browser (response as html page)

314
July 08, 2017, at 4:24 PM

I'm working with a bank api. When user chooses to add his bank card to his account I need to make request to their API and then continue in browser for user to enter his card credentials in https safety

API looks like this:

@FormUrlEncoded
@POST("/jsp/hbpay/logon.jsp")
Observable<Response<String>> addCard(@Field("Signed_Order_B64") String order,
                                   @Field("email") String email,
                                   @Field("Language") String lang,
                                   @Field("BackLink") String backLink,
                                   @Field("PostLink ") String postLink,
                                   @Field("FailureBackLink") String failureBackLink);

BackLink and others are supposed to be web links to send user in different situations. I don't know what to put there for android.

Next, I have my request:

private void addCardRequest() {
    showProgress();
    mDisposable.add(createAddCardOrder()
            .flatMap(orderString -> mBankApi.addCard(orderString,
                    mDataManager.getLocalUserInfo().getEmail(),
                    BankApi.EPAY_LANG,
                    BankApi.EPAY_BACK_LINK,//"http://localhost/"?
                    BankApi.EPAY_POST_LINK,
                    BankApi.EPAY_FAILURE_BACK_LINK))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(this::handleAddCardResponse,
                    this::handleError,
                    () -> Timber.w("addCard completed")));
}

Response is a plain html page with a bunch of pics and scripts. What I'm doing for now is just saving it as a .html file and then displaying in a webview:

private void handleAddCardResponse(Response<String> response) throws Exception {
    hideProgress();
    if (response.isSuccessful()) {
        String fileUrl = getContext().getCacheDir() + "/add_card.html";
        Utils.writeStringToFile(getContext(), response.body(), fileUrl);
        startActivity(WebViewActivity.getIntent(getContext(), fileUrl));
    } else {
        throw handleUnsuccessfulResponse(response);
    }
}

What I need is to open incoming response (which is a html markup) in browser, or to make the browser make my request and handle response

Rent Charter Buses Company
READ ALSO
Installing Digits on Android today?

Installing Digits on Android today?

I'm trying to install Digits in an Android React Native project

288
Firebase Crash Reporting API/Notifications

Firebase Crash Reporting API/Notifications

I've been looking around for a while now, but haven't been able to find a way to send out notifications about Firebase crashesI have found/enabled email notifications for these crashes, but I was hoping for an API that I could use to integrate them into Slack or something...

301
How implements unread message in twilio android app?

How implements unread message in twilio android app?

In mi app I implements unread message but doesn't work properly First when i tried to get unread message it is null Image 1 This how i get the unConsumedMessage for the channel but it is null like the previous image

367
API for two player android app

API for two player android app

I want to make android app in which two players will be there both have 10 cards (not poker cards), Now my concern is, when player one select any cards, that card needs to be displayed at player 2's device something like real timeSo i want to know what is the best way to do it

322