Skip to content

Commit

Permalink
Adding subvention emi sdk v3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Kumar2 committed Dec 12, 2016
1 parent 84ec7d2 commit 033992b
Show file tree
Hide file tree
Showing 40 changed files with 1,205 additions and 529 deletions.
1,026 changes: 548 additions & 478 deletions PayUNonSeamlessTestApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Empty file modified PayUNonSeamlessTestApp/PayU/CB/iOSCustomBrowser/CBConstant.h
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified PayUNonSeamlessTestApp/PayU/CB/iOSCustomBrowser/PUCBLoader.xib
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified PayUNonSeamlessTestApp/PayU/CB/iOSCustomBrowser/PayU_CB_SDK.h
100644 → 100755
Empty file.
Empty file.
11 changes: 10 additions & 1 deletion PayUNonSeamlessTestApp/PayU/SDK/PayU_iOS_CoreSDK/PayUConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@

#define ERROR_MEMORY_ISSUE @"Memory Issue"

#define ERROR_SUBVENTION_AMOUNT_IS_MISSING @"Subvention Amount is missing, "
#define ERROR_SUBVENTION_AMOUNT_IS_NONNUMERIC @"Subvention Amount should be a Double value example 5.00, "
#define ERROR_SUBVENTION_AMOUNT_GREATER_THAN_AMOUNT @"Subvention Amount should be less than or equal to the transaction amount, "
//#define ERROR_FREE @"Error free"


Expand Down Expand Up @@ -246,6 +249,9 @@
#define PARAM_SHIPPING_PHONE @"shipping_phone"
#define PARAM_OFFER_KEY @"offer_key"
#define PARAM_USER_CREDENTIALS @"user_credentials"
#define PARAM_SUBVENTION_AMOUNT @"subvention_amount"
#define PARAM_SUBVENTION_ELIGIBILITY @"subvention_eligibility"
#define PARAM_IS_SUBVENT @"is_subvent"

#define PARAM_DEVICE_TYPE @"device_type"
#define PARAM_INSTRUMENT_TYPE @"instrument_type"
Expand Down Expand Up @@ -276,6 +282,7 @@
#define KEY_DEBITCARD @"debitcard"
#define KEY_CREDITCARD @"creditcard"
#define KEY_PAISAWALLET @"paisawallet"
#define KEY_NO_COST_EMI @"no_cost_emi"
//NetBanking parsing elements
#define KEY_BANK_ID @"bank_id"
#define KEY_PGID @"pgId"
Expand All @@ -285,6 +292,7 @@

//EMI parsing elements
#define KEY_BANK @"bank"
#define KEY_MIN_AMOUNT @"min_amount"

//Stored Card parsing elements
#define KEY_USER_CARDS @"user_cards"
Expand Down Expand Up @@ -369,6 +377,7 @@
#define PAYMENT_PG_NET_BANKING @"Net Banking"
#define PAYMENT_PG_CASHCARD @"Cash Card"
#define PAYMENT_PG_EMI @"EMI"
#define PAYMENT_PG_NO_COST_EMI @"No Cost EMI"
#define PAYMENT_PG_PAYU_MONEY @"PayU Money"


Expand Down Expand Up @@ -414,7 +423,7 @@
#define KEY_PAYMENT_GATEWAY @"payment_gateway"
#define KEY_PG_MID @"pg_mid"
#define KEY_TRANSACTION_FEE @"transaction_fee"

#define KEY_MERCHANT_SUBVENTION_AMOUNT @"merchant_subvention_amount"
// SaveUserCard & EditUserCard API parsing elements
#define KEY_CARDTOKEN @"cardToken"
#define KEY_CARD_LABEL @"card_label"
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions PayUNonSeamlessTestApp/PayU/SDK/PayU_iOS_CoreSDK/PayUModelEMI.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@property (strong, nonatomic) NSString * showForm;
@property (strong, nonatomic) NSString * emiTitle;
@property (strong, nonatomic) NSString * bankCode;
@property (strong, nonatomic) NSString * minAmount;

/*!
* This method returns model objects array.
Expand All @@ -28,4 +29,17 @@
*/
+ (NSArray *)prepareEMIArrayFromDict:(id)JSON;


/*!
* This method returns model objects of No cost EMI.
* @return [obj array] [NSArray type]
* @param [Json] [NSDictionary type]
*/
+ (NSArray *)prepareNoCostEMIArrayFromDict:(id)JSON;


+ (NSDictionary *)getEMIDictFromEMIModelArray:(NSArray *)emiArray;

