Class StkPushRequest

java.lang.Object
io.github.openpaydev.mpesa.core.models.StkPushRequest

public final class StkPushRequest extends Object
Represents the complete request model for an M-Pesa STK Push API call.

This object is used to build a payment request. The recommended way to create an instance is by using the static helper method newPayBillRequest(String, String, String, String, String).

The MpesaClient implementation will automatically populate the server-side fields (BusinessShortCode, Password, Timestamp, etc.) before sending the request.

  • Method Details

    • newPayBillRequest

      public static StkPushRequest newPayBillRequest(String amount, String phoneNumber, String accountReference, String transactionDesc, String callBackURL)
      A convenient static factory method to create a standard PayBill STK Push request object.

      This is the recommended way to create a new STK Push request.

      Parameters:
      amount - The amount to be paid.
      phoneNumber - The customer's phone number in MSISDN format (e.g., "254712345678").
      accountReference - Your internal reference for the transaction (e.g., "invoice-123").
      transactionDesc - A short description of the payment (e.g., "Payment for shoes").
      callBackURL - Your public HTTPS callback URL for receiving the final status.
      Returns:
      A new, populated StkPushRequest instance.
    • builder

      public static StkPushRequest.StkPushRequestBuilder builder()
    • toBuilder

    • getBusinessShortCode

      public String getBusinessShortCode()
    • getPassword

      public String getPassword()
    • getTimestamp

      public String getTimestamp()
    • getTransactionType

      public String getTransactionType()
    • getAmount

      public String getAmount()
    • getPartyA

      public String getPartyA()
    • getPartyB

      public String getPartyB()
    • getPhoneNumber

      public String getPhoneNumber()
    • getCallBackURL

      public String getCallBackURL()
    • getAccountReference

      public String getAccountReference()
    • getTransactionDesc

      public String getTransactionDesc()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object