5

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 : enter image description here

*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

Shobhakar Tiwari
  • 7,862
  • 4
  • 36
  • 71
  • Have you signed up with Paytm as a merchant and obtained proper merchant configuration information? What msg do you get in the dialog that contains the order id and txn id? – Pradeep K Feb 19 '16 at 06:47
  • well as far as tax is concerned that we are doing from our side (calling a webservice ) but how to open paytm payment form . I have successfully set mc.checksumGenerationURL and mc.checksumValidationURL . but it directly opening a page showing "Total payment to be made Rs 100 to Company name" with transaction id . i want to open paytm payment form sir . is this possible with sdk 2.1 or not ! – Shobhakar Tiwari Feb 19 '16 at 06:51
  • please have a look at this: https://stackoverflow.com/questions/48782215/ios-paytm-something-went-wrong-it-may-be-due-to-any-of-these-reasons – Abhinandan Pratap Feb 14 '18 at 11:23

2 Answers2

3

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 .

Shobhakar Tiwari
  • 7,862
  • 4
  • 36
  • 71
  • @Shobhakar Tiwari Can u Please guide me how to generate checksumGenerationURL and checksumvalidationURL – siva krishna Mar 17 '16 at 09:34
  • Is this set Up by server side, I know Merchant Id and Merchant Key – siva krishna Mar 17 '16 at 09:36
  • @sivakrishna To generate checksumgenerationURL and checksumvalidationUrl , either go with your server side team ( need to write server side method for this ) or in ios you need to write this . We did through server side . – Shobhakar Tiwari Mar 20 '16 at 08:51
  • K thanks for u r reply, Do u know any guide to write in iOS ? – siva krishna Mar 21 '16 at 04:20
  • @sivakrishna yes in ios you can write this . Ask a question in SO , i will update it with code too. – Shobhakar Tiwari Mar 21 '16 at 07:50
  • @SKT Thnx,Please check my question here http://stackoverflow.com/questions/36130422/how-to-generate-checksumgenerationurl-and-checksumvalidationurl-in-ios-paytm – siva krishna Mar 21 '16 at 11:59
  • can't able to open view in Paytm using New created Credential. – Super Developer Jan 30 '17 at 10:14
  • Nice, I followed but these errors. "_OBJC_CLASS_$_PGServerEnvironment", referenced from: objc-class-ref in CartViewController.o "_OBJC_CLASS_$_PGTransactionViewController", referenced from: objc-class-ref in CartViewController.o "_OBJC_CLASS_$_PGOrder", referenced from: objc-class-ref in CartViewController.o "_OBJC_CLASS_$_PGMerchantConfiguration", referenced from: objc-class-ref in CartViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) – iHarshil Jul 16 '18 at 09:06
  • Which version of SDK you are using ? – Shobhakar Tiwari Jul 17 '18 at 15:35
0

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.

Pradeep K
  • 3,671
  • 1
  • 11
  • 15
  • well as far as tax is concerned that we are doing from our side (calling a webservice ) but how to open paytm payment form . I have successfully set mc.checksumGenerationURL and mc.checksumValidationURL . but it directly opening a page showing "Total payment to be made Rs 100 to Company name" with transaction id . i want to open paytm payment form sir . is this possible with sdk 2.1 or not ! – Shobhakar Tiwari Feb 19 '16 at 06:51
  • You have to upgrade to 2.7. Also if you are running on iOS 9 then have you added the App Transport Security property to the app's Info.plist. What error are you exactly getting? Can you attach a snapshot? – Pradeep K Feb 19 '16 at 08:10
  • i have already added App Transport Security . sir i am only asking how to open Paytm payment form where payment using net banking , credit card etc are there . it is not showing . it is directly showing Paytm page showing ..TOTAL PAYMENT MADE TO XYZ RS 100 WITH TRANSACTION ID. – Shobhakar Tiwari Feb 19 '16 at 09:21
  • Can you show the implementation of `showController` method? Also can you attach the exact screenshots of the paytm page that you are talking about? – Pradeep K Feb 19 '16 at 13:40
  • updated question with updated screenshot and corresponding delegete for showing controller . Please suggest sir. – Shobhakar Tiwari Feb 20 '16 at 14:14
  • There must be something wrong with your merchant configuration. Contact your Paytm sales agent with this problem. It looks like no payment options are enabled for your merchant account. – Pradeep K Feb 21 '16 at 05:27
  • Since we have already implemented sdk for android and web end . Its working fine so that shouldn't be problem . Please look my code, is there anything else i need to add while using PGMerchantConfiguration . – Shobhakar Tiwari Feb 22 '16 at 05:51
  • Your code looks fine. If you can pass me your merchant config privately I can help you more with this. – Pradeep K Feb 22 '16 at 05:56
  • sorry but we cant share this . any other way if u could guide us so that we can look into this . Thanks in advance . Highly appreciate for your instant response. – Shobhakar Tiwari Feb 22 '16 at 06:58
  • Can u Please guide me how to generate checksumGenerationURL and checksumvalidationURL – siva krishna Mar 17 '16 at 10:25
  • You have to get it from paytm. Its either hosted at their end or hosted at your end. – Pradeep K Mar 17 '16 at 10:36
  • @PradeepK I only get Merchant Id and Merchant Key form PayTm, didn't get Urls. Shall I need to contact them again.. – siva krishna Mar 18 '16 at 05:24