Stripe google pay Android - Unexpected developer error, please try again later - java

I faced an issue with google pay with stripe. The problem is that I fully
followed the documentation and get an obscure error. I have this onGooglePayResult and i always have Result.Failed with error - " java.lang.RuntimeException: Google Pay failed with error 10 " And error code 2.Feel free to ask i can answer on all your questions.
Main error is java.lang.RuntimeException: Google Pay failed with error 10:. This is coming in GooglePayPaymentMethodLauncher.Result.Failed. I really can't understand why this is producing, I've checked stripe documentation twice, google pay set up and everything, but can't find out.
I mean how to find out what is real error message is, I try to find anything related to this but unfortunatelythere is simply nothing of the kind.
Logcat - error = java.lang.RuntimeException: Google Pay failed with error 10: + error code = 2
private fun onGooglePayResult(
result: GooglePayPaymentMethodLauncher.Result
) {
when (result) {
is GooglePayPaymentMethodLauncher.Result.Completed -> {
// Payment details successfully captured.
// Send the paymentMethodId to your server to finalize payment.
val paymentMethodId = result.paymentMethod.id
presenter.payPlanWithGooglePay(deviceIdentifier, paymentMethodId)
}
GooglePayPaymentMethodLauncher.Result.Canceled -> {
// User cancelled the operation
Timber.d("Cancel")
}
is GooglePayPaymentMethodLauncher.Result.Failed -> {
// Operation failed; inspect `result.error` for the exception
Timber.d("error = ${result.error} + error code = ${result.errorCode}")
}
}
}

I've resolved this issue, was my fault. I forget to add the PUBLISHABLE key from the stripe developer portal.
I use this function to set up Google pay. Just substitute TEST_PUBLISHABLE_KEY with your key in stripe account(Website).
private fun setUpGooglePay(): GooglePayPaymentMethodLauncher {
PaymentConfiguration.init(this, TEST_PUBLISHABLE_KEY)
return GooglePayPaymentMethodLauncher(
activity = this,
config = GooglePayPaymentMethodLauncher.Config(
environment = GooglePayEnvironment.Test,
merchantCountryCode = Constants.GooglePay.Manx.COUNTRY_CODE,
merchantName = UIUtils.getString(R.string.app_name)
),
readyCallback = ::onGooglePayReady,
resultCallback = ::onGooglePayResult
)
}

Related

OSPermissionSubscriptionState : Cannot resolve symbol

I'm trying to add push notification to my mobile native chat app. I'm trying to use OneSignal.
I can send manual push notification, so I think gradle part is okay
idsAvaiable method is deprecated, I started to looking for how can I get userId.
OSPermissionSubscriptionState status = OneSignal.getPermissionSubscriptionState();
String userId = status.getSubscriptionStatus().getUserId();
In here, I'm trying to get userId with status, but it's saying:
Cannot resolve symbol 'OSPermissionSubscriptionState'
How can I get userId?
Root cause
From OneSignal API 4.0.0, there are many APIs that have been removed including OSPermissionSubscriptionState.
Solution 1
Use OneSignal.getDeviceState()
OSDeviceState device = OneSignal.getDeviceState();
String userId = device.getUserId();
Solution 2
Use OneSignal.addSubscriptionObserver()
OneSignal.addSubscriptionObserver(new OSSubscriptionObserver() {
#Override
public void onOSSubscriptionChanged(OSSubscriptionStateChanges stateChanges) {
if (!stateChanges.getFrom().isSubscribed() && stateChanges.getTo().isSubscribed()) {
// Get user id
String userId = stateChanges.getTo().getUserId();
}
}
});
For more information, see the change log here.

React fetch error/response catching not working

