flutter-plugin icon indicating copy to clipboard operation
flutter-plugin copied to clipboard

Expose properties to load the configuration both from an asset and a JSON string directly from the GooglePayButton widget

Open JlUgia opened this issue 4 years ago • 2 comments

The Pay client accepts loading a payment configuration both from an asset stored within the Flutter module, or a JSON string produced at runtime (eg.: loaded from a backend server). This flexibility is not exposed all the way up to the GooglePayButton widget yet.

Include an additional property in the GooglePayButton widget to load the configuration from a JSON string, similar to how the Pay client already offers. Make sure to control for existence of at least one field using assert on the init constructor.

JlUgia avatar Mar 05 '21 10:03 JlUgia

@JlUgia sir do you know how to add paymentConfiguration without using assets? i can not create PaymentConfiguration.

91priyansh avatar Jun 05 '21 08:06 91priyansh

Hi @91priyansh, you can instantiate a payment configuration using a string:

PaymentConfiguration.fromJsonString(configurationJsonString)

You can then use that configuration to call the methods to determine readiness to pay and start the payment process. You can use the high level client in the pay package as a reference.

We may want to consider simplifying the use of JSON strings, exposing the method it all the way to the pay client, adding a wrapping method that takes a list of strings instead of assets.

JlUgia avatar Nov 22 '21 10:11 JlUgia

Use the new 1.1.0 version from the pay package to load your configuration from strings.

JlUgia avatar Jan 24 '23 12:01 JlUgia