Integration of Paytm sdk ios to open a Paytm payment form?

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

I have a form in which it is necessary to fill in the quantity and other fields, then there is a button for payment.

Here is the code I'm 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 a screenshot when you use a show directly showing this page: enter image description here

* Note. In fact, I'm trying to organize a production not for production.

When I execute, it does not show the Paytm fepayment form, instead it shows the orderid and the amount with the transaction ID is dirctly.

How to open the Paytm payment form, when the user enters the amount of fees in the form, then she must calculate the amount with the additional tax, and then click on the payment payment button, she should open the PAYTM PAYMENT FORMULA.

PLEASE HELP ME SOLVE THIS PROBLEM (I GOT THROUGH STEP DOC STEP PAYTM SDK STEP, BUT DAY TO FIND IT). THANKS.

Important: ** As for the checksum GenerationURL and checksumValidationURL, we need to create it. I originally tried to use from Paytm, but it worked so that finally, our server team did this, this is the most important moment for Paytm integration

+5
source share
2 answers

Finally, he decided, testing it in production and its working condition. As for the intermediate server, I think that sdk has hard-coded information, so I hope that in the next version of PGSDK we will also check it at the Staging stage.

Thanks.

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

+3
source

Have you filled mc.checksumGenerationURL and mc.checksumValidationURL correctly? There is also a version 2.7 SDK that you should use. Contact your Paytm contact point for the latest iOS SDK.

Now about the Paytm amount does not calculate tax. You must add it to the amount you send to Paytm.

0
source

Source: https://habr.com/ru/post/1243369/


All Articles