Giter Club home page Giter Club logo

fortumo's Introduction

Fortumo

Fortumo in-app purchasing on Android SDK allows easy to use payments inside mobile apps and games.

Usage

To initialise a payment you need to build a Fortumo_PaymentRequest object and call the Fortumo_MakePayment method. When a payment is completed, notification about that will be sent to the callback function. If the billing has been succesful, the user should be given the virtual goods bought and the purchase should be stored on the device or on server-side so that users will keep access to the goods:

Fortumo_PaymentRequest *request = Fortumo_PaymentRequest_Create();
Fortumo_PaymentRequest_SetDisplayString(request, "display_string_here");
Fortumo_PaymentRequest_SetService(request, "service_id_here", "app_secret_here");
Fortumo_PaymentRequest_SetProductName(request, "product_name_here");
Fortumo_PaymentRequest_SetType(request, Fortumo_ServiceType_Consumable);
Fortumo_MakePayment(request, &Fortumo_OnPaymentComplete, NULL);
Fortumo_PaymentRequest_Delete(request);

Once the purchase has been processed, a notification will be sent to your callback function. You can decide to give users access to premium features upon the notification on the device or if you are keeping track of users purchases on your server you will update purchase data from there.

static void Fortumo_OnPaymentComplete(Fortumo_PaymentResponse *response, void *userData)
{
	int billingStatus = Fortumo_PaymentResponse_GetBillingStatus(response);
	
	switch(billingStatus) {
		case Fortumo_BillingStatus_NotSent:
			// The payment flow was cancelled by the user (eg. Back button)
			break;
		case Fortumo_BillingStatus_Pending:
			// The payment was probably successful, but isn't completely processed yet or the UI was closed too soon.
			// 1. Assume that the payment was successful without waiting.
			// 2. Use Fortumo_SetStateChangeListener() to get notified as soon as possible
			// 3. Use Fortumo_FindPayment() later to check if the status has changed.
			// 4. Fail. If the payment was successful, then Fortumo_MakePayment() should return the 'Billed' status next time.
			break;
		case Fortumo_BillingStatus_Billed:
			// The payment was successful.
			break;
		case Fortumo_BillingStatus_Failed:
			// The payment was not successful.
			break;
		default:
			// Try alternative payment methods if possible.
			break;
	}
	
	Fortumo_PaymentResponse_Delete(response);
}

See samples/DemoPayment for a full example.

Documentation

Read more about integration: http://developers.fortumo.com/in-app-purchasing-for-marmalade/

fortumo's People

Contributors

fortumohub avatar janekp avatar salqadri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.