Paytm sdk ios 集成以打开 Paytm 付款表格?
Paytm sdk ios integration to open Paytm payment form?
在 iOS (Xcode 7) 中集成 Paytm sdk 2.1 并配置为进行支付。
我有一个表格,其中需要填写金额和其他字段,然后有一个付款按钮。
这是我正在使用的代码:
//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);
}
这是使用登台直接显示此页面时的屏幕截图:
*注意 - 实际上我正在尝试进行暂存而不是生产。
当我执行时,它不显示 Paytm 费用支付表格,而是直接显示订单 ID 和金额以及交易 ID。
当用户在表格中输入费用金额时如何打开 Paytm 付款表格,然后它应该用额外的税计算金额,然后单击费用支付按钮它应该打开 PAYTM 付款表格。
请帮我解决这个问题(我已经一步步浏览了 PAYTM SDK 文档,但无法找到它)。
谢谢。
重要提示:**就checksumGenerationURL和checksumValidationURL而言,我们需要创建它。最初我尝试使用 Paytm,但它没有用,所以最后我们的服务器团队做到了,这是集成 Paytm 最重要的一点
您是否正确填充了 mc.checksumGenerationURL 和 mc.checksumValidationURL?您还应该使用 2.7 版本的 SDK。请向您的 Paytm 联系点索取最新的 iOS SDK。
现在关于金额,Paytm不计算税金。您必须将其添加到您发送给 Paytm 的金额中。
最后,通过在产品上测试它并且工作正常来解决。就登台服务器而言,我想 sdk 中有硬编码信息,所以希望在下一个版本的 PGSDK 中我们也可以在登台上测试它。
谢谢。
@Pradeep k ...非常感谢您的宝贵支持。
在 iOS (Xcode 7) 中集成 Paytm sdk 2.1 并配置为进行支付。
我有一个表格,其中需要填写金额和其他字段,然后有一个付款按钮。
这是我正在使用的代码:
//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);
}
这是使用登台直接显示此页面时的屏幕截图:
*注意 - 实际上我正在尝试进行暂存而不是生产。
当我执行时,它不显示 Paytm 费用支付表格,而是直接显示订单 ID 和金额以及交易 ID。
当用户在表格中输入费用金额时如何打开 Paytm 付款表格,然后它应该用额外的税计算金额,然后单击费用支付按钮它应该打开 PAYTM 付款表格。
请帮我解决这个问题(我已经一步步浏览了 PAYTM SDK 文档,但无法找到它)。 谢谢。
重要提示:**就checksumGenerationURL和checksumValidationURL而言,我们需要创建它。最初我尝试使用 Paytm,但它没有用,所以最后我们的服务器团队做到了,这是集成 Paytm 最重要的一点
您是否正确填充了 mc.checksumGenerationURL 和 mc.checksumValidationURL?您还应该使用 2.7 版本的 SDK。请向您的 Paytm 联系点索取最新的 iOS SDK。
现在关于金额,Paytm不计算税金。您必须将其添加到您发送给 Paytm 的金额中。
最后,通过在产品上测试它并且工作正常来解决。就登台服务器而言,我想 sdk 中有硬编码信息,所以希望在下一个版本的 PGSDK 中我们也可以在登台上测试它。
谢谢。
@Pradeep k ...非常感谢您的宝贵支持。