Please let me work for you!

I will surely give you a great offer now!

Dear Sir/Madam,

My name is Brian Mbiki and I created this platform with products to help you:

1. Start a Payment processing gateway.

2. Integrate Mpesa with any website or Mobile App.

3. Add any form of Payment gateway to your website or Mobile App.

I am willing to cut down all my costs now.

Just write to me via WhatsApp +254706745202 and I will surely surprise you with  a great offer.

 

x

× This category encapsulates all discussions, tutorials and answers about Mpesa Express APIs integration | Mpesa Express APIs integration | STK push | STK push integration in PHP

Lipa na Mpesa Online Sandbox Test

More
1 month 1 week ago #332 by AM
I keep getting the below error while testing STK push on the sandbox platform. What could be the issue?

{
"requestId": "10813-938234-2",
"errorCode": "500.001.1001",
"errorMessage": "Request failed: Output data invalid"
}

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #333 by Sir Brian M. W
Replied by Sir Brian M. W on topic Lipa na Mpesa Online Sandbox Test
Hi Alex,
We need to see your code inside your action file for your STK push form.
That is where the problem may be.

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #334 by AM
Replied by AM on topic Lipa na Mpesa Online Sandbox Test
Hi Brian,

Below is the code:

public ResponseEntity<CheckoutResponse> doCheckout() throws IOException {

//String timestamp = String.valueOf(new Timestamp(System.currentTimeMillis()).getTime());
String timestamp = getTimeStamp();

log.info("Short Code " + applicationProperties.getMpesaConfig().getShortcode());

CheckoutRequest checkoutRequest = new CheckoutRequest();
//checkoutRequest.setAccountReference(getReference());
checkoutRequest.setAccountReference("");
checkoutRequest.setAmount("30");
checkoutRequest.setBusinessShortCode(applicationProperties.getMpesaConfig().getShortcode());
checkoutRequest.setCallBackURL(applicationProperties.getMpesaConfig().getCallbackurl());
checkoutRequest.setPartyA("254708374149");
checkoutRequest.setPartyB(applicationProperties.getMpesaConfig().getShortcode());
checkoutRequest.setPassword(password(timestamp));
checkoutRequest.setPhoneNumber("254708374149");
checkoutRequest.setTimestamp(timestamp);
checkoutRequest.setTransactionDesc("MPesa online checkout");
checkoutRequest.setTransactionType("CustomerPayBillOnline");

CheckoutResponse checkoutResponse = mpesaPaymentService.getCheckoutResponse(checkoutRequest);

return new ResponseEntity<>(checkoutResponse, HttpStatus.OK);
}


public CheckoutResponse getCheckoutResponse(CheckoutRequest checkoutRequest) throws IOException {

initMpesaConfifg();

OkHttpClient client = new OkHttpClient();

String req = new Gson().toJson(checkoutRequest);

log.debug("getCheckoutResponse json request {} ",req);

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, req);
Request request = new Request.Builder()
.url(" sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest ")
.post(body)
.addHeader("authorization", "Bearer " + getSandBoxToken().getAccess_token() + "")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
String res = response.body().string().toString();
System.out.println(res);
CheckoutResponse checkoutResponse = new Gson().fromJson(res, CheckoutResponse.class);

return checkoutResponse;
}
The following user(s) said Thank You: Sir Brian M. W

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #335 by Stella
Replied by Stella on topic Lipa na Mpesa Online Sandbox Test
Please supply enough information on your solution.
What are you tying to do in your STK push test before you landed to this error?
Some sample code of what you have may help.

Before I get this, I will guess that your Daraja Sandbox app is not enabled for Mpesa Express product.

I will get to that when I see some code.

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #336 by AM
Replied by AM on topic Lipa na Mpesa Online Sandbox Test
Hi Stella,

I have provided the sample code in post no 334. My app has Mpesa Express checkout enabled. What other information do you require?

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago - 1 month 1 week ago #337 by Sir Brian M. W
Replied by Sir Brian M. W on topic Lipa na Mpesa Online Sandbox Test
In your code, I do not see where you are GETTING the Daraja app SECRET, KEY and passkey correctly.

That is why you are getting that error because you are simply not supplying the needed credentials.

It would be helpful to share those functions or just look into them to ensure you have a function that provides this file with:

1. Shortcode.

2. Amount

3. Passkey

4. PartyB - phone number

5. Consumer Key

6. Consumer secret.
Last edit: 1 month 1 week ago by Sir Brian M. W. Reason: Some commissions

Please Log in or Create an account to join the conversation.

Time to create page: 0.241 seconds
Powered by Kunena Forum