PayPal Error when remove setEnviroment - ios

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/

Related

how to setup receiverEmail with paypal-iOS-SDK 2.12.9

I'm new in using paypal-iOS-SDK. I want to test my app about the payment part. I use paypal SDK as the payment platform.My code like this:
// Create a PayPalPaymentViewController.
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment configuration:self.payPalConfiguration delegate:self];
And I check the PayPalConfiguration class.I didn't find any property to setup the receiverEmail. I check out some old document.And find the code like this:
// Create a PayPalPaymentViewController with the credentials and payerId, the PayPalPayment
// from the previous step, and a PayPalPaymentDelegate to handle the results.
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:#"YOUR_CLIENT_ID"
receiverEmail:#"YOUR_PAYPAL_EMAIL_ADDRESS"
payerId:aPayerId
payment:payment
delegate:self];
who can tell me how to setup the receiverEmail for receive payment using the latest paypal-iOS-SDK(2.12.9).Thank you very much!
You do not need to set a receiverEmail in the 2.x versions of the mSDK. Instead, you should set your client ID as documented in the SDK. You can get a client ID by going to the PayPal Developer dashboard portal site and creating an application if you have not already done so.
The client ID is tied to the business account which will receive the payments. Be sure to use the right client ID for each environment (e.g. sandbox vs. live/production).

ConnectionID is in incorrect formate. SignalR

I usesignalR latest library. I downloaded signalR library from gitHub SignalR gitHub link and installed pod file in my app. I am working on iOS end. I don't know about asp.net. The only url is provided to me for integration. Here is my code
__weak SRConnection *connection = [SRConnection connectionWithURL:SIGNALR_PATH];
[connection addValue:[[NSUserDefaults standardUserDefaults] objectForKey:kAccessToken] forHTTPHeaderField:#"MyAuthentication"];
connection.received = ^(NSString * data) {
NSLog(#"%#",data);
};
connection.started = ^{
[connection send:#"hello world"];
};
[connection start];
Connection open successfully but When I get try to send message it gives me an error "The ConnectionId is in incorrect format".
I am using latest library of signalR. I don't know what I need to authorised. Is only url enough for that? Or will need to add accessToken that I get on login?.
Please help me what I need for integrating signalR. I searched a lot but couldn't find any clear information.

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

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?

QuickBlox TSendPush error

My ios app is running into a problem using the QuickBlox sdk's TSendPush. -(void)completedWithResult:(Result*)result gets called but result.success is false.
The debug info from the call is:
parameters:{
"event[environment]" = development;
"event[event_type]" = "one_shot";
"event[message]" = "payload=eyJhcHMiOnsic291bmQiOiJkZWZhdWx0IiwiYWxlcnQiOiJIZWxsbyBtYW4hIn19";
"event[notification_type]" = push;
"event[push_type]" = apns;
"event[user][ids]" = 673543;
}
raw body:event[environment]=development&event[event_type]=one_shot&event[message]=payload%3DeyJhcHMiOnsic291bmQiOiJkZWZhdWx0IiwiYWxlcnQiOiJIZWxsbyBtYW4hIn19&event[notification_type]=push&event[push_type]=apns&event[user][ids]=673543
and I get "Forbidden. Need user." 673543 is a valid user (well, a user of that ID is listed in the QuickBlox admin panel)
Any ideas gratefully received
It means that you have to login and do on user behalf in order to send push notifications
just do
[QBUsers logInWithUserLogin:#"igorigor" password:#"igorigor" delegate:self];
or
[QBUsers logInWithUserEmail:#"qbuserqqqq34r5#gmail.com" password:#"qbuserr345" delegate:self];
After this you can use TSendPush method
Solved. The sending user wasn't logged in correctly (I had been using their Facebook username but for some reason Facebook wasn't sending it to me)

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