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;
Related
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?
Hope you are doing well.
I am trying to integrate CitrusPay SDK to my iPhone application. How can i integrate CitrusPay Direct payment without asking user to login to citrus pay.
I want to give options to user like :
Pay using Citrus Wallet
Pay using Creditcard/Debit Card
Pay using Net banking
If user would like to pay using Citrus Wallet then i will ask user to login to citrus using their credentials. If they will go with 2nd or 3rd option like pay using Credit Card/Debit Card or net banking then they don't need to login.
I want to implement this function in my app using CitrusPay SDK. Can you point out me for the code of this?
I already have a demo of the Citrus pay and i already checked it.
https://github.com/citruspay/citruspay-ios-sdk
I downloaded the demo from the above link.
Please help me out for this.
[CitrusPaymentSDK enableDEBUGLogs];
CTSKeyStore *keyStore = [[CTSKeyStore alloc] init];
keyStore.signinId = SignInId;
keyStore.signinSecret = SignInSecretKey;
keyStore.signUpId = SubscriptionId;
keyStore.signUpSecret = SubscriptionSecretKey;
keyStore.vanity = VanityUrl;
[CitrusPaymentSDK initializeWithKeyStore:keyStore environment:CTSEnvSandbox];
[CitrusPaymentSDK enableDEBUGLogs];
//CC, DC payments
CTSElectronicCardUpdate *creditCard = [[CTSElectronicCardUpdate alloc] initCreditCard]; //for debit card use > initDebitCard
creditCard.number = #"";
creditCard.expiryDate = #"XX/XX"; //only mm/yyyy format
creditCard.scheme = [CTSUtility fetchCardSchemeForCardNumber:creditCard.number]; //fetch card scheme
creditCard.ownerName = #"XXXXXXXX"; // no special characters here
creditCard.cvv = #"XXX";
CTSPaymentLayer *paymentLayer = [CitrusPaymentSDK fetchSharedPaymentLayer];
CTSPaymentDetailUpdate *paymentInfo = [[CTSPaymentDetailUpdate alloc] init];
[paymentInfo addCard:creditCard];
CTSContactUpdate* contactInfo;
CTSUserAddress* addressInfo;
contactInfo = [[CTSContactUpdate alloc] init];
contactInfo.firstName = #"";
contactInfo.lastName = #"";
contactInfo.email = #"";
contactInfo.mobile = #"";
addressInfo = [[CTSUserAddress alloc] init];
addressInfo.city = TEST_CITY;
addressInfo.country = TEST_COUNTRY;
addressInfo.state = TEST_STATE;
addressInfo.street1 = TEST_STREET1;
addressInfo.street2 = TEST_STREET2;
addressInfo.zip = TEST_ZIP;
[CTSUtility requestBillAmount:#"X" billURL:BillUrl callback: ^(CTSBill *bill , NSError *error){
if(error){
dispatch_async(dispatch_get_main_queue(), ^{
});
[UIUtility toastMessageOnScreen:error.localizedDescription];
}
else {
[paymentLayer requestDirectChargePayment:paymentInfo withContact:contactInfo withAddress:addressInfo bill:bill returnViewController:self withCompletionHandler:^(CTSCitrusCashRes *citrusCashResponse, NSError *error){
dispatch_async(dispatch_get_main_queue(), ^{
// [self.indicatorView stopAnimating];
// self.indicatorView.hidden = TRUE;
});
if(error){
[UIUtility toastMessageOnScreen:error.localizedDescription];
}
else {
[UIUtility toastMessageOnScreen:[NSString stringWithFormat:#"Payment Status %#",[citrusCashResponse.responseDict valueForKey:#"TxStatus"] ]];
// [self resetUI];
}
}];
}
}];
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
Update: hideCreditCardButton has no role in this issue, it was just a coincident that when I tried it w/o credit card it worked for me but thats not the case anymore.I does work but only 20-30% of the time.
I am using PayPal iOS SDK 1.4.6. if I use paymentViewController.hideCreditCardButton = YES; it works fine but if I set this to paymentViewController.hideCreditCardButton = NO; I get the server error (ref. to image).
here's my code:
- (void)paypalPayment {
// Create a PayPalPayment
float paypalPrice =[youPay floatValue];
NSString* currencyCode = appDelegate.countryCurrency;
if ([currencyCode isEqual: #"INR"]) {
float new = [[[ExchangeRate sharedManager]getExchangeRate:#"INR" toCurrency:#"USD"]
floatValue];
paypalPrice = paypalPrice*new;
}
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:
[NSString stringWithFormat:#"%.2f",paypalPrice]];
payment.currencyCode = #"USD";
payment.shortDescription = #"Total Order";
[PayPalPaymentViewController setEnvironment:PayPalEnvironmentProduction];
// Provide a payerId that uniquely identifies a user within the scope of your system,
// such as an email address or user ID.
NSString *aPayerId = #"abc#msronline.in";
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc]
initWithClientId:kPayPalClientId
receiverEmail:kPayPalReceiverEmail
payerId:aPayerId
payment:payment
delegate:self];
paymentViewController.languageOrLocale = #"en";
paymentViewController.hideCreditCardButton = NO;
[self presentViewController:paymentViewController animated:YES completion:nil];
}
Dave from PayPal here.
That's indeed weird. You're getting this as soon as you present the viewcontroller? Is it still happening today?
From your screenshot, it looks like the SDK is still trying to get an initial connection with the PayPal server. At this early stage, the setting of hideCreditCardButton shouldn't yet affect anything.
You are using the Client ID that's designated for Production (as opposed to the Client ID designated for Sandbox), right?
Do you see anything helpful in the console log?
I have same issue and solved by change kPayPalReceiverEmail.
If you use same email as kPayPalReceiverEmail to login in paypal to send payment than this error comes.
I just change kPayPalReceiverEmail email to another one and I get successful response from paypal server.
It may help you
I am trying to implement the Paypal SDK into my iOS app. I copied the code exactly from the Readme instructions, imported the files, and linked my button to my action but when I clicked the button it gives me a "Thread 1 signal:SIGABRT" error and crashes.
Here is the Paypal code in my .m files:
- (IBAction)pay {
// Create a PayPalPayment
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:#"39.95"];
payment.currencyCode = #"USD";
payment.shortDescription = #"Product";
// Check whether payment is processable.
if (!payment.processable) {
// If, for example, the amount was negative or the shortDescription was empty, then
// this payment would not be processable. You would want to handle that here.
}
// Provide a payerId that uniquely identifies a user within the scope of your system,
// such as an email address or user ID.
NSString *aPayerId = #"someone#someone.com";
// 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:#"MY-CLIENT-ID-HERE"
receiverEmail:#"MY-EMAIL-HERE"
payerId:aPayerId
payment:payment
delegate:self];
// Present the PayPalPaymentViewController.
[self presentViewController:paymentViewController animated:YES completion:nil];
}
#pragma mark - PayPalPaymentDelegate methods
- (void)payPalPaymentDidComplete:(PayPalPayment *)completedPayment {
// Payment was processed successfully; send to server for verification and fulfillment.
[self verifyCompletedPayment:completedPayment];
// Dismiss the PayPalPaymentViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)payPalPaymentDidCancel {
// The payment was canceled; dismiss the PayPalPaymentViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)verifyCompletedPayment:(PayPalPayment *)completedPayment {
// Send the entire confirmation dictionary
NSData *confirmation = [NSJSONSerialization dataWithJSONObject:completedPayment.confirmation
options:0
error:nil];
// Send confirmation to your server; your server should verify the proof of payment
// and give the user their goods or services. If the server is not reachable, save
// the confirmation and try again later.
}
Does anyone have any ideas what the problem might be?
You know what?
cuz you use decimal number on you currency.
so you need do something in this code
// Check whether payment is processable.
if (!payment.processable) {
// If, for example, the amount was negative or the shortDescription was empty, then
// this payment would not be processable. You would want to handle that here.
}
If you in debug point you can find a keyword in payment, display, it's mean your currency will change to 40.0.
Try it.