+ (NSDictionary *)getEligibleNoCostEMIDictFromEMIModelArray:(NSArray *)emiArray WRTToAmount:(NSString *) amount;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
@property (strong, nonatomic) NSString * transactionFee;
@property (strong, nonatomic) NSString * txnID;
@property (strong, nonatomic) NSString * udf1;
@property (strong, nonatomic) NSString * merchantSubventionAmount;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@
//This param is for SaveuserCard API
@property (strong, nonatomic) NSString *duplicateCheck;
@property (strong, nonatomic) NSString *encryptionData;

//This param is used while doing payment via subvention mode of EMI
@property (strong, nonatomic) NSString *subventionAmount;
@property (strong, nonatomic) NSString *subventionEligibility;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@property (nonatomic, strong) NSArray *netBankingArray;
@property (nonatomic, strong) NSArray *cashCardArray;
@property (nonatomic, strong) NSArray *EMIArray;
@property (nonatomic, strong) NSArray *NoCostEMIArray;

@property (nonatomic, strong) NSMutableArray *availablePaymentOptionsArray;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@property (nonatomic, strong) NSString * Udf4;
@property (nonatomic, strong) NSString * Udf5;
@property (nonatomic, strong) NSString * UnmappedStatus;
@property (strong, nonatomic) NSString * merchantSubventionAmount;

+(NSDictionary *) prepareDictFromVerifyPaymentAPI:(id)JSON;

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion PayUNonSeamlessTestApp/PayU/SDK/PayU_iOS_CoreSDK/PayUSDKInfo.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>sdkVersion</key>
<string>3.7.5</string>
<string>3.8</string>
</dict>
</plist>
Empty file.
Binary file modified PayUNonSeamlessTestApp/PayU/SDK/libPayU_iOS_CoreSDK.a
Binary file not shown.
18 changes: 18 additions & 0 deletions PayUNonSeamlessTestApp/PayU/SDKUI/CustomViews/PUUIEMITopView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// PUUIEMITopView.h
// PayUNonSeamlessTestApp
//
// Created by Umang Arya on 9/29/16.
// Copyright © 2016 PayU. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "PUUICCDCVC.h"

@interface PUUIEMITopView : UIView

@property (weak, nonatomic) IBOutlet UIView *vwBottom;
-(instancetype)initWithPaymentType:(NSString *) paymentType parentVC:(PUUICCDCVC *) parentVC;
- (void)showSubViewOnView:(UIView *)view;

@end
167 changes: 167 additions & 0 deletions PayUNonSeamlessTestApp/PayU/SDKUI/CustomViews/PUUIEMITopView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//
// PUUIEMITopView.m
// PayUNonSeamlessTestApp
//
// Created by Umang Arya on 9/29/16.
// Copyright © 2016 PayU. All rights reserved.
//

#import "PUUIEMITopView.h"
#import "PayUConstants.h"
#import "PUUICardOptionVC.h"
#import "PUUIConstants.h"

@interface PUUIEMITopView () <CardOptionDelegate>
{
PUUICardOptionVC *_cardOptionVC;
NSArray *_arrEMI, *_arrbankName, *_arrDuration;
NSDictionary *_emiDict;
NSString *_selectedBankName, *_selectedEMIDuration;
}
@property (weak, nonatomic) IBOutlet UIButton *btnSelectBank;
@property (weak, nonatomic) IBOutlet UIButton *btnSelectDuration;
@property (weak, nonatomic) IBOutlet UIView *vwTop;
@property (weak, nonatomic) PUUICCDCVC *parentVC;
@property (nonatomic, weak) NSString *paymentType;
@end


@implementation PUUIEMITopView

-(instancetype)initWithPaymentType:(NSString *) paymentType parentVC:(PUUICCDCVC *) parentVC{
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([PUUIEMITopView class]) owner:self options:nil] firstObject];
if (self) {
self.parentVC = parentVC;
self.paymentType = paymentType;

if ([paymentType isEqual:PAYMENT_PG_NO_COST_EMI]) {
PayUSDKLog(@"No Cost EMI EMI Top view created");
_arrEMI = parentVC.paymentRelatedDetail.NoCostEMIArray;
_emiDict = [PayUModelEMI getEligibleNoCostEMIDictFromEMIModelArray:_arrEMI WRTToAmount:self.parentVC.paymentParam.amount];
}
else if ([paymentType isEqual:PAYMENT_PG_EMI]){
PayUSDKLog(@"EMI Top view created");
_arrEMI = parentVC.paymentRelatedDetail.EMIArray;
_emiDict = [PayUModelEMI getEMIDictFromEMIModelArray:_arrEMI];
[self.vwTop removeFromSuperview];
[self.vwBottom setNeedsLayout];
[self.vwBottom layoutIfNeeded];
}

[self.btnSelectBank.layer setBorderColor:[UIColor payUViewBorderColor].CGColor];
[self.btnSelectDuration.layer setBorderColor:[UIColor payUViewBorderColor].CGColor];

}
return self;
}

