Skip to content

Commit

Permalink
added support for UPI
Browse files Browse the repository at this point in the history
  • Loading branch information
RajvinderPayU committed Feb 1, 2019
1 parent 0e7eeb6 commit b2b410e
Show file tree
Hide file tree
Showing 63 changed files with 157 additions and 108 deletions.
15 changes: 12 additions & 3 deletions CoreSDK/Objective-C SampleApp/PayUMoneyExample/APIListVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ - (void)viewDidLoad {
@"PayViaStoredCard",
@"PayViaWallet",
@"PayViaEMI",
@"PayViaUPI",
@"NitroFlags",
@"VerifyOTP",
@"FetchUserDataAPI",
Expand Down Expand Up @@ -140,7 +141,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
NSArray *arrSavedCard = [[dict valueForKey:@"result"] valueForKey:@"savedCards"];
PaymentVC *paymentVC = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([PaymentVC class])];
paymentVC.paymentMode = PUMPaymentModeStoredCard;
paymentVC.arrStoredCard = arrSavedCard;
paymentVC.arrStoredCard = [arrSavedCard isKindOfClass:[NSArray class]] ? arrSavedCard : nil;
[self.navigationController pushViewController:paymentVC animated:YES];
}
break;
Expand All @@ -160,6 +161,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
break;
case 11:
{
PaymentVC *paymentVC = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([PaymentVC class])];
paymentVC.paymentMode = PUMPaymentModeUPI;
[self.navigationController pushViewController:paymentVC animated:YES];

}
break;
case 12:
{
// @"NitroFlags",
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
Expand All @@ -174,14 +183,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[Utils showMsgWithTitle:@"NitroFlags" message:[NSString stringWithFormat:@"%@",dict]];
}
break;
case 12:
case 13:
{
// @"VerifyOTP",
VerifyOTPVC *verifyOTPVC = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([VerifyOTPVC class])];
[self.navigationController pushViewController:verifyOTPVC animated:YES];
}
break;
case 13:
case 14:
{
// @"FetchUserDataAPI",
msg = [NSString stringWithFormat:@"%@",self.fetchUserDataAPIResponse];
Expand Down
76 changes: 68 additions & 8 deletions CoreSDK/Objective-C SampleApp/PayUMoneyExample/PaymentVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#import "iOSDefaultActivityIndicator.h"
#import "EMISelectorViewController.h"

#define kInvaildVPAMessage @"Please enter a valid vpa"
#define kUnableToValidateVPAMessage @"Unable to validate VPA"
#define kUPIUnavailable @"UPI option is unavailable"

@interface PaymentVC ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate>
{
Expand Down Expand Up @@ -51,6 +54,9 @@ - (void)viewDidLoad {
else if (self.paymentMode == PUMPaymentModeStoredCard){
self.vwStoredCard.hidden = NO;
self.vwNB.hidden = NO;
} else if (self.paymentMode == PUMPaymentModeUPI) {
self.vwNB.hidden = NO;
self.vwStoredCard.hidden = YES;
}
else if (self.paymentMode == PUMPaymentModeNone){
[self btnTappedPayNow:nil];
Expand All @@ -62,7 +68,8 @@ - (void)viewDidLoad {
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tapGesture];
}
// Do any additional setup after loading the view.

[self checkIfUPIOptionAvaliable];
}
- (void)dismissKeyboard{
[self.view endEditing:NO];
Expand All @@ -72,6 +79,13 @@ - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)checkIfUPIOptionAvaliable {
if (self.paymentMode == PUMPaymentModeUPI && ![[PayUMoneyCoreSDK sharedInstance] isUPIOptionAvailable]) {
[self showAlertWithMessage:kUPIUnavailable];
}
}

- (void)getBinDetails:(NSString *)cardNumber withCompletionBlock:(PUMRawJSONCompletionBlock)completionBlock {
self.defaultActivityIndicator = [iOSDefaultActivityIndicator new];
[self.defaultActivityIndicator startAnimatingActivityIndicatorWithSelfView:self.view];
Expand Down Expand Up @@ -143,8 +157,9 @@ - (IBAction)btnTappedPayNow:(id)sender {
paymentParam.paymentMode = PUMPaymentModeStoredCard;
paymentParam.objSavedCard.cvv = self.tfBankCode.text;
[self showWebView:paymentParam];
}
else if (self.paymentMode == PUMPaymentModeNone){
} else if (self.paymentMode == PUMPaymentModeUPI) {
[self checkForValidVPA];
} else if (self.paymentMode == PUMPaymentModeNone){
paymentParam.paymentMode = PUMPaymentModeNone;
paymentParam.useWallet = YES;
[self showWebView:paymentParam];
Expand Down Expand Up @@ -172,7 +187,7 @@ - (void)setUpCardParamsForEMI:(PUMPaymentParam *)params {

-(void)openEMITenureScreen:(PUMPaymentParam *)paymentParam {
NSDictionary *emiDictionary = [self.arrNetBank objectAtIndex:selectedIndex];

EMISelectorViewController *emiSelectorVC = [self.storyboard instantiateViewControllerWithIdentifier:@"EMISelectorViewController"];
[emiSelectorVC setBankCode:[[emiDictionary allKeys] firstObject]];
[emiSelectorVC setPaymentParams:paymentParam];
Expand Down Expand Up @@ -200,6 +215,51 @@ - (NSArray *)testOrderDetailsArray {
return @[@{@"From":@"Delhi"}, @{@"To":@"Pune"}];
}

- (void)showAlertWithMessage:(NSString *)message {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:action];

[self presentViewController:alertController animated:YES completion:nil];
}

- (void)proceedWithVPA:(NSString *)vpa {
PUMUPI *upiObject = [PUMUPI new];
upiObject.vpa = vpa;

PUMPaymentParam *paymentParam = [PUMPaymentParam new];
paymentParam.objUPI = upiObject;
paymentParam.paymentMode = PUMPaymentModeUPI;
paymentParam.useWallet = self.switchUseWallet.isOn;
[self showWebView:paymentParam];
}

#pragma mark - API -

- (void)checkForValidVPA {
[self.view endEditing:YES];
NSString *vpa = [self.tfBankCode.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

__weak PaymentVC *weakSelf = self;

self.defaultActivityIndicator = [iOSDefaultActivityIndicator new];
[self.defaultActivityIndicator startAnimatingActivityIndicatorWithSelfView:self.view];

[[PayUMoneyCoreSDK sharedInstance] validateVPA:vpa completion:^(BOOL isValidVPA, NSError *error) {
[weakSelf.defaultActivityIndicator stopAnimatingActivityIndicator];
if (error) {
[weakSelf showAlertWithMessage:kUnableToValidateVPAMessage];
} else {
if (isValidVPA) {
[weakSelf proceedWithVPA:vpa];
} else {
[weakSelf showAlertWithMessage:kInvaildVPAMessage];
}
}
}];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
Expand All @@ -218,7 +278,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];

if (self.paymentMode != PUMPaymentModeStoredCard ){
NSDictionary *eachNetBank = [self.arrNetBank objectAtIndex:indexPath.row];
if (_paymentMode == PUMPaymentModeEMI) {
Expand All @@ -239,9 +299,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// if (self.paymentMode == PUMPaymentModeNetBanking){
// self.tfBankCode.text = [[self tableView:tableView cellForRowAtIndexPath:indexPath].detailTextLabel.text copy];
// }
// if (self.paymentMode == PUMPaymentModeNetBanking){
// self.tfBankCode.text = [[self tableView:tableView cellForRowAtIndexPath:indexPath].detailTextLabel.text copy];
// }
selectedIndex = (int)indexPath.row;
}

Expand Down
Binary file modified CoreSDK/PayUMoneyCoreSDK.framework/Assets.car
Binary file not shown.
1 change: 1 addition & 0 deletions CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef NS_ENUM(NSInteger, PUMEnvironment) {

#define EMI_SMALL @"emi"
#define EMI @"EMI"
#define UPI @"UPI"
#define CASH_CARD_SMALL @"cashcard"
#define CASH_CARD_CAPITAL @"CASHCARD"
#define CASH @"CASH"
Expand Down
2 changes: 2 additions & 0 deletions CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMHelperClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

+ (BOOL)isValidEmail:(NSString *)email;

+ (BOOL)isValidVPA:(NSString *)vpa;

+ (BOOL)validateRegex:(NSString *) regex onString:(NSString *) str;

+ (BOOL)isNitroFlowEnabledForMerchant;
Expand Down
43 changes: 26 additions & 17 deletions CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMInternalConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#define Cancel_Transaction_URL @"payment/postBackParam.do"
#define Cancel_Transaction @"payment/postBackParamIcp.do"
#define Post_Payment_URL @"payment/app/postPayment"
#define Validate_VPA @"payu/validateVpa"

// ONE_TAP_ENABLE
#define ENABLE_ONE_TAP @"auth/app/setUserPaymentOption" //params oneClickTxn=-1 OR 0 OR 1 <POST
Expand Down Expand Up @@ -230,22 +231,26 @@
#define ENVIRONMENT_PP22_API_URL @"https://pp22.payumoney.com/"
#define ENVIRONMENT_MOBILE_TEST_API_URL @"https://mobiletest.payumoney.com/"
#define ENVIRONMENT_PP44_API_URL @"https://pp44.payumoney.com/"
#define ENVIRONMENT_PP58_API_URL @"https://pp58.payumoney.com/"

//Web URLs
#define ENVIRONMENT_PRODUCTION_WEB_URL @"https://secure.payu.in/_payment"
#define ENVIRONMENT_TEST_WEB_URL @"https://sandboxsecure.payu.in/_payment"
#define ENVIRONMENT_PP42_WEB_URL @"http://pp42.secure.payu.in/_payment"
#define ENVIRONMENT_PP25_WEB_URL @"http://pp25.secure.payu.in/_payment"
#define ENVIRONMENT_PP41_WEB_URL @"http://pp41.secure.payu.in/_payment"
#define ENVIRONMENT_PP10_WEB_URL @"http://pp10.secure.payu.in/_payment"
#define ENVIRONMENT_PP0_WEB_URL @"http://pp0.secure.payu.in/_payment"
#define ENVIRONMENT_PP48_WEB_URL @"http://pp51.secure.payu.in/_payment"
#define ENVIRONMENT_PP4_WEB_URL @"http://pp4.secure.payu.in/_payment"
#define ENVIRONMENT_MOBILE_TEST_WEB_URL @"http://mobiletest.payu.in/_payment"
#define ENVIRONMENT_PP22_WEB_URL @"http://pp22.secure.payu.in/_payment"
#define ENVIRONMENT_PP44_WEB_URL @"http://pp44.secure.payu.in/_payment"


#define ENVIRONMENT_PP42_WEB_URL @"https://pp42secure.payu.in/_payment"
#define ENVIRONMENT_PP25_WEB_URL @"https://pp25secure.payu.in/_payment"
#define ENVIRONMENT_PP41_WEB_URL @"https://pp41secure.payu.in/_payment"
#define ENVIRONMENT_PP10_WEB_URL @"https://pp10secure.payu.in/_payment"
#define ENVIRONMENT_PP0_WEB_URL @"https://pp0secure.payu.in/_payment"
#define ENVIRONMENT_PP48_WEB_URL @"https://pp51secure.payu.in/_payment"
#define ENVIRONMENT_PP4_WEB_URL @"https://pp4secure.payu.in/_payment"
#define ENVIRONMENT_MOBILE_TEST_WEB_URL @"https://mobiletest.payu.in/_payment"
#define ENVIRONMENT_PP22_WEB_URL @"https://pp22secure.payu.in/_payment"
#define ENVIRONMENT_PP44_WEB_URL @"https://pp44secure.payu.in/_payment"
#define ENVIRONMENT_PP58_WEB_URL @"https://pp58secure.payu.in/_payment"

//Citrus URLs

#define CITRUS_CHECKOUT_URL @"https://checkout.citruspay.com/"

#define TXNID @"txnid"
#define MERCHANTID @"merchantId"
Expand Down Expand Up @@ -277,13 +282,16 @@

#define RAW_JSON @"RawJSON"
#define PARSED_RESPONSE @"ParsedResponse"

#define VPA @"vpa"
#define INVALID_RESPONSE @"Invalid Response"
#define API_Failure @"API Failed"



typedef NS_ENUM(NSInteger, PUMBaseURLCategory) {
PUMBaseURLForAPI,
PUMBaseURLForWeb
PUMBaseURLForWeb,
PUMBaseURLForCitrusCheckout
};

typedef NS_ENUM(NSInteger, PUMInternalEnvironment) {
Expand All @@ -296,7 +304,8 @@ typedef NS_ENUM(NSInteger, PUMInternalEnvironment) {
PUMEnvironmentPP22,
PUMEnvironmentPP48,
PUMEnvironmentPP44,
PUMEnvironmentPP25
PUMEnvironmentPP25,
PUMEnvironmentPP58
};


Expand Down Expand Up @@ -336,8 +345,8 @@ typedef NS_ENUM(NSInteger,SDK_REQUEST_TYPE ) {
SDK_ANALYTICS_FETCH_API_TOKEN,
SDK_ANALYTICS_SEND,
SDK_FETCH_USER_DATA,
SDK_GET_MULTIPLE_BIN_DETAILS

SDK_GET_MULTIPLE_BIN_DETAILS,
SDK_VALIDATE_VPA
};

static NSString *const kPUMAOTP = @"OTP";
Expand Down
12 changes: 9 additions & 3 deletions CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMLogEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static NSString *const KPUMAWalletCardValue = @"PUMWallet|Cards";
static NSString *const KPUMAWalletNetBankValue = @"PUMWallet|Bank";
static NSString *const KPUMA3PWallet = @"3PWallet";
static NSString *const KPUMAEMI = @"EMI";
static NSString *const kPUMAUPI = @"UPI";

static NSString *const kPUMAScreenTypeCheckout = @"Checkout";
static NSString *const kPUMAScreenTypeAddCard = @"AddCard";
Expand All @@ -39,9 +40,11 @@ static NSString *const kPUMAInvalidCVV = @"Invalid CVV";

+(void)paymentAdded;

+(void)paymentSucceededForAmount:(NSString *) amount;
+(void)paymentSucceededForAmount:(NSString *) amount pgType:(NSString *)pgType;

+(void)paymentFailedWithReason:(NSString *) reason andAmount:(NSString *) amount;
+(void)paymentFailedWithReason:(NSString *) reason andAmount:(NSString *) amount pgType:(NSString *)pgType;

+(void)verifyAPIFailedWithReason:(NSString *)reason andAmount:(NSString *)amount;

+(void)loginAttempted;

Expand Down Expand Up @@ -96,7 +99,10 @@ static NSString *const kPUMAInvalidCVV = @"Invalid CVV";
+(void)more3PWalletsClicked;

+(void)moreEMIBanksClicked:(NSString *)amount;
//+(void)twoFALoaded;

+(void)invalidVPAEntered:(NSString *)vpa;

+(void)failedToValidateVPA:(NSString *)vpa errorMessage:(NSString *)errorMessage;

+(void)paymentAbandonedWithReason:(NSString *)reason;

Expand Down
5 changes: 4 additions & 1 deletion CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMPaymentParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
#import "PUMNetBankingBO.h"
#import "PUMCCDC.h"
#import "PUMEMI.h"
#import "PUMUPI.h"

typedef NS_ENUM(NSInteger, PUMPaymentMode) {
PUMPaymentModeNone = 0,
PUMPaymentModeCCDC,
PUMPaymentModeNetBanking,
PUMPaymentModeStoredCard,
PUMPaymentMode3PWallet,
PUMPaymentModeEMI
PUMPaymentModeEMI,
PUMPaymentModeUPI
};
@interface PUMPaymentParam : NSObject

Expand All @@ -28,6 +30,7 @@ typedef NS_ENUM(NSInteger, PUMPaymentMode) {
@property (strong, nonatomic) PUMCCDC * objCCDC;
@property (strong, nonatomic) PUMNetBankingBO * obj3PWallet;
@property (strong, nonatomic) PUMEMI * objEMI;
@property (strong, nonatomic) PUMUPI * objUPI;

/**
Set payment mode
Expand Down
5 changes: 4 additions & 1 deletion CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMSDKError.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ typedef NS_ENUM(NSInteger, PUMSDKErrorCode)
PUMErrorInternationalCardWithEMI,
PUMErrorDebitCardWithEMI,
PUMInvalidReviewOrder,
PUMErrorSaveCardUnavailable
PUMErrorSaveCardUnavailable,
PUMErrorSplitNotAllowedWithUPI,
PUMErrorInvalidVPA,
PUMErrorUnableToValidateVPA
};

+(NSError *)toNSError:(int)errorCode
Expand Down
17 changes: 17 additions & 0 deletions CoreSDK/PayUMoneyCoreSDK.framework/Headers/PUMUPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// PUMUPI.h
// PayUMoneyCoreSDK
//
// Created by Rajvinder Singh on 1/10/19.
// Copyright © 2019 PayU Payments Private Limited. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface PUMUPI : NSObject

@property (strong, nonatomic) NSString *vpa;

@end

8 changes: 8 additions & 0 deletions CoreSDK/PayUMoneyCoreSDK.framework/Headers/PayUMoneyCoreSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ typedef NSString* (^PUMRightActionCompletionBlock)(BOOL actionOccurred);
/// This method is used for getting updated emi tenures on the basis of amount provided. Amount should contain convenience fee as well
- (void)getEMIOptionsForAmount:(NSString *)amount completion:(PUMRawJSONCompletionBlock)completionBlock;

/// Checks if UPI option is available or not.
- (BOOL)isUPIOptionAvailable;

/** Checks if VPA is valid or not. VPA should be in a format example@@example
@param vpa The VPA whose validation needs to be performed
*/
- (void)validateVPA:(NSString *)vpa completion:(void(^)(BOOL isValidVPA, NSError *error))completionBlock;

- (void)fetchPaymentUserDataAPIWithCompletionBlock:(PUMRawJSONCompletionBlock)completionBlock;

- (void)getBinDetailsAPI:(NSString *)cardBin
Expand Down
Binary file modified CoreSDK/PayUMoneyCoreSDK.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed CoreSDK/PayUMoneyCoreSDK.framework/PUCBLoader.nib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed CoreSDK/PayUMoneyCoreSDK.framework/PUCBROCell.nib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed CoreSDK/PayUMoneyCoreSDK.framework/PUCBSurePay.nib
Binary file not shown.
Binary file removed CoreSDK/PayUMoneyCoreSDK.framework/PUCBUserIdNB.nib
Binary file not shown.
Loading

0 comments on commit b2b410e

Please sign in to comment.