Payment retrieval operations
United States
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
.
Prerequisites
- Read overview of the Clover platform.
- Create a global developer account with a default test merchant account.
- Order a Clover Developer Kit (Dev Kit) and set it up.
- Use the required Android SDK versions.
Retrieve a payment request
Build a retrieve a payment request.
Example—Retrieve an online payment with a paymentId
request
paymentId
requestval 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
request
externalPaymentId
requestval 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);
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)
}
}
}
NOTE
To build a retrieve payment request, you must have a
paymentId
orexternalPaymentId
. Not providing one or the other results in anIllegalArgumentException
.
Retrieve pending payments
Build a retrieve open payment request.
Example—Retrieve pending payments request
val builder = RetrievePendingPaymentsRequestIntentBuilder()
val intent = builder.build(context)
RetrievePendingPaymentsRequestIntentBuilder builder = new RetrievePendingPaymentsRequestIntentBuilder();
Intent intent = builder.build(context);
Example—Retrieve 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);
}
}
}
Retrieve open payments
Build a retrieve open payment request.
Example—Retrieve open payments request
val builder = RetrieveOpenPaymentsRequestIntentBuilder()
val intent = builder.build(context)
RetrieveOpenPaymentsRequestIntentBuilder builder = new RetrieveOpenPaymentsRequestIntentBuilder();
Intent intent = builder.build(context);
Example—Retrieve open payments response
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RETRIEVE_OPEN_PAYMENTS_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
val openPayments = data?.getStringArrayListExtra(RetrieveOpenPaymentsRequestIntentBuilder.Response.PAYMENT_IDS)
} else {
// retrieve pending payments failed, check for error
val failureMessage = data?.getStringExtra(RetrieveOpenPaymentsRequestIntentBuilder.Response.FAILURE_MESSAGE)
}
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RETRIEVE_OPEN_PAYMENTS_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
List<String> openPayments = data.getStringArrayListExtra(RetrieveOpenPaymentsRequestIntentBuilder.Response.PAYMENT_IDS);
} else {
// retrieve pending payments failed, check for error
String failureMessage = data.getStringExtra(RetrieveOpenPaymentsRequestIntentBuilder.Response.FAILURE_MESSAGE);
}
}
}
Retrieve a credit
Build a retrieve credit payment request.
Example—Retrieve a credit request
val creditId = "<id of credit to retrieve>"
val builder = RetrieveCreditRequestIntentBuilder(creditId)
val intent = builder.build(context)
String creditId = "<id of credit to retrieve>";
RetrieveCreditRequestIntentBuilder builder = new RetrieveCreditRequestIntentBuilder(creditId);
Intent intent = builder.build(context);
Example—Retrieve a credit response
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RETRIEVE_CREDIT_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
val credit: Credit? = data?.getParcelableExtra(RetrieveCreditRequestIntentBuilder.Response.CREDIT)
} else {
// retrieve credit failed, check for error
val failureMessage = data?.getStringExtra(RetrieveCreditRequestIntentBuilder.Response.FAILURE_MESSAGE)
}
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RETRIEVE_CREDIT_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Credit credit = data.getParcelableExtra(RetrieveCreditRequestIntentBuilder.Response.CREDIT);
} else {
// retrieve credit failed, check for error
String failureMessage = data.getStringExtra(RetrieveCreditRequestIntentBuilder.Response.FAILURE_MESSAGE);
}
}
}
Retrieve a refund
Build a retrieve refund payment request.
Example—Retrieve a refund request
val refundId = "<id of refund to retrieve>"
val builder = RetrieveRefundRequestIntentBuilder(refundId)
val intent = builder.build(context)
String refundId = "<id of refund to retrieve>";
RetrieveRefundRequestIntentBuilder builder = new RetrieveRefundRequestIntentBuilder(refundId);
Intent intent = builder.build(context);
Example—Retrieve a refund response
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RETRIEVE_REFUND_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
val refund: Refund? = data?.getParcelableExtra(RetrieveRefundRequestIntentBuilder.Response.REFUND)
} else {
// retrieve refund failed, check for error
val failureMessage = data?.getStringExtra(RetrieveRefundRequestIntentBuilder.Response.FAILURE_MESSAGE)
}
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RETRIEVE_REFUND_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Refund refund = data.getParcelableExtra(RetrieveRefundRequestIntentBuilder.Response.REFUND);
} else {
// retrieve refund failed, check for error
String failureMessage = data.getStringExtra(RetrieveRefundRequestIntentBuilder.Response.FAILURE_MESSAGE);
}
}
}
Updated 2 months ago