I have implemented Braintree SDK which supports pay using Paypal, Credit or Debit Card and Google Pay.
All are working except Google Pay.
I am getting following error while selecting payment method as GooglePay.
This merchant is not enabled for Google Pay
Even I have enabled Google Pay option on Braintree console.
following is the code for implementation:
Code on Pay button click:
DropInRequest dropInRequest = new DropInRequest()
.amount(strAmount)
.googlePaymentRequest(getGooglePaymentRequest())
.tokenizationKey("production_key_xxxxxxxxx");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
startActivityForResult(dropInRequest.getIntent(getActivity()), 399);
}
private GooglePaymentRequest getGooglePaymentRequest() {
return new GooglePaymentRequest()
.transactionInfo(TransactionInfo.newBuilder()
.setTotalPrice(strAmount)
.setCurrencyCode("USD")
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
.build())
.emailRequired(true);
}
Help would be appreciated.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact
support.
It looks like you're trying to pass the incorrect Google Pay object for a standalone Google Pay integration through Braintree into your Drop-in UI.
If you haven't already, you need to include the Google Pay meta tag in your AndroidManifest.xml:
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>
Then, construct a GooglePaymentRequest object and pass it to your DropInRequest object. The object may look something like:
private void enableGooglePay(DropInRequest dropInRequest) {
GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
.transactionInfo(TransactionInfo.newBuilder()
.setTotalPrice("1.00")
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
.setCurrencyCode("USD")
.build())
.billingAddressRequired(true); // We recommend collecting and passing billing address information with all Google Pay transactions as a best practice.
dropInRequest.googlePaymentRequest(googlePaymentRequest);
}
You can find more information about this in our developer docs.
To use the Google Pay API in production, you need to have it enabled for your app on Google's side as well.
Their Integration checklist is a good place to start, specifically it has a section called Requesting production access
You also need to add googleMerchantId("YOUR-MERCHANT-ID")
The merchantId parameter inside PaymentDataRequest must be set to the value provided in your Google Pay Developer profile.
https://developers.google.com/pay/api/web/support/troubleshooting#merchantId
Related
I'm trying to cast the videos playing on Jwplayer in near by devices like Tv, Laptop etc.
i followed this tutorial https://developer.jwplayer.com/jwplayer/docs/android-enable-casting-to-chromecast-devices
then on below code
CastOptions castOptions = new CastOptions.Builder()
// .setReceiverApplicationId(context.getString(R.string.app_id))
.setLaunchOptions(launchOptions)
.build();
I didn't get setReceiverApplicationId as i don't have such a id.
So, i went here How do you find your Google Cast App ID (app_id) in the 2017 Google Play Developer Console? and decided not to pay before testing.
Then on Jw docs it is mentioned setReceiverApplicationId() allows you to filter discovery results and to launch the receiver app when a cast session starts
Since i don't need filters i commented that line.
Now i got a cast icon on xml. but when I tap it nothing is happening.
Please someone tell me
Is app_id is necessary how to get it ?
How to test the chrome casting ?
You need to call setReceiverApplicationId, but you can use the default receiver ID without paying for a developer account.
For Android, your code should look like
CastOptions castOptions = new CastOptions.Builder()
.setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.setLaunchOptions(launchOptions)
.build();
I'm trying to integrate Google pay wallet following this demo https://github.com/google-pay/android-quickstart.
but when i try to make the payment for testing environment it gives me and error "there are no accepted cards available for use with this merchant".
i provide the below configration's
val SUPPORTED_NETWORKS = listOf(
"AMEX",
"DISCOVER",
"JCB",
"MASTERCARD",
"VISA")
/**
* The Google Pay API may return cards on file on Google.com (PAN_ONLY) and/or a device token on
* an Android device authenticated with a 3-D Secure cryptogram (CRYPTOGRAM_3DS).
*
* #value #SUPPORTED_METHODS
*/
val SUPPORTED_METHODS = listOf(
"PAN_ONLY",
"CRYPTOGRAM_3DS")
and the merchant config is
val PAYMENT_GATEWAY_TOKENIZATION_PARAMETERS = mapOf(
"gateway" to PAYMENT_GATEWAY_TOKENIZATION_NAME,
"gatewayMerchantId" to "exampleGatewayMerchantId"
)
use environment as
const val PAYMENTS_ENVIRONMENT = WalletConstants.ENVIRONMENT_TEST
i'm using it in india (as i have Indian gmail account) but the issue is how will i be able to add testing cards to my account.
I think this is because you determined a gateway but your ID is still "example"
One of the possible reasons for this is that the merchant is requesting payment methods from a user that isn't available in their country.
In this case, you mentioned that you are using an Indian Google account which doesn't support credit card payment methods.
One work-around for this is to create separate Google account for a country that is supported (e.g. the United States) and test using that account.
We would like to provide a list of reference from a public sheets that everyone can view in android.
I tried the Quickstart sample from Google which works just fine.
But we would like to minimize the steps (steps like allow access to contacts, choosing google account) since this apps is designed for people who's considering suicide. The list is fill of info about where to ask for help.
I did find a article about how to read a sheet as a InputStream
I would really appreciate if there's more elegant way with Google Sheet API V4
If the Sheets are shared to "anyone with link" or "public", it might not be necessary to go through the account flow in Android. Choosing an account is mainly to get access to the right credentials, but public sheets can be read anonymously (without credentials) with the API.
If you are still looking for an answer, only a single line replacement is needed for this to work:
Credential credential = new GoogleCredential().createScoped(SCOPES);
instead of
Credential credential = authorize();
then you can remove the method authorize() and the corresponding variables
I found out there's a setKey method in com.google.api.services.sheets.v4.Sheets. For the third parameter in Builder, as credential, can be null. But will have error "Requests from this Android client application are blocked" if the Key restricted to Android.
I'm trying to use the YouTubeData API with OAuth 2.0 authentication on Android, and i'm kind of struggling with it.
I've searched a lot online, but there's not much help for the Android implementation.
First of all, it's not clear to me what's the best way to obtain an OAuth token. In the doc they suggest that for Android is better to obtain it using the Google Play services lib. Is that true? if yes, it should be pretty trivial following this guide: https://developers.google.com/android/guides/http-auth.
But at this point i will have the token in a String object .. how should I use it with the YouTubeData API? Should I place it somewhere in the YouTube.Builder ?
YouTube youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("AppName").build();
if yes, does anyone know where?
Searching on StackOverflow i've come across this question: What to do after getting Auth Token - Android Youtube API. Here Ibrahim Ulukaya says it's better to use GoogleAccountCredential. For what i've understood (Access to Google API - GoogleAccountCredential.usingOAuth2 vs GoogleAuthUtil.getToken()) the Android version of GoogleAccountCredential should use the GoogleAuthUtil provided from the Google Play services lib, so it could be pretty useful to simplify the process. I've looked at the sample project suggested from Ibrahim Ulukaya (https://github.com/youtube/yt-direct-lite-android) and i've implemented everything as he does. But it doesn't seem to work very well as i'm only obtaining this message in the logcat: "There was an IO error: com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission : null".
(Note that I've enabled all the required APIs on the Google Console, and created the Client ID for my app)
At this point i'm kind of lost.
Should I use directly the GoogleAuthUtil from the Google Play services lib? in this case once obtained the token as a String how can i use it with the YouTubeData APIs?
Or should I use the GoogleAccountCredential ? in this case someone knows how can I solve the "NeedPersmission : null" error?
---- EDIT:
details on what my app is trying to do: being this my first experience with this kind of APIs I started from the easy stuff: retrieve video information and then play those videos, without any user authentication. I managed to do that pretty easily, but for my app's purpose i need to access the user data, in particular users must be able to like and comment videos.
So I started implementing OAuth2, trying to do the same exact queries I was doing before (retrieve video info).
Wow. The documentation on this is super confusing. Full disclosure, I'm not an Android developer but I am a Java developer who has worked with Google apps and OAuth2.
Google Play or not Google Play? First off, Google Play Services will only be available on Android devices with Google Play Services installed (so not OUYA, Amazon devices, etc.). Google state that "the Google Play library will give you the best possible performance and experience.".
There are numerous discussions (e.g. here, here) from actual Android developers that list the various merits of Google Play verses other techniques. I would imagine that once you are able to get your application working using one method, then it should be an easy enough to change if you so desire.
Much of the example code about uses the Android AccountManager (Tasks and Calendars being favourite examples) so that is what I will show.
Your example code looks like it might be for a simple search, I would guess that many of the YouTube API interactions do not require OAuth2, in other code I've seen this empty HttpRequestInitializer implementation referred to as a no-op function. (e.g. GeolocationSearch.java).
It sounds like you want access to YouTube API operations that need account credentials. You can do something similar to this Android Calendar example (CalendarSampleActivity.java) except with YouTube, like the example answer from here.
// Google Accounts
credential = GoogleAccountCredential.usingOAuth2(this, YouTubeScopes.YOUTUBE, YouTubeScopes.YOUTUBE_READONLY);
SharedPreferences settings = getPreferences(Context.MODE_PRIVATE);
credential.setSelectedAccountName(settings.getString(PREF_ACCOUNT_NAME, null));
// YouTube client
service =
new com.google.api.services.youtube.YouTube.Builder(transport, jsonFactory, credential)
.setApplicationName("Google-YouTubeAndroidSample/1.0").build();
I hope this helps.
In the initialize method of the HttpRequestInitializer you can set headers of the request. According to Googles documention for Oath2 for devices https://developers.google.com/identity/protocols/OAuth2ForDevices if you have an access token you should put it in the Authorization: Bearer HTTP header.
YouTube youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
public void initialize(HttpRequest request) throws IOException {
request.put("Authorization", "Bearer " + yourAccessTokenString);
}
}).setApplicationName("AppName").build();
Remember the space after the Bearer in the authorization header value
I use the Google+ Platform for Android with
PlusClient plusClient =
new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN).build();
In the onConnected-Listener I want to read the data of the logged in user
#Override
public void onConnected() {
super.onConnected();
Person person = plusClient.getCurrentPerson();
}
The method call getCurrentPerson returns null.
Has anyone managed to read the user-data?
You need to create an OAuth 2 client ID and add your Android app's developer (and probably production) signing keys to it, as described in the Google+ Getting Started guide.
I did the same thing but had not known to create the OAuth 2 client ID, and was getting null from that method (of course with no useful feedback in the logs). After creating the ID and adding my app's signing keys, the method returns an actual Person instance.
Even though you don't actually USE the client ID anywhere in your application, the act of adding your signing key in that interface apparently unlocks something on Google's servers and allows things to work.
Did you go through the setup steps outlined here?
You need to create an OAuth 2 client ID and add your Android app's developer (if you are releasing only add release key, otherwise development key will be enough) signing keys to it, as described in the Google+ Getting Started guide.
If you upgrade your API Console to New one, Go To "Consent Screen" and add Product Name(this is required)
Go to API Console "APIs & auth" -> "APIs" and enable "Google+ API"
it will work like a charm!!!