Skip to content

Commit

Permalink
disable save cards feature on UI if merchantClientData nil
Browse files Browse the repository at this point in the history
  • Loading branch information
jukiginanjar committed Aug 22, 2016
1 parent 6194b83 commit b1c1380
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 78 deletions.
21 changes: 4 additions & 17 deletions Demo/VTDirectDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,23 @@ - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.navigationController.view.userInteractionEnabled = NO;

self.itemDetails = [self generateItemDetails];

self.navigationController.view.userInteractionEnabled = NO;
NSDictionary *clientAuth = [[NSUserDefaults standardUserDefaults] objectForKey:@"clientAuth"];
if (clientAuth) {
[CONFIG setMerchantClientData:clientAuth];
self.navigationController.view.userInteractionEnabled = YES;
} else {
}
else {
[[VTMerchantClient sharedClient] fetchMerchantAuthDataWithCompletion:^(id response, NSError *error) {
if (response) {
[[NSUserDefaults standardUserDefaults] setObject:response forKey:@"clientAuth"];
[[NSUserDefaults standardUserDefaults] synchronize];
[CONFIG setMerchantClientData:response];
self.navigationController.view.userInteractionEnabled = YES;
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error loading merchant authentication data, please restart the App" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alert show];
}
}];
}

if ([CONFIG merchantClientData]) {
self.navigationController.view.userInteractionEnabled = YES;
} else {
[[VTMerchantClient sharedClient] fetchMerchantAuthDataWithCompletion:^(id response, NSError *error) {
if (response) {
[CONFIG setMerchantClientData:response];
self.navigationController.view.userInteractionEnabled = YES;
} else {
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error loading merchant authentication data, please restart the App" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alert show];
}
Expand Down
8 changes: 8 additions & 0 deletions MidtransKit/MidtransKit/VTAddCardController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ @interface VTAddCardController ()
@property (strong, nonatomic) IBOutlet VTCCFrontView *cardFrontView;
@property (strong, nonatomic) IBOutlet UILabel *amountLabel;
@property (strong, nonatomic) IBOutlet UISwitch *saveCardSwitch;
@property (strong, nonatomic) IBOutlet UIView *saveOptionView;

@end

Expand All @@ -49,6 +50,13 @@ - (void)viewDidLoad {
[_cardExpiryDate addObserver:self forKeyPath:@"text" options:0 context:nil];

_amountLabel.text = self.transactionDetails.grossAmount.formattedCurrencyNumber;

if ([CONFIG merchantClientData]) {
self.saveOptionView.hidden = NO;
}
else {
self.saveOptionView.hidden = YES;
}
}

- (void)dealloc {
Expand Down
31 changes: 20 additions & 11 deletions MidtransKit/MidtransKit/VTPaymentListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,34 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
VTPaymentListModel *paymentMethod = (VTPaymentListModel *)[self.paymentMethodList objectAtIndex:indexPath.row];
if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_CREDIT_CARD_IDENTIFIER]) {
VTCardListController *vc = [[VTCardListController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:paymentMethod];
[self.navigationController pushViewController:vc animated:YES];

} else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_VA_IDENTIFIER]) {
if ([CONFIG merchantClientData]) {
VTCardListController *vc = [[VTCardListController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:paymentMethod];
[self.navigationController pushViewController:vc animated:YES];
}
else {
VTAddCardController *vc = [[VTAddCardController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:nil];
[self.navigationController pushViewController:vc animated:YES];
}
}
else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_VA_IDENTIFIER]) {
VTVAListController *vc = [[VTVAListController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:paymentMethod];
[self.navigationController pushViewController:vc animated:YES];

} else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_CIMB_CLIKS_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_ECASH_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_BCA_KLIKPAY_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_EPAY_IDENTIFIER]) {
}
else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_CIMB_CLIKS_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_ECASH_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_BCA_KLIKPAY_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_EPAY_IDENTIFIER]) {
VTPaymentGeneralViewController *vc = [[VTPaymentGeneralViewController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:paymentMethod];
[self.navigationController pushViewController:vc animated:YES];
} else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_INDOMARET_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_KLIK_BCA_IDENTIFIER]) {
}
else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_INDOMARET_IDENTIFIER] ||
[paymentMethod.internalBaseClassIdentifier isEqualToString:VT_KLIK_BCA_IDENTIFIER]) {
VTPaymentDirectViewController *vc = [[VTPaymentDirectViewController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:paymentMethod];
[self.navigationController pushViewController:vc animated:YES];

} else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_MANDIRI_CLICKPAY_IDENTIFIER]) {
}
else if ([paymentMethod.internalBaseClassIdentifier isEqualToString:VT_MANDIRI_CLICKPAY_IDENTIFIER]) {
VTMandiriClickpayController *vc = [[VTMandiriClickpayController alloc] initWithCustomerDetails:self.customerDetails itemDetails:self.itemDetails transactionDetails:self.transactionDetails paymentMethodName:paymentMethod];
[self.navigationController pushViewController:vc animated:YES];

Expand Down
Loading

0 comments on commit b1c1380

Please sign in to comment.