Przejdź do głównej zawartości

SoftAcceptService (optional flow)

Notatka

This flow is optional. Merchant can check if there is a need to open WebView for handling 3DS Payments.

alt_name

This flow should be called after OCR (order create request) return WARNING_CONTINUE_3DS. Main purpose of this component is to check if user needs to additional authenticate in WebView.

This is a part of payment_library_webview_module.

Entry Point: com.payu.android.front.sdk.payment_library_webview_module.soft_accept.external.SoftAcceptService

SoftAcceptService Constructors
/**
* @param dialogBodyMessage -message on dialog that could be seen by end user - if not provided then user will see default text
* @param fragmentManager -dialog will be attached using fragmentManager
* @param authorizationDetails -start data for soft accept {@linkplain SoftAcceptTransactionData} - right now it consist of redirect link
* @param isCancelable - flag that indicate if user can cancel a dialog pressing outside of it. In this case dialog will return {@link SoftAcceptTransactionStatus#AUTHENTICATION_CANCELED}

* To retrieve resonse {@linkplain SoftAcceptTransactionStatus}: there is a need to call getParentFragmentManager().setFragmentResultListener
* Using Key: {@link SoftAcceptService#KEY_REQUEST_BUNDLE}
* Object is stored {@link SoftAcceptService#KEY_SOFT_ACCEPT_RESPONSE_DETAIL}
* Sample in Kotlin:

* supportFragmentManager.setFragmentResultListener(SoftAcceptService.KEY_REQUEST_BUNDLE, this, { _, bundle ->
* val result = bundle.getParcelable<SoftAcceptTransactionDetail>(SoftAcceptService.KEY_SOFT_ACCEPT_RESPONSE_DETAIL)
* // Do something with the result
* })
*/
public SoftAcceptService(
@Nullable String dialogBodyMessage,
@NonNull FragmentManager fragmentManager,
@NonNull AuthorizationDetails authorizationDetails,
boolean isCancelable) {
//init
}
/**
* @param childView -custom layout, that should be displayed in default layout place, only simple layout are supported
* @param fragmentManager -dialog will be attached using fragmentManager
* @param authorizationDetails -start data for soft accept {@linkplain SoftAcceptTransactionData} - right now it consist of redirect link
* @param isCancelable - flag that indicate if user can cancel a dialog pressing outside of it. In this case dialog will return {@link SoftAcceptTransactionStatus#AUTHENTICATION_CANCELED}

* To retrieve resonse {@linkplain SoftAcceptTransactionStatus}: there is a need to call getParentFragmentManager().setFragmentResultListener
* Using Key: {@link SoftAcceptService#KEY_REQUEST_BUNDLE}
* Object is stored {@link SoftAcceptService#KEY_SOFT_ACCEPT_RESPONSE_DETAIL}
* Sample in Kotlin:

*supportFragmentManager.setFragmentResultListener(SoftAcceptService.KEY_REQUEST_BUNDLE, this, { _, bundle ->
* val result = bundle.getParcelable<SoftAcceptTransactionDetail>(SoftAcceptService.KEY_SOFT_ACCEPT_RESPONSE_DETAIL)
* // Do something with the result
*})
*/

public SoftAcceptService(@LayoutRes int childView,
@NonNull FragmentManager fragmentManager,
@NonNull AuthorizationDetails authorizationDetails,
boolean isCancelable) {
//init
}

First constructor will prepare a default dialog to be displayed (with a possibility to change displayed text). This dialog could be customized via provided styles in xml property ... Second constructor will prepare custom view in dialog and merchant is responsible to pass LayoutId.

SoftAcceptService provides two additional methods:

  • public void processSoftAccept() //display dialog & check if payment doesn't need additional action from user
  • public void dismissSoftAccept() //remove dialog

When check will be finished SDK will return an object:

com.payu.android.front.sdk.payment_library_webview_module.soft_accept.external.SoftAcceptTransactionDetail in bundle in SupportFragmentManger

Retrieving Information from Dialog
fun retrieveStatusFromSoftAccept() {
supportFragmentManager.setFragmentResultListener(SoftAcceptService.KEY_REQUEST_BUNDLE, this, { _, bundle ->
val result = bundle.getParcelable<SoftAcceptTransactionDetail>(SoftAcceptService.KEY_SOFT_ACCEPT_RESPONSE_DETAIL)
Log.v("SoftAccept", "Response with: " + result?.softAcceptTransactionStatus.toString())

});
}

Additional information regarding the statuses in SoftAcceptTransactionDetail:

  • DISPLAY_FRAME - reveal the iframe if it was hidden.
  • AUTHENTICATION_SUCCESSFUL - challenge has been finished, close the iframe. Note: term SUCCESSFUL has technical sense (no errors occurred), it does not indicate the business outcome (i.e. whether the cardholder has been authenticated).
  • AUTHENTICATION_CANCELED - errors occurred, close the iframe.

You can find more information in handling iframe section.