Paypal IOS SDK issues (can't communicate with servers) - ios

I am trying to process a paypal payment using the latest IOS SDK 2 - BASICALLY i'm trying to follow the example at -
https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/single_payment.md
without much luck.
Background
I'm in Australia.
I'm using the paypal sdk to take a payment in IOS app. the app then makes a call to a PHP web server that will validate the paypal payment and then update a subscription on the PHP server backend.
What I've done and where I'm getting stuck.
I've setup a classic API application.
I've set the production and sandbox environments using -
[PayPalMobile initializeWithClientIdsForEnvironments:
#{PayPalEnvironmentProduction : #"HIDDEN",
PayPalEnvironmentSandbox : #"HIDDEN"}
];
With the text HIDDEN replaced with the real ones.
I used the following code, that successfully starts the paypal dialog -
[PayPalMobile preconnectWithEnvironment:PayPalEnvironmentSandbox];
PayPalPayment *payment = [[PayPalPayment alloc] init];
NSDecimalNumber *total_cost = NSDecimalNumber decimalNumberWithString:#"4.30"];
// Amount, currency, and description
payment.amount = total_cost;
payment.currencyCode = #"USD";
payment.shortDescription = #"test";
// Use the intent property to indicate that this is a "sale" payment,
// meaning combined Authorization + Capture. To perform Authorization only,
// and defer Capture to your server, use PayPalPaymentIntentAuthorize.
payment.intent = PayPalPaymentIntentSale;
// Check whether payment is processable.
if (!payment.processable) {
[self display_message: #"Payment could not be processed. This can happen for a variety of reasons, i.e. the payment amount was negative, etc. Please contact us if you believe you have received this message in error."];
return;
}
// Create a PayPalPaymentViewController.
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfiguration
delegate:self];
// Present the PayPalPaymentViewController.
[self presentViewController:paymentViewController animated:YES completion:nil];
The paypal dialog appears but then displays a "can't communicate with servers error, try again later".
the following appears on the xcode console -
2014-03-25 10:42:22.432 PayPal SDK: Request has failed with error:
pp_service_error_json_parse_error - System error. Please try again later. (500) | PayPal Debug-ID: a26da2c300c31 | Details: (
{
"ns_error" = "Error Domain=NSCocoaErrorDomain Code=3840 \"The operation couldn\U2019t be completed. (Cocoa error 3840.)\" (No value.) UserInfo=0xbadecd0 {NSDebugDescription=No value.}";
}
).
so QUESTION (1) any ideas why this is happening.
and QUESTION (2) after this works and I can make a payment, do I then need to confirm the payment info returned from paypal? i.e. do I -
Extract the payment id from the SDK callback.
Create a rest app id in paypal in addition to the classic one, and
then get an auth token via a rest call to payal. without the rest
app, i don't seem to have the secret key, etc to access the paypal
rest service.
Then use the auth token and id from (1) to make another rest call
to get the payal payment info and validate it (i.e. check the amount
is whats expected etc)?
Hope that makes sense.
PS I find the docs incredibly confusing.
EDIT: Ok, so next day without anything changed, i tried running the app again, this time different xcode console error - "invalid client credentials". nowhere in this example at https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/single_payment.md does it specify client credentials except for this part around client ids -
[PayPalMobile initializeWithClientIdsForEnvironments:
#{PayPalEnvironmentProduction : #"HIDDEN",
PayPalEnvironmentSandbox : #"HIDDEN"}
];
which i've set correctly. are their additional credentials that need to be set before launching paypal ios sdk ui?

Related

How can I receive update status(data) when I request ride with UBSDKRideRequestViewController (Uber SDK)

I have added Uber SDK in my application. I didn't request project to Request full access. It's on development. and I have issues that I can't find an answer (I'm using sandbox mode.)
Q. I need to test. If I requested and driver is already accepted. How can I know the time that he will arrive or other status e.g.arrived . and How can I send notification to my user in my application when driver is arrived. I see UBSDKRideRequestViewControllerDelegate response only error case.
this's my code.
UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
[builder setPickupToCurrentLocation];
[builder setDropoffLocation:dropoffLocation];
UBSDKRideParameters *parameters = [builder build];
NSArray<UBSDKRidesScope *> *scopes = #[UBSDKRidesScope.RideWidgets,UBSDKRidesScope.Profile,UBSDKRidesScope.Request];
UBSDKLoginManager *loginManager = [[UBSDKLoginManager alloc] init];
UBSDKRideRequestViewController *vc = [[UBSDKRideRequestViewController alloc] initWithRideParameters:parameters loginManager:loginManager];
vc.title = #"Uber";
vc.delegate = self;
please advice thanks.
Currently, the Ride Request Widget does not provide you notifications for changes in trip status. You can, however, get the status of the current trip by using a RidesClient and calling fetchCurrentRide which will give you details about the current trip. In order to access trips from the widget on this endpoint, however, you will need the all_trips scope. This will require you to handle login separately from the RideRequestViewController. You can use the LoginButton or LoginManager to request the AllTrips and RideWidgets RidesScopes
In terms of testing, you can update the status of a sandbox trip by making a PUT request to the /v1/sandbox/requests/{request_id} endpoint with a JSON body in the form {"status": "accepted"} (replacing the status you want to see). This status change would then be reflected in your app. You can find more information on the sandbox on the Uber Developer Site