I built a signup page that needs to check whether an inputted email is already taken.
When a duplicate email is taken, it gets stopped in the java spring api backend and returns a status of "400".
(I've also tried using the spring annotation #column(unique=true) but could not get the 422 error to catch, either.)
I then have a catch for that status, which should then set an error (for which a field exists); when any error is set, the page won't continue. If there are no errors, the page automatically signs in and reroutes to the homepage.
I've tried catching the error as error, error status, error response, and response. (since technically a received exception from the backend isnt an error.) I just can't seem to get it to catch.
I'd appreciate if anyone knows what's wrong here and how to fix it.
the signup code, in which I'm leaving the various methods by which I've tried to catch the response:
const signUp = () => {
axios
.post('http://localhost:8080/signup', {
email,
password,
firstName,
lastName
// address,
// phoneNumber,
// image
})
// eslint-disable-next-line consistent-return
.catch((err) => {
if (err.status) {
setEmailUsedError('Already in use. ');
}
})
.then(() => {
post('/login', null, {
email,
password
}).then((data) => {
if ('token' in data) {
sessionStorage.token = data.token;
const { sub } = JSON.parse(atob(data.token.split('.')[1]));
sessionStorage.email = sub;
onLogin();
history.push('/');
}
})
.catch((err) => {
if (err.res.status === 422) {
setEmailError('Already in use. ');
} else setServerError(true);
});
});
};
then the uncaught error message in the browser:
Update: I changed .then((res)... to `.catch
.then((res) => {
if (res.status) {
setEmailUsedError('Already in use. ');
}
in the signUp function to .catch((err)...
Now it's showing the error is caught, but isn't setting the error as is coded. Not sure why.
Same result when I tried .catch((res)...
While there may be other factors in play, based on the console message it is your call to the /signup endpoint that is returning 422, rather than /login (as shown in the code sample). You may wish to check if the enclosing block calling it is itself chained with a catch statement.
Based on the assumption that /signup is called immediately before /login, you'll need a catch block on the same indent level as the .then(() => {post()...}.

Conversation ID leads to unkown path in graph-api

I have a code that fetches conversations and the messages inside them (a specific number of pages). It works most of the time, but for certain conversations it throws an exception, such as:
Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: Unknown path components: /[id of the message]/messages (code 2500, subcode null)
at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1192)
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1118)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1059)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:970)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:932)
at com.restfb.DefaultFacebookClient.fetchConnection(DefaultFacebookClient.java:356)
at test.Test.main(Test.java:40)
After debugging I found the ID that doesn't work and tried to access it from graph-api, which results in an "unknown path components" error. I also attempted to manually find the conversation in me/conversations and click the next page link in the graph api explorer which also lead to the same error.
Is there a different way to retrieve a conversation than by ID? And if not, could someone show me an example to verify first if the conversation ID is valid, so if there are conversations I can't retrieve I could skip them instead of getting an error. Here's my current code:
Connection<Conversation> fetchedConversations = fbClient.fetchConnection("me/Conversations", Conversation.class);
int pageCnt = 2;
for (List<Conversation> conversationPage : fetchedConversations) {
for (Conversation aConversation : conversationPage) {
String id = aConversation.getId();
//The line of code which causes the exception
Connection<Message> messages = fbClient.fetchConnection(id + "/messages", Message.class, Parameter.with("fields", "message,created_time,from,id"));
int tempCnt = 0;
for (List<Message> messagePage : messages) {
for (Message msg : messagePage) {
System.out.println(msg.getFrom().getName());
System.out.println(msg.getMessage());
}
if (tempCnt == pageCnt) {
break;
}
tempCnt++;
}
}
}
Thanks in advance!
Update: Surrounded the problematic part with a try catch as a temporary solution, also counted the number of occurrences and it only effects 3 out of 53 conversations. I also printed all the IDs, and it seems that these 3 IDs are the only ones that contain a "/" symbol, I'm guessing it has something to do with the exception.
The IDs that work look something like this: t_[text] (sometimes a "." or a ":" symbol) and the ones that cause an exception are always t_[text]/[text]
conv_id/messages is not a valid graph api call.
messages is a field of conversation.
Here is what you do (single call to api):
Connection<Conversation> conversations = facebookClient.fetchConnection("me/conversations", Conversation.class);
for (Conversation conv : conversations.getData()) {
// To get list of messages for given conversation
LinkedList<Message> allConvMessagesStorage = new LinkedList<Message>();
Connection<Message> messages25 = facebookClient.fetchConnection(conv.getId()+"/messages", Message.class);
//Add messages returned
allConvMessagesStorage.addAll(messages25.getData());
//Check if there is next page to fetch
boolean progress = messages25.hasNext();
while(progress){
messages25 = facebookClient.fetchConnectionPage(messages25.getNextPageUrl(), Message.class);
//Append next page of messages
allConvMessagesStorage.addAll(messages25.getData());
progress = messages25.hasNext();
}
}

Facebook4J OAuth failing

I am trying to search for public items using Facebook4J, I understad I need an appId AND appSecret which I have, the app token is the these two with a pipe symbol between them (as I understand). I can not understand why I am gett an OAuthError , Please see my code below and precise error code.
facebook4j.conf.ConfigurationBuilder fac = new facebook4j.conf.ConfigurationBuilder();
fac.setDebugEnabled(true)
.setOAuthAppId("appId")
.setOAuthAppSecret("appSecret")
.setOAuthPermissions("email,publish_stream");
fac.setOAuthAccessToken(accessToken);
FacebookFactory ff = new FacebookFactory(fac.build());
Facebook facebook = ff.getInstance();
ResponseList<JSONObject> results = facebook.search("%whatever");
This is the following error code I get. Error code one seems to be unknown API???
Exception in thread "main" message - An unknown error has occurred.
code - 1
Relevant information for error recovery can be found on the Facebook Developers Document:
https://developers.facebook.com/docs/graph-api/using-graph-api/#errors
FacebookException{statusCode=500, errorType='OAuthException', errorMessage='An unknown error has occurred.', errorCode=1, errorSubcode=-1, version=2.4.2}
at facebook4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:179)
at facebook4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at facebook4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
at facebook4j.FacebookImpl.get(FacebookImpl.java:2742)
at facebook4j.FacebookImpl.search(FacebookImpl.java:2337)
at facebook4j.FacebookImpl.search(FacebookImpl.java:2332)
at Main.facebook4JRequest(Main.java:37)
at Main.main(Main.java:15)
Try using the below code it worked for me.
Facebook facebook = new FacebookFactory().getInstance();
facebook.setOAuthAppId("XXXXXX", "XXXXXXXXXXXX");
String accessTokenString = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
AccessToken at = new AccessToken(accessTokenString);
facebook.setOAuthAccessToken(at);
ResponseList<Post> feeds = facebook.getPosts("%whatever", new Reading().limit(80));

The image id '[ami-fd9cecc7]' does not exist

I want to create EC2 Instance using this Java code remotely:
public void testEC2ServiceInRegion() throws Exception
{
String launchInstance = launchInstance();
System.out.println("Status " + launchInstance);
}
public String launchInstance()
{
BasicAWSCredentials bawsc = new BasicAWSCredentials(
"AKIAIUY1KF4KZV3DAL21", "Onv+nq33tUkiLl1Ib2H9JtIB732QMEesh01Jl73L");
AmazonEC2 ec2 = new AmazonEC2Client(bawsc);
System.out.println("\n\nLAUNCH INSTANCE\n\n");
try
{
// Construct a RunInstancesRequest.
RunInstancesRequest request = new RunInstancesRequest();
request.setImageId("ami-fd9cecc7"); // the AMI ID, ami-fd9cecc7 is Amazon Linux AMI 2015.03 (HVM)
request.setInstanceType("t2.micro"); // instance type
request.setKeyName("desktop"); // the keypair
// request.setSubnetId("subnet-2dc0d459"); // the subnet
// ArrayList list = new ArrayList();
// list.add("sg-efcc248a"); // security group, call add() again to add more than one
// request.setSecurityGroupIds(list);
request.setMinCount(1); // minimum number of instances to be launched
request.setMaxCount(1); // maximum number of instances to be launched
// Pass the RunInstancesRequest to EC2.
RunInstancesResult result = ec2.runInstances(request);
String instanceId = result.getReservation().getInstances().get(0).getInstanceId();
// Return the first instance id in this reservation.
// So, don't launch multiple instances with this demo code.
System.out.println("Launching instance " + instanceId);
return instanceId;
} catch (Exception e)
{
// Simple exception handling by printing out error message and stack trace
System.out.println(e.getMessage());
e.printStackTrace();
return "ERROR";
}
}
But I get this error code:
The image id '[ami-fd9cecc7]' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidAMIID.NotFound; Request ID: f85433c1-df4f-4105-bfe3-6f900eca6b70)
com.amazonaws.AmazonServiceException: The image id '[ami-fd9cecc7]' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidAMIID.NotFound; Request ID: f85433c1-df4f-4105-bfe3-6f900eca6b70)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1275)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:873)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:576)
at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:362)
Can you propose me some solution how to fix this code or there is a alternative?
Can you recommend me some working solution which I can use?
The AMI ami-fd9cecc7 exists in the Sydney (ap-southeast-2) region.
When you are executing your code, make sure that you are running it in the Sydney (ap-southeast-2) region. By default, it may run in Virginia (us-east-1). You may be able to specify the region by a code change or by a configuration change.
If you want your code to execute in Virginia (or any region other than Sydney), then you need to find a different AMI from that region to use as the base image for your EC2 instance.
You need to set Region while creating AmazonEC2Client.
Example:
Region usWest2 = Region.getRegion(Regions.US_WEST_2);
ec2.setRegion(usWest2);
I had everything configured correctly but failed to realise the AMI I created 10 minutes ago was still in 'Pending' status. Go to AMI dashboard and check:
If the AMI you're trying to use is 'Pending', try again when it's Available.
FYI it took about 12 minutes to become available. But it may take longer if the AMI is large or old.
I attempted the exact same configs immediately after it became 'Available' and it worked immediately:

Categories

Resources