1

I want to integrate Mpesa API to a google form. Users using the form to pay, let us say for registration Fee

Jack Siro
  • 627
  • 9
  • 29
Ruth
  • 69
  • 1
  • 8

3 Answers3

3

You now use M-Pesa RESTful APIs accessible through Safaricom's developer portal. The documentation has sample codes in the major programming languages - Python, JavaScript/NodeJS, Java, Ruby.

You can now consume the M-Pesa RESTful APIs with Google Apps Script like you would any other RESTful APIs.

Beliot
  • 135
  • 1
  • 6
1

I think this is possible by using Apps Script to create a google form.

Forms Service

This service allows scripts to create, access, and modify Google Forms.

Here is a sample code for creating a google form using Apps Scripts.

// Create a new form, then add a checkbox question, a multiple choice question,
// a page break, then a date question and a grid of questions.
var form = FormApp.create('New Form');
var item = form.addCheckboxItem();
item.setTitle('What condiments would you like on your hot dog?');
item.setChoices([
        item.createChoice('Ketchup'),
        item.createChoice('Mustard'),
        item.createChoice('Relish')
    ]);
form.addMultipleChoiceItem()
    .setTitle('Do you prefer cats or dogs?')
    .setChoiceValues(['Cats','Dogs'])
    .showOtherOption(true);
form.addPageBreakItem()
    .setTitle('Getting to know you');
form.addDateItem()
    .setTitle('When were you born?');
form.addGridItem()
    .setTitle('Rate your interests')
    .setRows(['Cars', 'Computers', 'Celebrities'])
    .setColumns(['Boring', 'So-so', 'Interesting']);
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());

Then you can integrate the third party API in the Apps Scripts.

External APIs

Google Apps Script can interact with APIs from all over the web. This guide shows how to work with different types of APIs in your scripts.

Dozens of Google APIs are available in Apps Script, either as built-in services or advanced services. If you want to use a Google (or non-Google) API that isn't available as an Apps Script service, you can connect to the API's public HTTP interface through the URL Fetch service.

The following example makes a request to the YouTube API and returns a feed of videos that match the query skateboarding dog.

var url = 'https://gdata.youtube.com/feeds/api/videos?'
    + 'q=skateboarding+dog'
    + '&start-index=21'
    + '&max-results=10'
    + '&v=2';
var response = UrlFetchApp.fetch(url);
Logger.log(response);

Similarly, the following example uploads a video to YouTube. Also using UrlFetchApp.fetch()

var payload = 'XXXXX'; // Replace with raw video data.
var headers = {
    'GData-Version': '2',
    'Slug': 'dog-skateboarding.mpeg'
    // Add any other required parameters for the YouTube API.
};
var url = 'https://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
var options = {
    'method': 'post',
    'headers': headers,
    'payload': payload
};
var response = UrlFetchApp.fetch(url, options);
Community
  • 1
  • 1
Mr.Rebot
  • 6,025
  • 2
  • 13
  • 76
1

Kindly check my answer on a similar question to yours here: Intergrating Mobile Money like Mpesa and AirtelMoney with Android App

Explore the possibbility of developing an android app with a custome made Mpesa api to help you store Mpesa messages online and optimize that information for use on Google Forms

Community
  • 1
  • 1
Jack Siro
  • 627
  • 9
  • 29