FBSDKGameRequestDialog with FBSDKGameRequestFilterAppNonUsers error

I need to implement game invitations (ie. inviting friends who are not users of the app to try the app) on an iOS app (which already has a working Facebook login system). There seems to be several possible ways of doing this, each with their own different requirements. FBSDKGameRequestDialog seems like a promising way of doing this. The tutorial at https://developers.facebook.com/docs/games/services/gamerequests says:
"Alternatively, by specifying app_non_users, the sender will only see friends who have previously not authenticated the app. This should be used when using requests for inviting new users to the game."
This seems to be exactly what I'm looking for. I therefore tried this:
FBSDKGameRequestContent* content = [[FBSDKGameRequestContent new] autorelease];
content.actionType = FBSDKGameRequestActionTypeSend;
content.filters = FBSDKGameRequestFilterAppNonUsers;
content.message = #"something";
content.title = #"something";
content.objectID = #"1"; // No idea what to put here
FBSDKGameRequestDialog* dialog = [[FBSDKGameRequestDialog new] autorelease];
dialog.content = content;
dialog.delegate = self;
NSError* error = nil;
if(![dialog validateWithError: &error])
NSLog(#"%#", error);
else
[dialog show];
The dialog launches, but calls the delegate with an error, namely:
Error Domain=com.facebook.sdk.share Code=100 "(null)" UserInfo={com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Invalid fbid.}
That error message is not very helpful, nor can I find anywhere why it's happening, or what the exact requirements are for this to be possible. (Yes, I am logged successfully into Facebook. Everything else is working just fine. I have no idea where that "Invalid fbid" is coming from.)
The same tutorial page offers an alternative to do this, by requesting a list of invitable friends explicitly, and using your own GUI. However, it says:
"This feature is only available to games with a presence on Facebook Desktop"
Obviously it doesn't bother telling what that means, or give a link to further information. And of course making the request doesn't work. (The error says "please set a Canvas URL in your app's settings", which I have no idea what it means or how to do it, even after browsing Facebook's own documentation and googling.)
Either way, I would prefer the SDK's own dialog for this, as it's much less work.
objectId refers to the "Open Graph object ID of the object being sent.". Lets say I am sending you 100 Coins of your in-app currency, then this would be the ID of the object you created for that "gift".
You don't have to provide a value for it if you are not planning to send around in-game items, and in your example, 1 is obviously not a valid ID for an object. The message could be more descriptive though.

PayPal Error when remove setEnviroment

I am implementing the PayPal SDK. Here is my code:
[PayPalPaymentViewController setEnvironment:PayPalEnvironmentNoNetwork];
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:kPayPalClientId
receiverEmail:kPayPalReceiverEmail
payerId:nil
payment:payment
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
Everything works fine but when I remove:
[PayPalPaymentViewController setEnvironment:PayPalEnvironmentNoNetwork];
I get this error message:
Request has failed with error:"invalid_client - System error (invalid_client). Please try again later.
details: (
{
"error_description" = "The client credentials are invalid";
}
)"
and an alertview pops up:
Any help will be appreciated.
Thank you!
When you remove "noNetwork" environment, the SDK attempts to communicate with the PayPal servers using the clientId from your code. The default environment is production. Make sure you are including the clientId for Live in your code. You can also set the environment to use sandbox as well, which requires a different clientId. You can get these clientIds at https://developer.paypal.com/

Giving system error please try again letter (id 520002) in iOS when trying to pay US customer with paypal

I successfully integrated PayPal MPL library in ios. And working perfectly . But when i try to pay to the US client it gives error "System error.Please try again letter .(ID 520002)". I am using this code to make payment.
PayPal *ppMEP = [PayPal getPayPalInst];
ppMEP.shippingEnabled = true;
ppMEP.dynamicAmountUpdateEnabled = TRUE;
ppMEP.feePayer = FEEPAYER_EACHRECEIVER;
ppMEP.delegate=self;
PayPalPayment *currentPayment = [[PayPalPayment alloc] init];
currentPayment.paymentCurrency = #"USD";
currentPayment.paymentType = TYPE_SERVICE;
currentPayment.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString
currentPayment.recipient =recipientString;
currentPayment.merchantName = [NSStringstringWithFormat:#"%#xxxRoyalties%#",merchantNameString,setMonthsButtonTitle];
[ppMEP checkoutWithPayment:currentPayment];
I also attach the a pic of error.
After lot of google search and some conversion with PayPal I found that it is bug. internal error with description message INTERNAL_ERROR&message=Invalid payload size. current payload size=215756, max payload size=204800. The person using MPL can use new iOS SDK . It works fine all over the places where the MPL PayPal library is working . Direct card facility is only available in US UK and CA only.

ios-Facebook SDK 3.0 Error 5 When Posting Status Update

I am trying out adding facebook integration in an app using the new (beta) facebook ios sdk 3.0. All I would like to is post a status update to facebook. I used a FBLoginView to login to facebook. I put my app id in the plist as instructed on facebook. I put in some code to post to facebook.
(void)viewDidLoad
{
[super viewDidLoad];
NSArray *perms;
perms = [NSArray arrayWithObjects:#"status_update", nil];
FBLoginView *loginview =
[[FBLoginView alloc] initWithPermissions:perms];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)poststatus:(UIButton *)sender {
NSString *message = [NSString stringWithFormat:#"Test staus update"];
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
}];
}
- (void)showAlert:(NSString *)message
result:(id)result
error:(NSError *)error {
NSString *alertMsg;
NSString *alertTitle;
if (error) {
alertMsg = error.localizedDescription;
alertTitle = #"Error";
} else {
NSDictionary *resultDict = (NSDictionary *)result;
alertMsg = [NSString stringWithFormat:#"Successfully posted '%#'.\nPost ID: %#",
message, [resultDict valueForKey:#"id"]];
alertTitle = #"Success";
}
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
message:alertMsg
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
The odd thing is, this code works ONCE. After authenticating the user for the first time, I can post ONE status update successfully. After that, all subsequent attempts will fail with a FBiOSSDK error 5 (in the console, Error: HTTP status code:400). The only way to fix this is to remove the app from the facebook account and re-authenticate. I'm not sure what the problem is. I looked online for solutions but couldn't find anything. If anyone knows how to fix this, please let me know. Thanks
com.facebook.sdk error 5 is always irritating while working with Facebook iOS sdk. Most of the times it comes with addional in console Error: HTTP status code:400. Its a perception that there is a bug in Facebook iOS sdk that produces this error randomly. I think this error occurs for some certain reasons and sdk do not provide actual reason of error when it occurs.
Several Possible Reasons
Every request in sdk is accomplished with completion blocks that we actually pass as argument in completionHandler. This error occurs when a block is in progress and made another request. A simple example might be If you have written request to post on Facebook (startForPostStatusUpdate::) on some button action. On single button tap it would work fine but if you double tap on button it will throw this error com.facebook.sdk error 5
If you are trying to post when your current session is not opened. e.g. Once sign in with Facebook then kill the app then reopen and then try to share on Facebook, Result -> com.facebook.sdk error 5. In this case try to reopen session using
Facebook do not allow same status to be posted repeatedly, they think it might be some kind of spam e.g. If you are trying to update status and you have hard coded a string lets say #”This is a test status update” you are posing again and again. After 5 to 10 attempts they wont allow you to do anymore. Resulting com.facebook.sdk error 5. If this is the scenario you should change your status string and try updating.
Facebook has defined a limit for a particular user to post status using sdk. e.g If you are trying to update status and you have done lets say 15 to 20 status updates. They wont let you do more Resulting -> com.facebook.sdk error 5. In this scenario try to unauthorize the app from your Facebook account and reauthorize it OR try using other Facebook account
It seems there might be no answer to the issue. I have checked FB samples coming with SDK, in these examples also the same error happens. So it means after few status updates (15-20) Facebook reaches limits for that particular user. If you log-out for that user and log-in as another user, you can successfully post.
If I will find any extension to limit settings I will reply.
Also Facebook doesn't allow for the same Post.
Use a proxy !
FB ios SDK is just a wrap to an HTTP request to graph.facebook.com/....?access_token=.....
So you can easily replicate the request or use an HTTP proxy to see the real server answer (which is not error 5 !).

Resources