When I try to process the transaction through the PayPal MPL for adaptive payments , I am getting "Invalid Parameter SubTotal" error. It works perfectly if amount is < 10000 but not if amount is > 10000. Here is my code
-(void)processSplitPaymentWithAdminPayPalId:(NSString*)adminId sellerPayPalId:(NSString*)sellerId withAdminPercentage:(NSNumber*)adminPercentage forTotalAmount:(NSNumber*)totalAmount andShippingCharges:(NSNumber*)shippingCharges
{
DLog(#"!!!--------------------------------------");
DLog(#"AdminID: %#",adminId);
DLog(#"SellerID: %#",sellerId);
DLog(#"Admin Percentage: %#",adminPercentage);
DLog(#"Total Amount: %#",totalAmount);
DLog(#"Shipping Charges: %#",shippingCharges);
DLog(#"!!!--------------------------------------");
PayPal *ppMEP = [PayPal getPayPalInst];
ppMEP.shippingEnabled = FALSE;
ppMEP.dynamicAmountUpdateEnabled = FALSE;
ppMEP.feePayer = FEEPAYER_EACHRECEIVER;
PayPalAdvancedPayment *payment = [[[PayPalAdvancedPayment alloc] init] autorelease];
payment.paymentCurrency = #"AUD";
payment.receiverPaymentDetails = [NSMutableArray array];
NSArray *emails = nil;
if ([adminPercentage doubleValue]>0.0) {
emails = [[NSArray alloc]initWithObjects:adminId,sellerId, nil];
}
else {
emails = [[NSArray alloc]initWithObjects:sellerId, nil];
}
for (int i = 0; i < emails.count; i++)
{
PayPalReceiverPaymentDetails *details = [[[PayPalReceiverPaymentDetails
alloc] init] autorelease];
details.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease];
float adminAmount = [adminPercentage floatValue];
float sellerAmount = [totalAmount floatValue] - adminAmount;
switch (i) {
case 0:
if (emails.count>1) {
// Admin commission
details.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%.2f",adminAmount]];
NSLog(#"Admin commission::details.subTotal: %#",details.subTotal);
details.description = #"Amount paid to Admin as a Commission";
details.merchantName = [NSString stringWithFormat:#"%#",ADMIN];
}
else {
// Seller amount
details.invoiceData.totalShipping = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%#",shippingCharges]];
details.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%.2f",sellerAmount]];
NSLog(#"Seller amount 1::details.subTotal: %#",details.subTotal);
details.description = [NSString stringWithFormat:#"Amount paid to Seller :%#",self.product.sellerName];
details.merchantName = [NSString stringWithFormat:#"%# : %#",SELLER,self.product.sellerName];
}
break;
case 1:
// Seller amount
details.invoiceData.totalShipping = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%#",shippingCharges]];
details.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:#"%.2f",sellerAmount]];
NSLog(#"Seller amount 2::details.subTotal: %#",details.subTotal);
details.description = [NSString stringWithFormat:#"Amount paid to Seller :%#",self.product.sellerName];
details.merchantName = [NSString stringWithFormat:#"%# : %#",SELLER,self.product.sellerName];
break;
default:
break;
}
details.recipient = [emails objectAtIndex:i];
[payment.receiverPaymentDetails addObject:details];
}
[ppMEP advancedCheckoutWithPayment:payment];
[emails release];
}
Here is the values that I am using to process the transaction
2013-07-24 11:28:20.234 AppName[6602:907] !!!--------------------------------------
2013-07-24 11:28:20.236 AppName[6602:907] AdminID: admin#gmail.com
2013-07-24 11:28:20.237 AppName[6602:907] SellerID: seller#gmail.com
2013-07-24 11:28:20.239 AppName[6602:907] Admin Percentage: 2.30
2013-07-24 11:28:20.240 AppName[6602:907] Total Amount: 30000
2013-07-24 11:28:20.241 AppName[6602:907] Shipping Charges: 0
2013-07-24 11:28:20.242 AppName[6602:907] !!!--------------------------------------
When I print the subtotal of admin & seller its showing me below values
2013-07-24 12:21:44.685 AppName[6720:907] Admin commission::details.subTotal: 2.3
2013-07-24 12:21:44.687 AppName[6720:907] Seller amount 2::details.subTotal: 29997.7
So the total is 29997.7+2.3 = 30000 which is correct. Then why I am getting this error ?
I came across this question iOS - PayPal integration - "Invalid parameter Subtotal" error which tells that there is a limit of 10000. Is this limit causing me this error ?
I am getting this error in LIVE ENVIRONMENT of Paypal. Thanks.
UPDATE
I tested new transaction with AU$12700 & I got the same error. So I think its a limit issue. Can any one confirm this ?
That's correct - here are the limits for each currency: https://www.paypal.com/us/webapps/helpcenter/helphub/article/?solutionId=11637&m=SRE
Related
I execute the following code to let the user choose multiple calendars to use for my notepad app. Until iOS 10.3.1, there was no problem. On 11.0.2, it was still working on actural devices. However, since 11.1 it crashes with the following error.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil'
The code is as follows. Basically, I'm opening a blank calendar chooser.
if (_eventStore == nil) {
_eventStore = [[EKEventStore alloc] init];
}
// the selector is available, so we must be on iOS 6 or newer
[_eventStore requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error)
{
// display error message here
}
else if (!granted)
{
// display access denied error message here
}
else
{
// access granted
EKCalendarChooser *calendarChooser = [[EKCalendarChooser alloc]
initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple
displayStyle:EKCalendarChooserDisplayAllCalendars
eventStore:_eventStore];
calendarChooser.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
calendarChooser.delegate = self;
calendarChooser.showsCancelButton = YES;
calendarChooser.showsDoneButton = YES;
NSSet *calendarSet = [[NSSet alloc] init];
calendarChooser.selectedCalendars = calendarSet;
UINavigationController *sub = [[UINavigationController alloc] initWithRootViewController:calendarChooser];
sub.navigationBar.barStyle = UIBarStyleDefault;
sub.toolbar.barStyle = UIBarStyleDefault;
[self presentViewController:sub animated:YES completion:nil];
//ios11 crashes after this
}
});
}];
Thanks for your help.
It turns out that EKCalendarChooserDisplayAllCalendars was causing the crash. Although it's not ideal, now I can avoid the crash when iOS is 11.1 or higher.
EKCalendarChooserDisplayStyle displayStyle = EKCalendarChooserDisplayAllCalendars;
if (#available(iOS 11.1, *)) {
displayStyle = EKCalendarChooserDisplayWritableCalendarsOnly;
}
EKCalendarChooser *calendarChooser = [[EKCalendarChooser alloc]
initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple
displayStyle:displayStyle
eventStore:eventStore];
I have an app written here is set a fixed reference Day,after this day i want to get an Alert !
with this code I set the date and time : here Day 3 (Thuesday) and hour 11.
this works great! with an Timer in viewDidload my navigationItem.title shows Day/Hour/Minutes to the target day...
now i will set a Timer to this Day/Time, when i open my app after Thuesday (Wednesday or Thursday) the timer is 0 and the Alert shows!
with :
NSString *currentTimestamp = [NSString stringWithFormat:#"%.f", [resetTime timeIntervalSince1970]];
_epochTimeer.text = currentTimestamp;
i convert the Target time to epoch Time for my timer!
- (void) resetTimer:(id)sender {
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:[NSLocale currentLocale]];
NSDateComponents *nowComponents = [gregorian components:NSYearCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:today];
[nowComponents setWeekday:3]; //2 = Monday 3 di 4 = mi 5 = do 6 = fr 7 = sa
[nowComponents setWeek: [nowComponents week]+ 1 ]; //Next week [nowComponents week] + 1]
[nowComponents setHour:11]; //8a.m.
[nowComponents setMinute:0];
[nowComponents setSecond:0];
NSDate *resetTime = [gregorian dateFromComponents:nowComponents];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:#"dd-MM-YYYY HH:mm:ss"];
NSDate *date1 = today;
NSDate *date2 = resetTime;
NSTimeInterval interval = [date2 timeIntervalSinceDate:date1];
int days = (int)interval / 86400;
int hours = (interval / 3600)- (days * 24);
int minutes = ((interval / 60) - (days * 24 * 60) -(hours * 60));
int sekunden = (days * 86400) + (hours * 3600) +(minutes * 60);
NSString *timeDiff = [NSString stringWithFormat:#"%02d Tage : %02d Std : %02d Min",days, hours, minutes];
self.navigationItem.title = [NSString stringWithFormat:#"%#",timeDiff];
NSString *currentTimestamp = [NSString stringWithFormat:#"%.f", [resetTime timeIntervalSince1970]];
_epochTimeer.text = currentTimestamp;
NSLog(#"timer: %#",timeDiff);
NSLog(#"timer: %#",currentTimestamp);
}
how can I set my timer with this epoch time or the target Day/time?
i am a beginner with timer and NSDate and I do not understand how I can write the code!
or is there a completely different solution to get my Alert after the Target day when i open my APP!
Thanks Jürgen
Sorry for my bad English ..:-)
Thanks for Helping, i Add your Code and Set the localNotification.fireDate to resetTime:
- (void) resetTimer:(id)sender {
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:[NSLocale currentLocale]];
NSDateComponents *nowComponents = [gregorian components:NSYearCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:today];
[nowComponents setWeekday:7]; //2 = Monday 3 di 4 = mi 5 = do 6 = fr 7 = sa
[nowComponents setWeek: [nowComponents week]]; //Next week [nowComponents week] + 1]
[nowComponents setHour:9]; //8a.m.
[nowComponents setMinute:25];
[nowComponents setSecond:0];
NSDate *resetTime = [gregorian dateFromComponents:nowComponents];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:#"dd-MM-YYYY HH:mm:ss"];
NSDate *date1 = today;
NSDate *date2 = resetTime;
NSTimeInterval interval = [date2 timeIntervalSinceDate:date1];
int days = (int)interval / 86400;
int hours = (interval / 3600)- (days * 24);
int minutes = ((interval / 60) - (days * 24 * 60) -(hours * 60));
int sekunden = (days * 86400) + (hours * 3600) +(minutes * 60);
NSString *timeDiff = [NSString stringWithFormat:#"%02d Tage : %02d Std : %02d Min",days, hours, minutes];
_showTimer.text = [NSString stringWithFormat:#"%02d",sekunden];
self.navigationItem.title = [NSString stringWithFormat:#"%#",timeDiff];
NSString *currentTimestamp = [NSString stringWithFormat:#"%.f", [resetTime timeIntervalSince1970]];
destinationDate = [NSDate dateWithTimeIntervalSince1970:1425981600];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate =resetTime;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
NSLog(#"timer: %#",timeDiff);
NSLog(#"timer: %#",currentTimestamp);
}
and this for my Alert :
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
// code to display an alert here
SCLAlertView *alert = [[SCLAlertView alloc] init];
alert.backgroundType = Blur;
UIColor *color = [UIColor colorWithRed:52/255.0 green:222/255.0 blue:192/255.0 alpha:255/255.0];
[alert showCustom:self image:[UIImage imageNamed:#"geist"] color:color title:NSLocalizedString(#"Auto Reset", nil) subTitle:NSLocalizedString(#"Automatischer Reset Aktiviert!", nil) closeButtonTitle:#"OK" duration:0.0f];
}
when the time has expired and i start my App ... the Alert is not and it does not happen..
I need to do is activate the Notification somewhere?
thanks
Ok i have added your code now in the AppDelegate.m
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIAlertView* alert= [[UIAlertView alloc]initWithTitle:#"My App"
message:#"Reset"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
}}
now it works, when i start my app the Alert shows, but it Loop Blinking and i can't Klick OK!
what is this now...?
This can be done by using NSLocalNotification
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate =<target date>;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
// code to display an alert here
}
my app won't stop sending the notification I set for a specific time until I opened the app. It will send me like every 2 minutes or so to kind of remind me...
(void)applicationDidEnterBackground:(UIApplication *)application {
NSCalendar *calendar3 = [NSCalendar currentCalendar];
NSDateComponents *components3 = [calendar3 components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]];
[components3 setHour:21];
[components3 setMinute:30];
UIApplication *app3 = [UIApplication sharedApplication];
UILocalNotification *notifyAlarm3 = [[UILocalNotification alloc] init];
if (notifyAlarm3) {
notifyAlarm3.fireDate = [calendar3 dateFromComponents:components3];
notifyAlarm3.timeZone = [NSTimeZone defaultTimeZone];
notifyAlarm3.repeatInterval = NSDayCalendarUnit;
notifyAlarm3.soundName = #"not.wav";
notifyAlarm3.alertBody = #"Hello";
[app3 scheduleLocalNotification:notifyAlarm3];
}
}
(void)applicationWillEnterForeground:(UIApplication *)application {
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
if ([oldNotifications count] > 0) {
[app cancelAllLocalNotifications];
}
}
Looking forward to response!
I want to add event for 55 year from current date.Using below code for iOS 6,event is added in calendar with event name "New Event" and event was set to all day.This is not correct as per my code.Code is working perfectly for events which are below 55 year from current date.
-(void)addEvent{
EKEventStore *es = [[EKEventStore alloc] init];
EKAuthorizationStatus authorizationStatus = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];
BOOL needsToRequestAccessToEventStore = (authorizationStatus == EKAuthorizationStatusNotDetermined);
if (needsToRequestAccessToEventStore) {
[es requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted) {
[self loadAllEventsForStore:es];
} else {
NSLog(#"Not Granted");
}
}];
} else {
BOOL granted = (authorizationStatus == EKAuthorizationStatusAuthorized);
if (granted) {
[self loadAllEventsForStore:es];
} else {
NSLog(#"Not Granted");
}
}
}
-(void)loadAllEventsForStore:(EKEventStore*)store{
[self setEventForStore:store yearfromCurrentDate:55];
[self setEventForStore:store yearfromCurrentDate:56];
}
-(void)setEventForStore:(EKEventStore*)store yearfromCurrentDate:(int)year{
EKEvent *event = [EKEvent eventWithEventStore:store];
event.title = [NSString stringWithFormat:#"Event %d",eventid++];
NSLog(#"=========== %# ==============", event.title);
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps = [NSDateComponents new];
[comps setDay:05];
[comps setMonth:1];
[comps setYear:year];
NSDate *startDate = [calendar dateByAddingComponents:comps toDate:[NSDate date] options:0];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"dd-MM-yyyy"];
NSString *startDateString = [dateFormatter stringFromDate:startDate];
NSLog(#"Start Date = %#", startDateString);
event.startDate = startDate;
NSDate *endDate = [event.startDate dateByAddingTimeInterval:60*60];;
[dateFormatter setDateFormat:#"dd-MM-yyyy"];
NSString *endDateString = [dateFormatter stringFromDate:endDate];
NSLog(#"End Date date = %#", endDateString);
event.endDate = endDate;
[event setCalendar:[store defaultCalendarForNewEvents]];
NSError *err = nil;
BOOL save=[store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
if (save && err==nil) {
NSLog(#"Event %# is added sucessfully",event.title);
}else
NSLog(#"Event %# is not added",event.title);
NSLog(#"==================================");
}
screenshot of calendar app after adding events programmatically:
Console Output:
2014-01-22 15:13:08.789 TestApp[19094:907] =========== Event 0 ==============
2014-01-22 15:13:08.796 TestApp[19094:907] Start Date = 27-02-2069
2014-01-22 15:13:08.798 TestApp[19094:907] End Date date = 27-02-2069
2014-01-22 15:13:08.884 TestApp[19094:907] Event Event 0 is added sucessfully
2014-01-22 15:13:08.886 TestApp[19094:907] ==================================
2014-01-22 15:13:08.889 TestApp[19094:907] =========== Event 1 ==============
2014-01-22 15:13:08.893 TestApp[19094:907] Start Date = 27-02-2070
2014-01-22 15:13:08.896 TestApp[19094:907] End Date date = 27-02-2070
2014-01-22 15:13:08.923 TestApp[19094:907] Event Event 1 is added sucessfully
2014-01-22 15:13:08.924 TestApp[19094:907] ==================================
I am using TAPKU calendar in my iOS application. I want to add some more marks on date tile after loading complete data in tapku calendar.
I am getting some additional data from async process and I want to mark that data also on calendar.
How can i do this. Thanks in advance.
This is indeed possible, as an example for the day calendar view, modify _refreshDataPageWithAtIndex to be like this:
- (void) _refreshDataWithPageAtIndex:(NSInteger)index{
UIScrollView *sv = self.pages[index];
TKTimelineView *timeline = [self _timelineAtIndex:index];
CGRect r = CGRectInset(self.horizontalScrollView.bounds, HORIZONTAL_PAD, 0);
r.origin.x = self.horizontalScrollView.frame.size.width * index + HORIZONTAL_PAD;
sv.frame = r;
timeline.startY = VERTICAL_INSET;
for (UIView* view in sv.subviews) {
if ([view isKindOfClass:[TKCalendarDayEventView class]]){
[self.eventGraveYard addObject:view];
[view removeFromSuperview];
}
}
if(self.nowLineView.superview == sv) [self.nowLineView removeFromSuperview];
if([timeline.date isTodayWithTimeZone:self.timeZone]){
NSDate *date = [NSDate date];
NSDateComponents *comp = [date dateComponentsWithTimeZone:self.timeZone];
NSInteger hourStart = comp.hour;
CGFloat hourStartPosition = hourStart * VERTICAL_DIFF + VERTICAL_INSET;
NSInteger minuteStart = round(comp.minute / 5.0) * 5;
CGFloat minuteStartPosition = roundf((CGFloat)minuteStart / 60.0f * VERTICAL_DIFF);
CGRect eventFrame = CGRectMake(self.nowLineView.frame.origin.x, hourStartPosition + minuteStartPosition - 5, NOB_SIZE + self.frame.size.width - LEFT_INSET, NOB_SIZE);
self.nowLineView.frame = eventFrame;
[sv addSubview:self.nowLineView];
}
if(!self.dataSource) return;
timeline.events = [NSMutableArray new];
[self.dataSource calendarDayTimelineView:self eventsForDate:timeline.date andEvents:timeline.events success:^{
[timeline.events sortUsingComparator:^NSComparisonResult(TKCalendarDayEventView *obj1, TKCalendarDayEventView *obj2){
return [obj1.startDate compare:obj2.startDate];
}];
[self _realignEventsAtIndex:index];
if(self.nowLineView.superview == sv)
[sv bringSubviewToFront:self.nowLineView];
}];
}
and then change your eventsForDate function to look like this:
- (void) calendarDayTimelineView:(TKCalendarDayView*)calendarDayTimeline eventsForDate:(NSDate *)eventDate andEvents:(NSMutableArray *)events success:(void (^)())success {
[Model doSomethingAsync andSuccess:^(NSArray *classes) {
// .. Add stuff to events..
success();
}];
}
I'm assuming the pattern for the other controls is very similar. The premise is you're waiting to continue the formatting/layout flow til you get your data.