CallbackUrlInterceptor

class CallbackUrlInterceptor @Inject constructor(credentialProvider: CredentialProvider) : <ERROR CLASS> ERROR CLASS: Symbol not found for Interceptor

Interceptor that attaches the optional X-Callback-Url header to transaction-initiation requests.

MTN MOMO supports a callback URL on the asynchronous POST operations that start a transaction — request-to-pay/withdraw, deposit, refund, transfer, cash transfer, invoice, payment, and pre-approval — to which the platform posts the result once the operation completes. It is not used by status (GET), cancel (DELETE), account/balance/user-info queries, delivery-notification POSTs, or the auth/token POSTs, so this interceptor scopes the header to the initiation endpoints by matching the request method (POST) and the final path segment.

The URL is read from CredentialProvider.getCallbackUrl on every request; when it is blank the header is omitted, making the callback opt-in (no behavior change until a URL is configured).

Parameters

credentialProvider

Supplies the configured callback URL at request time.

Constructors

Link copied to clipboard
@Inject
constructor(credentialProvider: CredentialProvider)

Functions

Link copied to clipboard
open override fun intercept(chain: ERROR CLASS: Symbol not found for Interceptor.Chain): ERROR CLASS: Symbol not found for Response

Adds the X-Callback-Url header when a callback URL is configured and the request targets a transaction-initiation endpoint; otherwise forwards the request unchanged.