CollectionService

sealed interface CollectionService : CommonService

Retrofit service interface for the MTN MOMO Collection product API.

Extends CommonService with collection-specific operations: request-to-pay and request-to-withdraw.

Functions

Link copied to clipboard
@HTTP(method = "DELETE", path = "/collection/{apiVersion}/invoice/{referenceId}", hasBody = true)
abstract suspend fun cancelInvoice(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Body invoiceCancellation: InvoiceCancellation, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Cancels a pending invoice before it is paid or expires.

Link copied to clipboard
@DELETE(value = "/collection/{apiVersion}/preapproval/{referenceId}")
abstract suspend fun cancelPreApproval(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<Unit>

Cancels an active pre-approval, immediately revoking the merchant's ability to debit the payer's wallet without per-transaction consent.

Link copied to clipboard
@POST(value = "/collection/{apiVersion}/invoice")
abstract suspend fun createInvoice(@Body invoice: Invoice, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Creates a Collection invoice, prompting the Invoice.intendedPayer to pay via their wallet.

Link copied to clipboard
@POST(value = "/collection/{apiVersion}/payment")
abstract suspend fun createPayment(@Body payment: Payment, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Creates a Collection payment (V2). Poll getPaymentStatus with the same uuid as the reference ID to check the outcome.

Link copied to clipboard
@POST(value = "/collection/{apiVersion}/preapproval")
abstract suspend fun createPreApproval(@Body preApproval: PreApproval, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Creates a pre-approval, allowing the merchant to charge the PreApproval.payer's wallet without per-transaction prompts until the pre-approval expires.

Link copied to clipboard
@GET(value = "/{productType}/{apiVersion}/account/balance")
abstract suspend fun getAccountBalance(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<AccountBalance>

Makes a request to get the Account Balance. This only works with the io.rekast.sdk.utils.ProductTypes.COLLECTION. It seems to break with the other API product type.

Link copied to clipboard
@GET(value = "/{productType}/{apiVersion}/account/balance/{currency}")
abstract suspend fun getAccountBalanceInSpecificCurrency(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Path(value = "currency") currency: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<AccountBalance>

Makes a request to get the Account Balance in a specific currency. This only works with the io.rekast.sdk.utils.ProductTypes.COLLECTION. It seems to break with the other API product type. Use EUR as the currency on sandbox

Link copied to clipboard
@GET(value = "/collection/{apiVersion}/preapprovals/{accountHolderIdType}/{accountHolderId}")
abstract suspend fun getApprovedPreApprovals(@Path(value = "accountHolderIdType") accountHolderIdType: String, @Path(value = "accountHolderId") accountHolderId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<ApprovedPreApprovals>

Retrieves the list of approved pre-approvals for a given account holder.

Link copied to clipboard
@GET(value = "/{productType}/{apiVersion}/accountholder/msisdn/{accountHolderId}/basicuserinfo")
abstract suspend fun getBasicUserInfo(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Path(value = "accountHolderId") accountHolder: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<BasicUserInfo>

Makes a request to get the Basic ApiUser Info.

Link copied to clipboard
@GET(value = "/collection/{apiVersion}/invoice/{referenceId}")
abstract suspend fun getInvoiceStatus(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<InvoiceStatus>

Retrieves the current status of a previously created invoice.

Link copied to clipboard
@GET(value = "/collection/{apiVersion}/payment/{referenceId}")
abstract suspend fun getPaymentStatus(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<PaymentStatus>

Retrieves the current status of a previously created Collection payment.

Link copied to clipboard
@GET(value = "/collection/{apiVersion}/preapproval/{referenceId}")
abstract suspend fun getPreApprovalStatus(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<PreApprovalStatus>

Retrieves the current status of a previously created pre-approval.

Link copied to clipboard
@GET(value = "/{productType}/oauth2/{apiVersion}/userinfo")
abstract suspend fun getUserInfoWithConsent(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<UserInfoWithConsent>

Makes a request to get the ApiUser Info with Consent.

Link copied to clipboard
@POST(value = "/collection/{apiVersion}/requesttopay")
abstract suspend fun requestToPay(@Body requestToPay: RequestToPay, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Initiates a request-to-pay, prompting the specified payer to approve a payment.

Link copied to clipboard
@POST(value = "/{productType}/{apiVersion}/requesttopay/{referenceId}/deliverynotification")
abstract suspend fun requestToPayDeliveryNotification(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Path(value = "referenceId") referenceId: String, @Body notifications: Notifications, @Header(value = "notificationMessage") notificationMessage: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<ERROR CLASS: Symbol not found for ResponseBody>

Makes a request to send a request-to-pay delivery notification.

Link copied to clipboard
@GET(value = "/collection/{apiVersion}/requesttopay/{referenceId}")
abstract suspend fun requestToPayTransactionStatus(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<RequestToPayStatus>

Retrieves the status of a previously initiated request-to-pay transaction.

Link copied to clipboard
@POST(value = "/collection/{apiVersion}/requesttowithdraw")
abstract suspend fun requestToWithdraw(@Body requestToWithdraw: RequestToWithdraw, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Initiates a request-to-withdraw, prompting the specified payer to approve a withdrawal.

Link copied to clipboard
@GET(value = "/collection/{apiVersion}/requesttowithdraw/{referenceId}")
abstract suspend fun requestToWithdrawTransactionStatus(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<RequestToWithdrawStatus>

Retrieves the status of a previously initiated request-to-withdraw transaction.

Link copied to clipboard
@GET(value = "/{productType}/{apiVersion}/accountholder/{accountHolderIdType}/{accountHolderId}/active")
abstract suspend fun validateAccountHolderStatus(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Path(value = "accountHolderId") accountHolderId: String, @Path(value = "accountHolderIdType") accountHolderType: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<AccountHolderStatus>

Makes a request to check the account holder status.