Payment retrieval operations

Use the RetrievePaymentRequestIntentBuilder class to build an Intent to start an activity to retrieve a specific online payment. This operation requires the paymentId or externalPaymentId of the payment to be retrieved.

To retrieve a list of offline pending payments, use the RetrievePendingPaymentsRequestIntentBuilder.

Retrieve a payment request 

You can build a retrieve payment request with a few lines of code.

Example—Retrieve an online payment with a paymentId

The following example shows how to retrieve an online payment with a paymentId.

val paymentId = "<ID of an online Payment>"
val builder = RetrievePaymentRequestIntentBuilder().paymentId(paymentId)
val intent = builder.build(context)
String paymentId = "<ID of an online Payment>";
RetrievePaymentRequestIntentBuilder builder = new RetrievePaymentRequestIntentBuilder().paymentId(paymentId);
Intent intent = builder.build(context);

Example—Retrieve an online payment with an externalPaymentId

The following example shows how to retrieve an online payment with an externalPaymentId.

val externalPaymentId = "<external ID of an online Payment>"
val builder = RetrievePaymentRequestIntentBuilder().externalPaymentId(externalPaymentId)
val intent = builder.build(context)
String externalPaymentId = "<external ID of an online Payment>";
RetrievePaymentRequestIntentBuilder builder = new RetrievePaymentRequestIntentBuilder().externalPaymentId(externalPaymentId);
Intent intent = builder.build(context);

📘

NOTE

To build a retrieve payment request, you must have a paymentId or externalPaymentId. Not providing one or the other results in an IllegalArgumentException.

Retrieve pending payments

You can build a retrieve pending payments request with a few lines of code.

Example—Retrieve a pending payment.

The following example shows how to retrieve a pending payment.

val builder = RetrievePendingPaymentsRequestIntentBuilder()
val intent = builder.build(context)
RetrievePendingPaymentsRequestIntentBuilder builder = new RetrievePendingPaymentsRequestIntentBuilder();
Intent intent = builder.build(context);

Response details

  • When the retrieve payment or retrieve pending payments flow completes, the response comes through onActivityResult().
  • When the retrieve payment request is successful, retrieve the Payment object with Intents.EXTRA_PAYMENT.
  • When the retrieve pending payments request is successful, retrieve the list of pending payments with Intents.EXTRA_PAYMENTS.
  • When both requests are unsuccessful, retrieve the failure message with Intents.EXTRA_FAILURE_MESSAGE.

Example—Retrieve a Payment Response

fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == RETRIEVE_PAYMENT_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                val payment: Payment = data.getParcelableExtra(Intents.EXTRA_PAYMENT)
            } else {
                // retrieve payment failed, check for error
                val failureMessage = data.getStringExtra(Intents.EXTRA_FAILURE_MESSAGE)
            }
        }
    }
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RETRIEVE_PAYMENT_REQUEST_CODE) {
      if (resultCode == RESULT_OK) {
        Payment payment  = data.getParcelableExtra(Intents.EXTRA_PAYMENT);
      } else {
        // retrieve payment failed, check for error
        String failureMessage = data.getStringExtra(Intents.EXTRA_FAILURE_MESSAGE)
      }
    }
  }

Example—Retrieve a Pending Payments Response

fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == RETRIEVE_PENDING_PAYMENTS_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                val pendingPaymentList:List<PendingPaymentEntry> = data.getSerializableExtra(Intents.EXTRA_PAYMENTS) as  
List<PendingPaymentEntry>
            } else {
                // retrieve pending payments failed, check for error
                val failureMessage = data.getStringExtra(Intents.EXTRA_FAILURE_MESSAGE)
            }
        }
    }
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RETRIEVE_PENDING_PAYMENTS_REQUEST_CODE) {
      if (resultCode == RESULT_OK) {
        List<PendingPaymentEntry> pendingPaymentList = data.getSerializableExtra(Intents.EXTRA_PAYMENTS);
      } else {
        // retrieve pending payments failed, check for error
        String failureMessage = data.getStringExtra(Intents.EXTRA_FAILURE_MESSAGE);
      }
    }
  }