Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C2B Register URLs For Production Should Use V2 API #56

Open
nigelnindodev opened this issue Sep 5, 2024 · 0 comments
Open

C2B Register URLs For Production Should Use V2 API #56

nigelnindodev opened this issue Sep 5, 2024 · 0 comments

Comments

@nigelnindodev
Copy link

nigelnindodev commented Sep 5, 2024

Describe the bug

Using V1 version of the API fails with the following error code & message:

"errorCode": "401.003.01",
"errorMessage": "Error Occurred - Invalid Access Token - Invalid API call as no apiproduct match found"

To Reproduce
Steps to reproduce the behavior:

Use the library to make calls to register C2B URLs for production.

Expected behavior
First time registration of C2B URLs should have the following as part of its response:

 "ResponseCode": "0",
 "ResponseDescription": "Success"

Screenshots
N/A

Additional context
To quickly test if this works, here is a script to quickly test using V2 version of the API:

let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'Bearer [add_valid_token_here]');

const BASE_URL = '';  // Add you base url

fetch('https://api.safaricom.co.ke/mpesa/c2b/v2/registerurl', {
	method: 'POST',
	headers,
	body: JSON.stringify({
		ShortCode: 0000000, // replace with production short code as number
		ResponseType: 'Completed',
		ConfirmationURL: `${BASE_URL}/confirmation_url_path`,
		ValidationURL: `${BASE_URL}/validation_url_path`
	})
})
	.then((response) => response.text())
	.then((result) => console.log(result))
	.catch((error) => console.log(error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant