how to setup receiverEmail with paypal-iOS-SDK 2.12.9 - ios

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).

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

How do I use an iOS app's bundle identifier to 'authorize' upload to Google Cloud Storage?

Our service is using Google App Engine as our backend, and we're now implementing an upload-function for images etc.
Using the answers from several different questions here on stack, I have made it working, but not completely as I want. We are not using the built-in OAuth etc, and for now we want the storage to be public, but not entirely public. We would like to limit it to users of our own app (I.E no authentication). In the Cloud-console we can create an API-key for iOS. When doing this, we copy the API-key to the app, and pass it along with every upload-request. This is currently working, when the bucket-permission is set to allUsers - WRITE
However, inside the API-key, we can supply our app's own Bundle Identifier, so that, supposedly, only requests from our app is allowed. (App Store ID/URL is also permitted, apparently).
Adding this bundle-id does nothing as long as the bucket has the permission allUsers - WRITE. If I change the bundle-id to not match the actual bundle-id, it still works. So which permission should it use for the bucket to make the bundle-id in the API-key apply? And what should be sent along in the upload-code on iOS (acl?)?.
If I remove the allUsers-permission, and use something else, I get this error when trying to upload:
{message:"There is a per-IP or per-Referer restriction configured
on your API key and the request does not match these
restrictions. Please use the Google Developers Console
to update your API key configuration if request from this
IP or referer should be allowed." data:[1] code:403}}
This is how I'm using it right now (though I have tried several different things, all picked up from different questions/answers):
GTLServiceStorage *serv = [[GTLServiceStorage alloc] init];
serv.additionalHTTPHeaders = [NSDictionary dictionaryWithObjectsAndKeys:
#"[my project id]", #"x-goog-project-id",
#"application/json-rpc", #"Content-Type",
#"application/json-rpc", #"Accept", nil];
serv.APIKey = #"[my iOS API key, gotten from console, (linked to bundle-id?)]";
serv.retryEnabled = YES;
GTLStorageBucket *bucket = [[GTLStorageBucket alloc] init];
bucket.name = #"[my bucket]";
GTLUploadParameters *params = [GTLUploadParameters uploadParametersWithFileHandle:fileHandle MIMEType:#"image/jpeg"];
GTLStorageObject *storageObject = [[GTLStorageObject alloc] init];
storageObject.name = #"testFile.jpg";
//I have no idea what I'm doing with the following stuff, but I've tried several things:
GTLStorageObjectAccessControl *objAccessControl
= [GTLStorageObjectAccessControl new];
//This is working
objAccessControl.entity = #"allUsers";
objAccessControl.email = #"[my app-id]#project.gserviceaccount.com";
objAccessControl.role = #"OWNER";
//If I try this instead, it is not working.
//objAccessControl.domain = #"[my app-id].apps.googleusercontent.com";
//objAccessControl.role = #"WRITER";
//Probably because it's bullshit, I have no idea what I'm doing.
storageObject.acl = #[objAccessControl];
[...] //Bucket and upload and stuff. It seems like it's the ACL-thing above that's not working..
It seems like I have to connect the permissions on the bucket to the iOS API Key somehow, but I don't know if it's even possible.
What I want: All users to be able to use the cloud, given that they are requesting it from my iOS app.
As this question never got an answer I'll add one here, based on the information currently in the post.
The reason you got the error 'There is a per-IP or per-Referer restriction..' when calling the GCS API with the iOS API Key is simply because the GCS API doesn't work with API Keys for private data, only Bearer Tokens (ie. using OAuth). There isn't anything you could have done to make the API Key work with the GCS API directly with private data. The reason it worked when you had 'allUsers - WRITE' set as the ACL is simply because that ACL allows public access.
To access the private data without user intervention requires a Service Account, however the Google APIs Objective-C Client only supports OAuth2 Client IDs. The rationale being that Service Accounts are intended for server-side authentication only. Using a Service Account in a client would involve distributing the private key along with the app, which could easily be compromised. For reference, here's a sample of how you might authorize the GCS service using OAuth:
NSString *keychainItemName = #"My App";
NSString *clientID = <your-client-id>;
NSString *clientSecret = <your-client-secret>;
// How to check for existing credentials in the keychain
GTMOAuth2Authentication *auth;
auth = [GTMOAuth2WindowController authForGoogleFromKeychainForName:kKeychainItemName
clientID:clientID
clientSecret:clientSecret];
...
// How to set up a window controller for sign-in
NSBundle *frameworkBundle = [NSBundle bundleForClass:[GTMOAuth2WindowController class]];
GTMOAuth2WindowController *windowController;
windowController = [GTMOAuth2WindowController controllerWithScope:kGTLAuthScopeStorageDevstorageFullControl
clientID:clientID
clientSecret:clientSecret
keychainItemName:kKeychainItemName
resourceBundle:frameworkBundle];
[windowController signInSheetModalForWindow:[self window]
completionHandler:^(GTMOAuth2Authentication *auth,
NSError *error) {
if (error == nil) {
self.storageService.authorizer = auth;
}
}];
...
// Initialize service with auth
GTLServiceStorage *serv = [[GTLServiceStorage alloc] init];
serv.authorizer = auth;
All of this was taken from the storage sample on the google-api-objectivec-client GitHub page, so you can refer to it for a complete example with context.
This still leaves the question of how to implement access to GCS from iOS without user authorization. The short answer to this is that the iOS Key can be used to restrict access to your own backend API hosted on Google Cloud Endpoints, and that backend application can authorize against GCS using a Service Account (usually the Application Default Service Account). The Cloud Storage Client Library Examples page has samples using the default credentials for different languages.
Further details on how to implement an Endpoints API for this purpose are probably getting outside of the scope of this question, but this should serve as a good starting point.

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?

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/

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)

Resources