-(void)addConstraint{
PayUSDKLog(@"Constraint Added");
[self setTranslatesAutoresizingMaskIntoConstraints:NO];

NSLayoutConstraint *leftConstraint, *rigthConstraint, *bottomConstraint, *topConstraint;

leftConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeLeading multiplier:1 constant:0];
leftConstraint.active = YES;

rigthConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeTrailing multiplier:1 constant:0];
rigthConstraint.active = YES;

bottomConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeBottom multiplier:1 constant:0];
bottomConstraint.active = YES;

topConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeTop multiplier:1 constant:0];
topConstraint.active = YES;

// NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1 constant:40];
// heightConstraint.active = YES;
}

- (void)showSubViewOnView:(UIView *)view {
PayUSDKLog(@"showSubViewOnView method called");
[view addSubview:self];
[self addConstraint];
}


- (IBAction)btnClickedSelectDuration:(id)sender {
PayUSDKLog(@"btnClickedSelectDuration called");
UINavigationController *navigationCtrlr = [self getNavigationControllerInstance];
_cardOptionVC = (PUUICardOptionVC *)[navigationCtrlr topViewController];
_cardOptionVC.arrStoredCards = (NSMutableArray *)_arrDuration;
_cardOptionVC.delegate = self;
if (!_selectedEMIDuration) {
_cardOptionVC.cardIndex = -1;
}
else{
_cardOptionVC.cardIndex = [_arrDuration indexOfObject:_selectedEMIDuration];
}
_cardOptionVC.tableViewType = TableViewTypeEMIDuration;

[self.parentVC presentViewController:navigationCtrlr animated:YES completion:nil];
}


- (IBAction)btnClickedSelectBank:(id)sender {
PayUSDKLog(@"btnClickedSelectBank called");
UINavigationController *navigationCtrlr = [self getNavigationControllerInstance];
_cardOptionVC = (PUUICardOptionVC *)[navigationCtrlr topViewController];
_arrbankName = [[_emiDict allKeys] sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
_cardOptionVC.arrStoredCards = (NSMutableArray *)_arrbankName;
_cardOptionVC.delegate = self;
if (!_selectedBankName) {
_cardOptionVC.cardIndex = -1;
}
else{
_cardOptionVC.cardIndex = [_arrbankName indexOfObject:_selectedBankName];
}
_cardOptionVC.tableViewType = TableViewTypeEMIBank;

[self.parentVC presentViewController:navigationCtrlr animated:YES completion:nil];
}


- (void) cardOptionSelectedWithIndex:(NSInteger)cardIndex{
if (cardIndex >=0) {
if (_cardOptionVC.tableViewType == TableViewTypeEMIBank){
PayUSDKLog(@"cardOptionSelectedWithIndex for EMIBank method called");
NSString *bankName = [_arrbankName objectAtIndex:cardIndex];
if (![bankName isEqualToString:_selectedBankName]) {
_selectedBankName = bankName;
_arrDuration = [[[_emiDict valueForKey:_selectedBankName] allKeys] sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
[self setEMIDurationRelatedObjects:0];
}
[self.btnSelectBank setTitle:_selectedBankName forState:UIControlStateNormal];
}
else if (_cardOptionVC.tableViewType == TableViewTypeEMIDuration) {
[self setEMIDurationRelatedObjects:cardIndex];
}
}
else{
if (_cardOptionVC.tableViewType == TableViewTypeEMIBank){
// [self setEMIDurationParamToDefault];
}
}
}

-(UINavigationController *)getNavigationControllerInstance{
UIStoryboard *stryBrd = [UIStoryboard storyboardWithName:@"PUUIMainStoryBoard" bundle:nil];
UINavigationController *navigationCtrlr = [stryBrd instantiateViewControllerWithIdentifier:@"NavSC"];
return navigationCtrlr;
}

//-(void)setEMIDurationParamToDefault{
// _arrDuration = nil;
// _selectedEMIDuration = nil;
// self.parentVC.paymentParam.bankCode = nil;
// [self.btnSelectDuration setTitle:self.defaultSelectDurationTitile forState:UIControlStateNormal];
//}
//
-(void)setEMIDurationRelatedObjects:(NSInteger) cardIndex{
_selectedEMIDuration = [_arrDuration objectAtIndex:cardIndex];
[self.btnSelectDuration setTitle:_selectedEMIDuration forState:UIControlStateNormal];
self.parentVC.paymentParam.bankCode = [(PayUModelEMI *)[[_emiDict valueForKey:_selectedBankName] valueForKey:_selectedEMIDuration] bankCode];

}

@end
Loading

0 comments on commit 033992b

Please sign in to comment.