I am using Paypal SandBox Environment. When I am opening Paypal from device i am getting this error:
Request has failed with error: pp_service_error_json_parse_error - System error. Please try again later. (403) | Details: (
{
"ns_error" = "Error Domain=NSCocoaErrorDomain Code=3840 \"JSON text did not start with array or object and option to allow fragments not set.\" UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}";
}
).
check Screenshot
Here is My code
_payPalConfig = [[PayPalConfiguration alloc] init];
_payPalConfig.acceptCreditCards = YES;
#else
_payPalConfig.acceptCreditCards = NO;
#endif
_payPalConfig.merchantName = #"";
_payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:#""];
_payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:#""];
_payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
_payPalConfig.payPalShippingAddressOption = PayPalShippingAddressOptionPayPal;
self.environment = PayPalEnvironmentSandbox;
nslog(#"PayPal iOS SDK version: %#", [PayPalMobile libraryVersion]);
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
// Preconnect to PayPal early
[self setPayPalEnvironment:self.environment];
}
- (void)setPayPalEnvironment:(NSString *)environment
{
self.environment = environment;
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentSandbox:PAYPAL_CLIENT_KEY}];
[PayPalMobile preconnectWithEnvironment:environment];
}
I am not getting why i am getting error.
Anyone is having solution?
Related
I am using the the iOS client quick start project hosted on https://github.com/twilio/voice-callkit-quickstart-objc
on server I am using python (as recommended on github project)
When I clicked on "Place outgoing call" it worked fine and I got "Welcome to Twilio" voice. Great!
Then I changed the code a bit and tried to make an outgoing call to specific number. Here's the modified code
Button click event
- (IBAction)placeCall:(id)sender {
NSUUID *uuid = [NSUUID UUID];
NSString *handle = #"Real Number";
[self performStartCallActionWithUUID:uuid handle:handle];
}
Here's the CallKit handle
- (void)performStartCallActionWithUUID:(NSUUID *)uuid handle:(NSString *)handle {
if (uuid == nil || handle == nil) {
return;
}
CXHandle *callHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
CXStartCallAction *startCallAction = [[CXStartCallAction alloc] initWithCallUUID:uuid handle:callHandle];
CXTransaction *transaction = [[CXTransaction alloc] initWithAction:startCallAction];
[self.callKitCallController requestTransaction:transaction completion:^(NSError *error) {
if (error) {
NSLog(#"StartCallAction transaction request failed: %#", [error localizedDescription]);
} else {
NSLog(#"StartCallAction transaction request successful");
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
callUpdate.remoteHandle = callHandle;
callUpdate.supportsDTMF = YES;
callUpdate.supportsHolding = NO;
callUpdate.supportsGrouping = NO;
callUpdate.supportsUngrouping = NO;
callUpdate.hasVideo = NO;
[self.callKitProvider reportCallWithUUID:uuid updated:callUpdate];
}
}];
}
And the number to call
- (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallAction *)action {
NSLog(#"provider:performStartCallAction:");
[[VoiceClient sharedInstance] configureAudioSession];
NSDictionary *toParam = #{#"To": #"+14805058877"};
//THIS IS WHERE WE NEED TO INSERT CALLING NUMBER
self.outgoingCall = [[VoiceClient sharedInstance] call:[self fetchAccessToken]
params:toParam
delegate:self];
if (!self.outgoingCall) {
[action fail];
} else {
self.outgoingCall.uuid = action.callUUID;
[self toggleUIState:NO];
[self startSpin];
[action fulfillWithDateStarted:[NSDate date]];
}
}
No matter what I enter in the parameter value I always get "Welcome to Twilio" msg. I need to know if I need change anything on the Python server or in the iOS client code. Please help!
Twilio developer evangelist here.
Have you set your TwiML application up correctly? The Voice Request URL should be pointing to your python server. I only ask as the message from the Python server, which comes from this line in the code, should be "Congratulations! You have made your first oubound call! Good bye." and you said it was "Welcome to Twilio"
Once you are definitely set up pointing at your Python app, once you have made your first outbound call you will get that message. Now you need to update your Python app as well as the iOS app.
You're sending a parameter To with the number you're trying to call. You need to change the Python so that it reads that number and outputs the TwiML that will dial that number.
That should look a bit like this:
#app.route('/outgoing', methods=['GET', 'POST'])
def outgoing():
resp = twilio.twiml.Response()
resp.dial(request.form['To'])
return str(resp)
Let me know if that helps at all.
Background: I used same code for iOS 8.2,8.3 it was working fine.
PKPaymentAuthorizationViewController *paymentPane = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
paymentPane.delegate = self;
[self presentViewController:paymentPane animated:TRUE completion:nil];
PaymentRequest Code:
PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
NSString *chargeApplePay=[NSString stringWithFormat:#"%.02f",pay];
PKPaymentSummaryItem *total = [PKPaymentSummaryItem summaryItemWithLabel:#"Grand Total"
amount:[NSDecimalNumber decimalNumberWithString:chargeApplePay]];
request.paymentSummaryItems = #[total];
request.countryCode = #"US";
request.currencyCode = #"USD";
request.supportedNetworks = #[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];
request.merchantIdentifier = #"valid.com.myIdentifier";
request.merchantCapabilities = PKMerchantCapability3DS;
Question: Now on iOS 8.4 when I try to present my paymentPane its value is nil somehow.
Fatal Exception: NSInvalidArgumentException Application tried to
present a nil modal view controller on target .
What I have already tried by googling and using answers from stackoverflow.
Used Checks like
[PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:#[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]
and
[PKPaymentAuthorizationViewController canMakePayments]
Checking my merchant id is valid or not.
Checking All the code I used for request is valid or not.
Check whether you've added Credit card information in your device Passbook or not.
Check whether you can make payment using your device.
Objective C :
if ([PKPaymentAuthorizationViewController canMakePayments]) {
NSLog(#"Can Make Payments");
}
else {
NSLog(#"Can't Make payments");
}
Swift :
if PKPaymentAuthorizationViewController.canMakePayments() {
NSLog(#"Can Make Payments");
}
else {
NSLog(#"Can't Make Payments");
}
Check whether you can make payment using the allowed payment networks.
Objective C :
NSArray *paymentNetworks = [NSArray arrayWithObjects:PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkAmex, nil];
if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:paymentNetworks]) {
NSLog(#"Can Make payment with your card");
}
else {
NSLog(#"Card is not supporting");
}
Swift :
let paymentNetworks = [PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]
if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(paymentNetworks) {
NSLog(#"Can Make payment with your card");
}
else {
NSLog(#"Card is not supporting");
}
I have also had similar problems when running inside the Xcode debugger. As a workaround I stop the app in Xcode and then manually start the app on the iPhone or iPad.
One drawback with this is obviously that you can't debug any issues. I've had to resort to NSLog and reading the console log.
i have some problems with PayPal sdk on iOS.I created my app at https://developer.paypal.com/webapps/developer/applications/myapps and got client id . i used paypal sample apps with my ID its working fine in mock and sandbox mode. when i am using this in my apps each time my apps moving in mock data mode i am getting response from paypal server.
{
client = {
environment = mock;
"paypal_sdk_version" = "2.2.1";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
response = {
"create_time" = "2014-08-27T10:18:57Z";
id = "PAY-8UD377151U972354RKOQ3DTQ";
intent = sale;
state = approved;
};
"response_type" = payment;
}
.i am not anle to set sandbox mode which variable i need to use .
- (void)viewDidLoad
{
// Set up payPalConfig
_payPalConfig = [[PayPalConfiguration alloc] init];
_payPalConfig.acceptCreditCards = YES;
_payPalConfig.languageOrLocale = #"en";
_payPalConfig.merchantName = #"KicksCloset Shoes, Inc.";
_payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/privacy-full"];
_payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/useragreement-full"];
_payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
// use default environment, should be Production in real life
self.environment = #"sandbox";
NSLog(#"PayPal iOS SDK version: %#", [PayPalMobile libraryVersion]);
}
this is my pay action
{
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:amountforserver];
payment.currencyCode = #"USD";
payment.shortDescription = creditsforserver;
// payment.items = items; // if not including multiple items, then leave payment.items as nil
// payment.paymentDetails = paymentDetails; // if not including payment details, then leave payment.paymentDetails as nil
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
}
// Update payPalConfig re accepting credit cards.
self.payPalConfig.acceptCreditCards = self.acceptCreditCards;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfig
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
}
your action method have issue .
just pass the environment
{
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:amountforserver];
payment.currencyCode = #"USD";
payment.shortDescription = creditsforserver;
// payment.items = items; // if not including multiple items, then leave payment.items as nil
// payment.paymentDetails = paymentDetails; // if not including payment details, then leave payment.paymentDetails as nil
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
}
self.environment = kPayPalEnvironment;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfig
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
}
and just use this
code in
-(void)viewWillAppear:(BOOL)animated{
[PayPalMobile preconnectWithEnvironment:self.environment];
}
change your paypal environment to PayPalEnvironmentSandbox
this is for sandbox mode
self.environment = PayPalEnvironmentSandbox;
if you want go with live mode..
self.environment = PayPalEnvironmentProduction;
check your PayPalMobile.h file
/// This environment MUST be used for App Store submissions.
extern NSString *const PayPalEnvironmentProduction;
/// Sandbox: Uses the PayPal sandbox for transactions. Useful for development.
extern NSString *const PayPalEnvironmentSandbox;
/// NoNetwork: Mock mode. Does not submit transactions to PayPal. Fakes successful responses. Useful for unit tests.
extern NSString *const PayPalEnvironmentNoNetwork;
Hi i am trying to integrate Paypal service but its giving error
Error :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [PayPalPaymentViewController payPalServiceManager]: unrecocnized selector sent to instance 0x12784450'
Code :
- (IBAction)buttonPaypalAction:(id)sender
{
gateway = #"Paypal";
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:[appDelegate.orderDetails objectAtIndex:6]];
payment.currencyCode = appDelegate.currencyCode;
payment.shortDescription = #"Food items";
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
}
// Update payPalConfig re accepting credit cards.
// self.payPalConfig.acceptCreditCards = self.acceptCreditCards;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment configuration:self.payPalConfig delegate:self];
// error is coming after this line...
[self presentViewController:paymentViewController animated:YES completion:nil];
}
Don't forgot to add -lc++ -ObjC in Other linker flags
I'm using the PayPal 2.0 SDK for Iphone. at the "PayPalEnvironmentSandbox" or "PayPalEnvironmentNoNetwork" it's all works perfect.
But when changing to "PayPalEnvironmentProduction" I get this very strange error, witch i can not find any documentary about what it actually means..
PayPal SDK: PayPal error: Could not find endpoint for live.dyson
My code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction : kPayPalClientId}];
}
At "PayCalssVC":
-(void)viewWillAppear:(BOOL)animated
{
[PayPalMobile preconnectWithEnvironment:PayPalEnvironmentNoNetwork];
}
-(void)payPressed
{
NSDecimalNumber *amount = [[NSDecimalNumber alloc] initWithString:[User getLoggedInUser].priceOfNewTone];
PayPalPayment *payMant = [[PayPalPayment alloc]init];
payMant.amount = amount;
payMant.intent = PayPalPaymentIntentSale;
payMant.currencyCode = #"ILS";
payMant.shortDescription = #"Song Distribution";
if (!payMant.processable) {
}
_payPalConfig.acceptCreditCards = self.acceptCreditCards;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payMant
configuration:_payPalConfig
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
}
My payClint ID is live, and the error occurs when this is called:
[PayPalMobile preconnectWithEnvironment:PayPalEnvironmentNoNetwork];
Any help would be much appreciated, thanks
Dave from PayPal here.
#PiratM, that warning message was misleading, and should not have appeared. Please ignore it. (It won't be present after our next update to the SDK.)