What is the default value of the IsReadyToPayRequest.existingPaymentMethodRequired property? - google-pay

The existingPaymentMethodRequired property in the IsReadyToPayRequest object is marked as optional but the documentation does not state what the property's default value is.
What value does this property fall back to if I don't specify it?

The existingPaymentMethodRequired property's default value, at the time of writing, is false.
You can validate this by calling the PaymentsClient.isReadyToPay(request:) method with an IsReadyToPayRequest object which omits the existingPaymentMethodRequired property and with the following setup:
The Google Pay environment is set to PRODUCTION.
The IsReadyToPayRequest.allowedAuthMethods array is set to ["PAN_ONLY","CRYPTOGRAM_3DS"].
Neither your Android device nor your Google account has a payment method added to it.
You will see that the PaymentsClient.isReadyToPay(request:) method returns true with this setup just as it does when the IsReadyToPayRequest.existingPaymentMethodRequired property is specified and set to false.

Related

What's the point of using empty string to set cache variable in CMake?

I've seen different ways of setting / using Cache variables in Cmake.
What is the standard?
What's the point of setting an empty string ("") to the cache variable?
Example
set(NVTX_ROOT_DIR "" CACHE PATH "Folder contains NVIDIA NVTX")
What's the point of setting an empty string ("") to the cache variable?
It is not just setting a value for a CACHE variable.
Command flow set(CACHE) normally performs two things:
Declares the parameter (assigns description and possibly the type)
Sets the parameter's default value. (That is, if the parameter is already set, its value isn't changed).
Empty value for CACHE variable could mean that a parameter denoted by this variable is not set. Depending on the project which uses it, this could be interpreted as:
Do not use functionality described by the parameter.
Emit an error telling the parameter should be set by a user.
In CMake code checking the parameter could be implemented with simple if(VAR):
if(NVTX_ROOT_DIR)
# The parameter is set
else()
# The parameter is not set
endif()
While if(NVTX_ROOT_DIR) is false even if the variable is not set, declaring the parameter is impossible without setting its value. So empty string as a default value is a logical choice for being able to use simple if(NVTX_ROOT_DIR) for check absence of the parameter's setting.

Why is variable substitution only recommended for values that wont change during lifetime of a widget?

Regarding Variable Substitution in Dojo
Variable Substitution:
A template can have values set on DOM rendering
though the use of a simple variable placeholder syntax, which looks
like this:
${property}
According to the documentation
Variable substitution in a template is only recommended for values
that will not be changed during the lifetime of the widget. In other
words, if you expect to be able to set the value of a property in a
widget during the lifetime of your application programmatically, we
recommend instead using your widget's postCreate method to set any
variables programmatically through your widget's set() method.
Can someone explain why this recommendation is made?
Variable substitution in Dojo has no binding.
This mean it wont change even if you change the actual value of the variable.
If a binding is needed, then you can use an attach point and a setter for that value. It will then have a binding and the UI will be updated with the new value.
Something like this:
_setLabelAttr : {
node : "_tplLabelNode",
type : "innerHTML"
},
Will bind the innerHTML of attach point _tplLabelNode to the "label" property of the widget.
So widget.set('label', 'foo'); will update the UI.
However <div>${label}</div> has no bind. ${label} will be replaced at creation of the widget and will never be updated

Core Data - Fetch object with optional attribute

I have an EntityA which has an optional attribute int32 result. When I create EntityA I do not set the result attribute. Then later on when I fetch it I expect it to have nil value but for some reason it's set to 3 even though I have not set this attribute.
What's going on here?
1st possible issue:
You have set a default value in the model editor. Select the attribute and check the inspector.
2nd possible issue:
You are retrieving or showing the wrong value. Show the code you are using to find out that result is '3'.
3rd possible issue:
You are setting the value later inadvertently, perhaps in a loop or something similar. Do a text search for the attribute to find a possible occurrence in your code.
Your int32 will be stored wrapped into a NSNumber object. If you don't provide a value, no NSNumber object will be created - sql will treat it as NULL.
The iOS Core Data Programming Guide says:
You can specify that an attribute is optional—that is, it is not
required to have a value. In general, however, you are discouraged
from doing so—especially for numeric values (typically you can get
better results using a mandatory attribute with a default value—in the
model—of 0). The reason for this is that SQL has special comparison
behavior for NULL that is unlike Objective-C's nil. NULL in a database
is not the same as 0, and searches for 0 will not match columns with
NULL.
So, it may be better to either make the attribute mandatory and set it to a distinct value, or to pass in NSNumber from the start.

How can I print a servlet context attribute in EL?

Is there a way I can get a attribute set in ServletContext in EL so that it ends up as a JavaScript variable?
I am setting it as
context.setAttribute("testing.port", "9000");
I tried retrieving it like
alert("port" +'${testing.port}');
I am just getting a blank.
The problem is the period (.) in the key name. EL interprets the period as a call to an accessor method named getPort1 on whatever object testing references. Fetch the value from the appropriate implicit object:
${applicationScope['testing.port']}
or just use a different key:
${testingPort}
1Yes, this is a simplification of what really happens. It may also look for a predicate getter named isPort, or try Map#get("port").

gtk3 get settings value from GtkSettings

I want to programmatically retrieve the value of the word wrap setting for GEdit3 from inside a Python plugin.
The GtkSettings class provides a method to set a string property, but how does one retrieve the value of a string property? I see no "getter" method.
I have also consulted pydoc gi.repository.Gtk.Settings - the methods listed there are the same as the online docs.
I am able to retrieve the property value of interest with the gsettings CLI utility. The command gsettings get org.gnome.gedit.preferences.editor wrap-mode
yields the value 'word'. I was hoping not to have to use subprocess.Popen() just to retrieve this property, however.
This will work
from gi.repository import Gio
a = Gio.Settings('org.gnome.gedit.preferences.editor')
a.get_string('wrap-mode')
Since you're using automatic generated bindings, C code samples will work just fine for you, it is just about changing the syntax.