Paytm sdk ios integration to open Paytm payment form?

放肆的年华 提交于 2019-12-20 11:33:24

问题


Integrated Paytm sdk 2.1 in iOS (Xcode 7) and configured to make payment .

I have a form in which amount and other fields need to filled then there is a button for Payment .

Here is code which i am using :

 //Step 1: Create a default merchant config object
    PGMerchantConfiguration *mc = [PGMerchantConfiguration defaultConfiguration];

    //Step 2: If you have your own checksum generation and validation url set this here. Otherwise use the default Paytm urls
    mc.checksumGenerationURL = @"generate checksum url";
    mc.checksumValidationURL =   @"checksum validation url";


    //Step 3: Create the order with whatever params you want to add. But make sure that you include the merchant mandatory params
    NSMutableDictionary *orderDict = [NSMutableDictionary new];
    //Merchant configuration in the order object
    orderDict[@"MID"] = @"abc1111"; 
    orderDict[@"CHANNEL_ID"] = @"WAP";
    orderDict[@"INDUSTRY_TYPE_ID"] = @"Education";
    orderDict[@"WEBSITE"] = @"companyname";
    //Order configuration in the order object
    orderDict[@"TXN_AMOUNT"] = @"100";
    orderDict[@"ORDER_ID"] = [Feepayment generateOrderIDWithPrefix:@"111"];
    orderDict[@"REQUEST_TYPE"] = @"DEFAULT";
    orderDict[@"CUST_ID"] = @"abc7777";

    PGOrder *order = [PGOrder orderWithParams:orderDict];

    //Step 4: Choose the PG server. In your production build dont call selectServerDialog. Just create a instance of the
    //PGTransactionViewController and set the serverType to eServerTypeProduction


    [PGServerEnvironment selectServerDialog:self.view completionHandler:^(ServerType type)
     {
         PGTransactionViewController *txnController = [[PGTransactionViewController alloc] initTransactionForOrder:order];

         //show title var
         UIView *mNavBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,44)];
         mNavBar.backgroundColor = [UIColor grayColor];
         txnController.topBar = mNavBar;

         //Cancel button
         UIButton *mCancelButton = [[UIButton alloc] initWithFrame:CGRectMake(5, 2, 70, 40)];
         [mCancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
         mCancelButton.titleLabel.textColor = PURPLE_COLOR;
         [mCancelButton setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15.0]];
         txnController.cancelButton = mCancelButton;


         //add title
         UILabel *mTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 10, 1, 100, 50)];
         [mTitleLabel setText:@"Payment"];
         [mTitleLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15.0]];
         mTitleLabel.textColor = [UIColor whiteColor];
         [mNavBar addSubview:mTitleLabel];

         if (type!=eServerTypeNone) {
             txnController.serverType = type;
             txnController.merchant = mc;
             txnController.loggingEnabled = YES;
             txnController.sendAllChecksumResponseParamsToPG = YES;
             txnController.delegate = self;
             [self showController:txnController];
         }

     }];

//show controller method
-(void)showController:(PGTransactionViewController *)controller {
    if (self.navigationController != nil)
        [self.navigationController pushViewController:controller animated:YES];
    else
        [self presentViewController:controller animated:YES
                         completion:^{

                         }];
}
//remove controller
-(void)removeController:(PGTransactionViewController *)controller {
    if (self.navigationController != nil)
        [self.navigationController popViewControllerAnimated:YES];
    else
        [controller dismissViewControllerAnimated:YES
                                       completion:^{
                                       }];
}
#pragma mark PGTransactionViewController delegate

- (void)didSucceedTransaction:(PGTransactionViewController *)controller
                     response:(NSDictionary *)response {
    DEBUGLOG(@"ViewController::didSucceedTransactionresponse= %@", response);
    NSString *title = [NSString stringWithFormat:@"Your order  was completed successfully. \n %@", response[@"ORDERID"]];
    [[[UIAlertView alloc] initWithTitle:title message:[response description] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    [self removeController:controller];
}

- (void)didFailTransaction:(PGTransactionViewController *)controller error:(NSError *)error response:(NSDictionary *)response {
    DEBUGLOG(@"ViewController::didFailTransaction error = %@ response= %@", error, response);
    if (response)
    {
        [[[UIAlertView alloc] initWithTitle:error.localizedDescription message:[response description] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    }
    else if (error)
    {
        [[[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    }
    [self removeController:controller];
}

- (void)didCancelTransaction:(PGTransactionViewController *)controller error:(NSError*)error response:(NSDictionary *)response {
    DEBUGLOG(@"ViewController::didCancelTransaction error = %@ response= %@", error, response);
    NSString *msg = nil;
    if (!error) msg = [NSString stringWithFormat:@"Successful"];
    else msg = [NSString stringWithFormat:@"UnSuccessful"];

    [[[UIAlertView alloc] initWithTitle:@"Transaction Cancel" message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    [self removeController:controller];
}

- (void)didFinishCASTransaction:(PGTransactionViewController *)controller response:(NSDictionary *)response {
    DEBUGLOG(@"ViewController::didFinishCASTransaction:response = %@", response);


}

Here is screenshot while using staging directly showing this page :

*Note - Actually i am trying for staging not for production .

When i execute then it doesnt showing Paytm feepayment form instead it showing orderid and amount with transaction id dirctly .

How to open Paytm payment form when user enter fee amount in the form then it should calcualte the amount with extraa tax and then clicking on Fee payment button it should open PAYTM PAYMENT FORM.

PLEASE HELP ME TO SOLVE THIS PROBLEM ( I HAVE GO THROUGH THE PAYTM SDK DOC STEP BY STEP BUT DINT ABLE TO FIND IT ). THANKS.

Important : **As far as checksumGenerationURL and checksumValidationURL is concerned , we need to create it . Initially i tried to use from Paytm but it dint work so finally our server team did it , this is most important point for Integrating Paytm


回答1:


Finally , Solved by testing it on the Production and its working fine . As far as Staging server is concerned i guess there is hard coded information is in the sdk so hope in the next version of PGSDK we could test it on Staging too.

Thanks .

@Pradeep k ... thank you very much for all your valuable support .




回答2:


Have you populated the mc.checksumGenerationURL and mc.checksumValidationURL properly? Also there is a 2.7 version of the SDK that you should be using. Ask your Paytm contact point for the latest iOS SDK.

Now about the amount, Paytm does not calculate the tax. You have to add it to the amount that you are sending to Paytm.



来源:https://stackoverflow.com/questions/35498658/paytm-sdk-ios-integration-to-open-paytm-payment-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!