HowTo: Call a Super App API from a Native mobile Mini App
GeneXus' Super App API offers an efficient way to achieve integration between Super Apps and Mini Apps without the need to implement the API's functionalities separately for each Mini App, thus enhancing security.
In this article, you will find full samples of how a Native Mobile Mini App can call a Super App API.
HowTo: Call a GeneXus Super App API
In these samples, it is assumed that:
1) You have a GeneXus Super App exposing the following method in its API for handling payments:
Payment {
NewPayment(in:&ExternalReference, in:&Amount, out:&Success, out:&PaymentId)
=> PaymentPanel(&ExternalReference, &Amount, &Success, &PaymentId);
}
2) The Super App object is placed within a module under the Root module, which is packaged and distributed.
You can check the Verdant Bank - GeneXus Super App Sample KB available for download.
To interact with this Super App API, make the following changes in your Native Mobile Mini App KB:
- Go to Knowledge Manager > Manage Module References.
- Install your Super App API Module (in this case: SampleVerdantBankAPI).
Once the module is installed:
3) Create a Panel object with a Button to interact with the Super App, as shown below:
4) In the Events section of the Panel object, write the following:
Event 'Pay'
Composite
SampleVerdantBankAPI.SuperAppVerdantBank.NewPayment(&Reference,&Amount,&Success,&PaymentId)
If &Success
msg(format("Successful payment %1",&PaymentId))
Else
msg('Sorry, your order has been rejected')
Endif
EndComposite
Endevent
You can check all these Mini Apps KBs available for download with Super App API call examples:
- The Movies: This Mini App facilitates the purchase of movie tickets.
- Frosty Delights: Users can order a variety of ice cream flavors through this Mini App.
- Coffee and Muffins: This Mini App allows users to order coffee and sandwiches from a coffee store.
By following these steps, you can integrate your Mini Apps with the GeneXus Super App.
HowTo: Call a non-GeneXus Super App API
In this case, the examples of non-GeneXus Super Apps published on GitHub will be followed: Android and iOS.
Both non-GeneXus Super Apps expose the following methods in their API:
PayWithUI(int amount, string reference)
PayWithoutUI(int amount, string reference)
To interact with this Super App API, make the following changes in your Native Mobile Mini App KB:
1) Create a new External Object; in this case, named Payments.
2) Declare two new methods: PayWithUI and PayWithoutUI with the following configuration:
3) Reference the new External Object from a button event programmed in the Checkout Panel:
Event 'PayWithoutUI'
&Reference = Payments.PayWithoutUI(&Amount)
msg(&Reference)
Endevent
Event 'PayWithUI'
&Reference = Payments.PayWithUI(&amount)
msg(&Reference)
Endevent
You can check this Mini App KB available for download with Super App API call examples.
Mini App Payments: This Mini App implements a non-GeneXus Super App API call.
See Also
Super App API
HowTo: Call a Super App API from a Web Mini App