Paytm sdk ios整合打开Paytm支付表格? [英] Paytm sdk ios integration to open Paytm payment form?

查看:509
本文介绍了Paytm sdk ios整合打开Paytm支付表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS(Xcode 7)中集成Paytm sdk 2.1并配置为付款。

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);


}

以下是使用staging直接显示的屏幕截图此页:

Here is screenshot while using staging directly showing this page :

*注意 - 实际上我正在尝试暂存而不是用于生产。

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

当我执行时它没有显示Paytm付款表格,而是显示订单和交易ID dirctly的金额。

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

如何当用户在表格中输入费用金额时打开Paytm支付表格然后它应该用额外税收计算金额,然后点击付款按钮它应该打开PAYTM支付表格。

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.

请帮助我解决这个问题(我已经逐步通过PAYTM SDK DOC,但很难找到它)。
谢谢。

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.

重要:**就checksumGenerationURL和checksumValidationURL而言,我们需要创建它。最初我尝试使用Paytm,但它的工作最终我们的服务器团队做到了,这是Integrating Paytm的最重要的一点

推荐答案

最后,通过测试生产及其工作正常解决。就Staging服务器而言,我猜在sdk中有硬编码信息,所以希望在下一版本的PGSDK中我们也可以在Staging上测试它。

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.

谢谢。

@Pradeep k ...非常感谢您的宝贵支持。

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

这篇关于Paytm sdk ios整合打开Paytm支付表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