com.nytimes.android

register

License

License

GroupId

GroupId

com.nytimes.android
ArtifactId

ArtifactId

register
Last Version

Last Version

0.0.8
Release Date

Release Date

Type

Type

aar
Description

Description

com.nytimes.android
register
Project URL

Project URL

https://github.com/nytimes/register/
Source Code Management

Source Code Management

https://github.com/nytimes/register/

Download register

How to add to project

<!-- https://jarcasting.com/artifacts/com.nytimes.android/register/ -->
<dependency>
    <groupId>com.nytimes.android</groupId>
    <artifactId>register</artifactId>
    <version>0.0.8</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.nytimes.android/register/
implementation 'com.nytimes.android:register:0.0.8'
// https://jarcasting.com/artifacts/com.nytimes.android/register/
implementation ("com.nytimes.android:register:0.0.8")
'com.nytimes.android:register:aar:0.0.8'
<dependency org="com.nytimes.android" name="register" rev="0.0.8">
  <artifact name="register" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.nytimes.android', module='register', version='0.0.8')
)
libraryDependencies += "com.nytimes.android" % "register" % "0.0.8"
[com.nytimes.android/register "0.0.8"]

Dependencies

compile (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-android-extensions-runtime jar 1.3.31
com.android.billingclient » billing jar 2.1.0
org.jetbrains.kotlin : kotlin-stdlib-jdk7 jar 1.3.21
androidx.annotation » annotation jar 1.0.0

Project Modules

There are no modules declared in this project.

Build Status

Register Logo

Register is an Android library for easier testing of Google Play's In-app Billing.

Blog Post

The Problems:

  • Google Play Billing implementations on Android are hard to get right
  • When payments are involved, developers sleep better having a way to test their functionality prior to release
  • Before an app is promoted to Alpha in the Play Store, we do not have an offical way to test payments

The New York Times Android Team developed a fake implementation of Google Play Billing called Register, which can be used as a companion app for testing Play Billing purchases and subscriptions.

Similar to a mock web server, you can point your app to use Register rather than the real Play Store In-app Billing implementation. Using Register, you'll be able to validate in-advance whether your purchasing flows work correctly.

Register has been used to test purchasing flows of our Flagship Reader App and NYT Crosswords App for three years and counting.

Register Sample

Overview

Register is a companion app and library that allows seamless mocking of responses from Google Play Store Billing. Register works by implementing the same interface as the Google Play Store Billing library Google Play Billing.

You can find a sample app that highlights the features of Google Play Billing here: Classy Taxi

From a client's perspective, there is no difference in how you work with Google Play Billing or Register's implementation.

If you've used Amazon's IAP Tester Utility, you'll find Register's workflow to be very familiar.

Using Register

You can find the latest version of Register in the Releases Tab

Step 0: Register needs a configuration file that declares the mock purchases, subscriptions and users that you will be testing against.

Here's a sample that we use at NYTimes. The format needs to be the same as below when creating your own fake purchases. This JSON file (register.json) should be included in the assets folder of your module.

{
	"skus": {
	    "register.sample.iap": {
			"type": "inapp",
			"price" : "1.00",
			"title" : "Sample In App Purchase Item",
			"description" : "This is an in app purchase item for use with Register sample app",
			"package" : "com.nytimes.android.external.register"
	    },
		"register.sample.sub": {
			"type": "subs",
			"price" : "10.00",
			"title" : "Sample Subscription Item1",
			"description" : "This is a subscription item for use with Register sample app",
			"package" : "com.nytimes.android.external.register"
		}
	},
	"users": [
		"[email protected]",
		"[email protected]"
	]
}

For Register to find the aforementioned configuration file (in case you change name or location), you need to change the data contained in the configuration\configuration.properties file:

ide.json.path=subfolder/from/root
file.json.name=newFileName.json

Step 1: Add Register as a dependency to your client app, this will install the companion app:

compile 'com.nytimes.android:register-app:0.0.8'
compile 'com.nytimes.android:register:0.0.8'

or, on Android Gradle Plugin 3.0 or later:

implementation 'com.nytimes.android:register-app:0.0.8'
implementation 'com.nytimes.android:register:0.0.8'

Step 2: Create a test Google Service Provider (or a real provider):

 private void initGoogleServiceProvider() {
        if (prefsManager.isUsingTestGoogleServiceProvider()) {
            googleServiceProvider = new GoogleServiceProviderTesting();
        } else {
            googleServiceProvider = new GoogleServiceProviderImpl();

Step 3: Make a purchase, similar to how you would with the regular In-app Billing API.

Register Sample

Step 4: Go to the companion app to view the purchase.

Register Sample

Fully Configurable (Configuration App)

Register's companion app allows you to view both successful and unsuccessful purchases directly on your Android device. Additionally, you can control responses back to your client app for values such as getSkuDetails.

See the image below for all configurable options on a response.

Register Sample

Sample App

SampleApp is a client app that showcases working with Register. See SampleActivity for a demo of the purchasing flow.

Gradle

For Android Gradle Plugin 3.0

implementation 'com.nytimes.android:register-app:0.0.8'
implementation 'com.nytimes.android:register:0.0.8'

For projects using older versions of the plugin

compile 'com.nytimes.android:register-app:0.0.8'
compile 'com.nytimes.android:register:0.0.8'
com.nytimes.android

The New York Times

Versions

Version
0.0.8
0.0.7.1
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1