Skip to content

remp2020/crm-google-play-billing-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Google Play Billing Module

Translation status @ Weblate

Installation

We recommend using Composer for installation and update management. To add CRM GooglePlay Billing extension to your REMP CRM application use following command:

composer require remp/crm-google-play-billing-module

Enable installed extension in your app/config/config.neon file:

extensions:
	# ...
	- Crm\GooglePlayBillingModule\DI\GooglePlayBillingModuleExtension

Add database tables and seed GooglePlay Billing payment gateway and its configuration:

php bin/command.php phinx:migrate
php bin/command.php application:seed

Configuration

Payment notifications

To be able to read pub/sub notifications generated by your payments, CRM needs to be able to have an access to your Pub/Sub notifications account via service account credentials.

Head to the Google Developer Console - Credentials and generate new Service account JSON key and download it.

Make sure you're generating the key for the same project and same service account, that's linked to your Google Play console - Developer account - API access.

Enter path to service account JSON with access to Google Play into CRM configuration:

  • Visit to CRM admin settings (gear icon).
  • Select Payments category.
  • Enter path to Google Play Service Account key.

Mapping subscriptions

GooglePlay's in-app subscription is mapped to CRM subscription type via relation table google_play_billing_subscription_types.

We'll be adding administration interface later. For now it's needed to seed these mapping data manually.

Matching payments with CRM users

GooglePlay's in-app subscription is mapped to CRM users via obfuscatedExternalAccountId field of SubscriptionResponse. This field is present in Google Play Billing library v2.2.

For previous version (<2.2) of Google Play Billing library, you have to set field obfuscatedExternalAccountId into DeveloperPayload. This is deprecated and will be removed after official SubscriptionResponse in Google's package google/apiclient-services is updated and response contains getObfuscatedExternalAccountId() method.

If user cannot be matched, processor creates anonymous unclaimed user (user with user_meta flag UnclaimedUser::META_KEY set to true). This is needed to fulfill Google's rules - user registration cannot be prerequisite of Android in-app purchases.

In case you need to link CRM user with app user in different way, you can override it by implementing SubscriptionResponseProcessorInterface and initializing own implementation as subscriptionResponseProcessor in config:

subscriptionResponseProcessor: Crm\FooModule\GoogleBillingSubscriptionResponse\MyFooBarSubscriptionResponseProcessor

Commands

google:revalidate-developer-notification

Command serves to revalidate developer notification against Google Billing service.

Support

  • Google Play Developer API version 3 is supported.
  • Only version 1.0 of DeveloperNotification is supported.
  • Only version 1.0 of SubscriptionNotification is supported.
  • One-time products are not supported.
  • Free trial is accepted without checking if user (MUID) used trial already. We rely on Google; it shouldn't allow multiple free trials for one credit card.