diff --git a/MidtransCoreKit/MidtransCoreKit/MidtransConstant.h b/MidtransCoreKit/MidtransCoreKit/MidtransConstant.h index 1456abca7..b72cd9569 100644 --- a/MidtransCoreKit/MidtransCoreKit/MidtransConstant.h +++ b/MidtransCoreKit/MidtransCoreKit/MidtransConstant.h @@ -10,7 +10,7 @@ * error domain */ -static NSString * const MIDTRANS_SDK_CURRENT_VERSION = @"1.12.0"; +static NSString * const MIDTRANS_SDK_CURRENT_VERSION = @"1.12.1"; static NSString * const MIDTRANS_CUSTOMFIELD_1 = @"custom_field1"; static NSString * const MIDTRANS_CUSTOMFIELD_2 = @"custom_field2"; static NSString * const MIDTRANS_CUSTOMFIELD_3 = @"custom_field3"; diff --git a/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.h b/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.h index 7fd1a8b0d..79d5cfe7c 100644 --- a/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.h +++ b/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.h @@ -42,5 +42,18 @@ static NSString * _Nonnull const kMTMaskedCreditCardExpiresAt = @"expires_at"; - (instancetype _Nonnull)initWithDictionary:(NSDictionary *_Nonnull)dictionary; - (instancetype _Nonnull)initWithData:(NSDictionary *_Nonnull)data; - +- (instancetype _Nonnull)initWithSavedTokenId:(NSString * _Nonnull)savedTokenId + maskedNumber:(NSString * _Nonnull)maskedNumber + tokenType:(NSString * _Nullable)tokenType + expiresAt:(NSString *_Nullable)expiresAt; + +/* + self.savedTokenId = dictionary[kMTMaskedCreditCardIdentifier]; + self.maskedNumber = dictionary[kMTMaskedCreditCardCardhash]; + self.type = dictionary[kMTMaskedCreditCardType]?dictionary[kMTMaskedCreditCardType]:@""; + self.tokenType = dictionary[kMTMaskedCreditCardTokenType]?dictionary[kMTMaskedCreditCardTokenType]:@""; + self.expiresAt = dictionary[kMTMaskedCreditCardExpiresAt]?dictionary[kMTMaskedCreditCardExpiresAt]:@""; + self.statusCode = @""; + self.transactionId = @""; + */ @end diff --git a/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.m b/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.m index f7673ab34..16aa9c658 100644 --- a/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.m +++ b/MidtransCoreKit/MidtransCoreKit/MidtransMaskedCreditCard.m @@ -46,15 +46,29 @@ - (instancetype _Nonnull)initWithDictionary:(NSDictionary *_Nonnull)dictionary { if (self = [super init]) { self.savedTokenId = dictionary[kMTMaskedCreditCardIdentifier]; self.maskedNumber = dictionary[kMTMaskedCreditCardCardhash]; - self.type = dictionary[kMTMaskedCreditCardType]; - self.tokenType = dictionary[kMTMaskedCreditCardTokenType]; - self.expiresAt = dictionary[kMTMaskedCreditCardExpiresAt]; + self.type = dictionary[kMTMaskedCreditCardType]?dictionary[kMTMaskedCreditCardType]:@""; + self.tokenType = dictionary[kMTMaskedCreditCardTokenType]?dictionary[kMTMaskedCreditCardTokenType]:@""; + self.expiresAt = dictionary[kMTMaskedCreditCardExpiresAt]?dictionary[kMTMaskedCreditCardExpiresAt]:@""; self.statusCode = @""; self.transactionId = @""; } return self; } - +- (instancetype )initWithSavedTokenId:(NSString * _Nonnull)savedTokenId + maskedNumber:(NSString * _Nonnull)maskedNumber + tokenType:(NSString * _Nullable)tokenType + expiresAt:(NSString *_Nullable)expiresAt { + + if (self = [super init]) { + self.maskedNumber = maskedNumber; + self.savedTokenId = savedTokenId; + self.expiresAt = expiresAt; + self.statusCode = @""; + self.transactionId = @""; + self.type = [MidtransCreditCardHelper nameFromString:self.maskedNumber]; + } + return self; +} - (NSDictionary *)dictionaryValue { return @{kMTMaskedCreditCardIdentifier:self.savedTokenId, kMTMaskedCreditCardCardhash:self.maskedNumber, diff --git a/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.h b/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.h index f3a425f47..cb71727ec 100644 --- a/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.h +++ b/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.h @@ -62,7 +62,7 @@ * updated method, snapping */ - (void)requestTransacationWithCurrentToken:(NSString *_Nonnull)token - completion:(void (^_Nullable)(MidtransTransactionTokenResponse *_Nullable token, NSError *_Nullable error))completion; + completion:(void (^_Nullable)(MidtransTransactionTokenResponse *_Nullable regenerateToken, NSError *_Nullable error))completion; - (void)requestTransactionTokenWithTransactionDetails:(nonnull MidtransTransactionDetails *)transactionDetails itemDetails:(nullable NSArray *)itemDetails diff --git a/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.m b/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.m index 07d7cc9d1..742f978f8 100644 --- a/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.m +++ b/MidtransCoreKit/MidtransCoreKit/MidtransMerchantClient.m @@ -183,6 +183,7 @@ - (void)fetchMaskedCardsCustomer:(MidtransCustomerDetails *)customer completion: if (!error) { for (NSDictionary *dictionary in requestResponse) { MidtransMaskedCreditCard *card = [[MidtransMaskedCreditCard alloc] initWithDictionary:dictionary]; + NSLog(@"data--> %@",card); [result addObject:card]; } } @@ -228,9 +229,59 @@ - (void)requestCustomerPointWithToken:(NSString * _Nonnull )token } - (void)requestTransacationWithCurrentToken:(NSString *_Nonnull)token - completion:(void (^_Nullable)(MidtransTransactionTokenResponse *_Nullable token, NSError *_Nullable error))completion { + completion:(void (^_Nullable)(MidtransTransactionTokenResponse *_Nullable regenerateToken, NSError *_Nullable error))completion { - //NSString *URL = [NSString stringWithFormat:@"%@/%@", [CONFIG merchantURL], MIDTRANS_CORE_SNAP_MERCHANT_SERVER_CHARGE]; + NSString *URL = [NSString stringWithFormat:ENDPOINT_TRANSACTION_DETAIL, [PRIVATECONFIG snapURL], token]; + [[MidtransNetworking shared] getFromURL:URL parameters:nil callback:^(id response, NSError *error) { + if (!error) { + MidtransPaymentRequestV2Response *paymentRequestV2 = [[MidtransPaymentRequestV2Response alloc] initWithDictionary:(NSDictionary *)response]; + + if (completion) { + NSLog(@"response-->%@",response); + MidtransTransactionTokenResponse *token2; + + MidtransAddress *billAddressConstruct = [MidtransAddress addressWithFirstName:paymentRequestV2.customerDetails.billingAddress.firstName + lastName:paymentRequestV2.customerDetails.billingAddress.firstName + phone:paymentRequestV2.customerDetails.billingAddress.phone + address:paymentRequestV2.customerDetails.billingAddress.firstName + city:paymentRequestV2.customerDetails.billingAddress.city + postalCode:paymentRequestV2.customerDetails.billingAddress.postalCode + countryCode:paymentRequestV2.customerDetails.billingAddress.countryCode]; + + + NSNumber *amount = [NSNumber numberWithInteger:[paymentRequestV2.transactionDetails.grossAmount integerValue]]; + MidtransTransactionDetails *reConstructTransactionDetail = [[MidtransTransactionDetails alloc] initWithOrderID:paymentRequestV2.transactionDetails.orderId + andGrossAmount:amount]; + + + + MidtransCustomerDetails *customerDetailsMock = [[MidtransCustomerDetails alloc] initWithFirstName:paymentRequestV2.customerDetails.firstName + lastName:paymentRequestV2.customerDetails.firstName + email:paymentRequestV2.customerDetails.email + phone:paymentRequestV2.customerDetails.phone + shippingAddress:billAddressConstruct + billingAddress:billAddressConstruct]; + NSMutableArray *itemDetails = [NSMutableArray new]; + + for (MidtransPaymentRequestV2ItemDetails *detail in paymentRequestV2.itemDetails) { + MidtransItemDetail *regenerate = [[MidtransItemDetail alloc]initWithItemID:detail.itemDetailsIdentifier name:detail.name price:[NSNumber numberWithDouble:detail.price] quantity:[NSNumber numberWithDouble:detail.quantity]]; + [itemDetails addObject:regenerate]; + } + token2 = [MidtransTransactionTokenResponse modelObjectWithDictionary:@{@"token":token} + transactionDetails:reConstructTransactionDetail + customerDetails:customerDetailsMock + itemDetails:itemDetails]; + + completion(token2,NULL); + } + + } + else { + if (completion) { + completion(NULL,error); + } + } + }]; } - (void)requestTransactionTokenWithTransactionDetails:(nonnull MidtransTransactionDetails *)transactionDetails itemDetails:(nullable NSArray *)itemDetails diff --git a/MidtransCoreKit/MidtransCoreKit/MidtransTransactionResult.m b/MidtransCoreKit/MidtransCoreKit/MidtransTransactionResult.m index 93d4f82f5..9d25bbdd0 100644 --- a/MidtransCoreKit/MidtransCoreKit/MidtransTransactionResult.m +++ b/MidtransCoreKit/MidtransCoreKit/MidtransTransactionResult.m @@ -36,6 +36,7 @@ @implementation MidtransTransactionResult - (instancetype)initWithTransactionResponse:(NSDictionary *)response { self = [super init]; if (self) { + NSMutableDictionary *mResponse = [NSMutableDictionary dictionaryWithDictionary:response]; self.statusCode = [[mResponse objectThenDeleteForKey:@"status_code"] integerValue]; self.statusMessage = [mResponse objectThenDeleteForKey:@"status_message"]; @@ -43,7 +44,7 @@ - (instancetype)initWithTransactionResponse:(NSDictionary *)response { self.transactionStatus = [mResponse objectThenDeleteForKey:@"transaction_status"]; self.orderId = [mResponse objectThenDeleteForKey:@"order_id"]; self.paymentType = [mResponse objectThenDeleteForKey:@"payment_type"]; - + NSLog(@"daata-->%@",mResponse); id rawGrossAmount = [mResponse objectThenDeleteForKey:@"gross_amount"]; if (rawGrossAmount) { self.grossAmount = @([rawGrossAmount doubleValue]); diff --git a/MidtransCoreKit/MidtransCoreKit/Promo/MidtransPromoPromos.m b/MidtransCoreKit/MidtransCoreKit/Promo/MidtransPromoPromos.m index aee4a1f63..75bc9fe01 100644 --- a/MidtransCoreKit/MidtransCoreKit/Promo/MidtransPromoPromos.m +++ b/MidtransCoreKit/MidtransCoreKit/Promo/MidtransPromoPromos.m @@ -38,7 +38,12 @@ + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict { return [[self alloc] initWithDictionary:dict]; } - +- (NSString *)removeAllWhitespace:(NSString *)string{ + return [string stringByReplacingOccurrencesOfString:@"\\s" withString:@"" + options:NSRegularExpressionSearch + range:NSMakeRange(0, [string length])] + ; +} - (instancetype)initWithDictionary:(NSDictionary *)dict { self = [super init]; @@ -46,7 +51,12 @@ - (instancetype)initWithDictionary:(NSDictionary *)dict // This check serves to make sure that a non-NSDictionary object // passed into the model class doesn't break the parsing. if(self && [dict isKindOfClass:[NSDictionary class]]) { - self.bins = [self objectOrNilForKey:kMidtransPromoPromosBins fromDictionary:dict]; + NSMutableArray *array = [NSMutableArray new]; + for (int i =0; i<[[self objectOrNilForKey:kMidtransPromoPromosBins fromDictionary:dict] count]; i++) { + NSString *currValue =[[[self objectOrNilForKey:kMidtransPromoPromosBins fromDictionary:dict] objectAtIndex:i] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + [array addObject:currValue]; + } + self.bins = array; self.discountType = [self objectOrNilForKey:kMidtransPromoPromosDiscountType fromDictionary:dict]; self.promosIdentifier = [[self objectOrNilForKey:kMidtransPromoPromosId fromDictionary:dict] doubleValue]; self.discountedGrossAmount = [[self objectOrNilForKey:kMidtransPromoPromosDiscountedGrossAmount fromDictionary:dict] doubleValue]; diff --git a/MidtransDemo/MidtransDemo/MDAlertInputCell.xib b/MidtransDemo/MidtransDemo/MDAlertInputCell.xib index 80339f78c..b798d2ed2 100644 --- a/MidtransDemo/MidtransDemo/MDAlertInputCell.xib +++ b/MidtransDemo/MidtransDemo/MDAlertInputCell.xib @@ -1,11 +1,11 @@ - + - + diff --git a/MidtransDemo/MidtransDemo/MDAlertViewController.h b/MidtransDemo/MidtransDemo/MDAlertViewController.h index 86299c5fc..c36de5e0d 100644 --- a/MidtransDemo/MidtransDemo/MDAlertViewController.h +++ b/MidtransDemo/MidtransDemo/MDAlertViewController.h @@ -11,7 +11,8 @@ typedef NS_ENUM(NSUInteger, MDAlertOptionType) { MDAlertOptionTypeInput = 1, MDAlertOptionTypeRadio = 2, - MDAlertOptionTypeCheck = 3 + MDAlertOptionTypeCheck = 3, + MDAlertOptionTypeMultipleInput = 4 }; @class MDAlertViewController; @@ -22,6 +23,7 @@ typedef NS_ENUM(NSUInteger, MDAlertOptionType) { - (void)alertViewController:(MDAlertViewController *)viewController didApplyInput:(NSString *)inputText; - (void)alertViewController:(MDAlertViewController *)viewController didApplyRadio:(id)value; - (void)alertViewController:(MDAlertViewController *)viewController didApplyCheck:(NSArray *)values; +- (void)alertViewController:(MDAlertViewController *)viewController didApplyMultipleInput:(NSArray *)multipleInputText; @end @@ -33,6 +35,7 @@ typedef NS_ENUM(NSUInteger, MDAlertOptionType) { @property (nonatomic) NSString *inputPlaceholder; @property (nonatomic) NSString *inputText; @property (nonatomic) NSString *predefinedInputText; +@property (nonatomic) NSArray *multipleInputTexts; @property (nonatomic) id predefinedRadio; @property (nonatomic) NSArray *predefinedCheckLists; @@ -41,6 +44,10 @@ typedef NS_ENUM(NSUInteger, MDAlertOptionType) { + (MDAlertViewController *)alertWithTitle:(NSString *)title predefinedText:(NSString *)predefinedText inputPlaceholder:(NSString *)placeholder; ++ (MDAlertViewController *)alertWithTitle:(NSString *)title + multipleTextfields:(NSArray *)multipleTextfields + inputPlaceholder:(NSString *)placeholder; + - (void)show; - (void)dismiss; diff --git a/MidtransDemo/MidtransDemo/MDAlertViewController.m b/MidtransDemo/MidtransDemo/MDAlertViewController.m index 3b2a3df64..7789b590a 100644 --- a/MidtransDemo/MidtransDemo/MDAlertViewController.m +++ b/MidtransDemo/MidtransDemo/MDAlertViewController.m @@ -12,6 +12,8 @@ #import "MDAlertCheckCell.h" #import "MDUtils.h" +#define MDAlertInputCellHeight 50.f + @interface MDAlertViewController () @property (nonatomic) IBOutlet UITableView *tableView; @property (nonatomic) IBOutlet NSLayoutConstraint *tableHeightConstraint; @@ -24,6 +26,7 @@ @interface MDAlertViewController () @property (nonatomic) NSString *alertTitle; @property (nonatomic) NSArray *radioButtons; @property (nonatomic) NSArray *checkLists; +@property (nonatomic) NSArray *textfields; @property (nonatomic) MDAlertInputCell *inputCell; @end @@ -60,6 +63,18 @@ + (MDAlertViewController *)alertWithTitle:(NSString *)title return vc; } ++ (MDAlertViewController *)alertWithTitle:(NSString *)title + multipleTextfields:(NSArray *)multipleTextfields + inputPlaceholder:(NSString *)placeholder { + MDAlertViewController *vc = [[MDAlertViewController alloc] initWithNibName:@"MDAlertViewController" + bundle:nil]; + vc.alertTitle = title; + vc.multipleInputTexts = multipleTextfields; + vc.inputPlaceholder = placeholder; + vc.type = MDAlertOptionTypeMultipleInput; + return vc; +} + - (void)viewDidLoad { [super viewDidLoad]; @@ -94,6 +109,12 @@ - (void)viewDidLoad { } } } + else if (self.type == MDAlertOptionTypeMultipleInput) { + if (self.multipleInputTexts == nil) { + self.multipleInputTexts = @[@"", @"", @""]; + } + self.applyButton.enabled = NO; + } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; @@ -137,13 +158,16 @@ - (void)updateTableViewHeight { switch (self.type) { case MDAlertOptionTypeInput: - height = 50; + height = MDAlertInputCellHeight; break; case MDAlertOptionTypeRadio: for (int i=0; i < self.radioButtons.count; i++) { height += 44; } break; + case MDAlertOptionTypeMultipleInput: + height += 3 * MDAlertInputCellHeight; + break; default: for (int i=0; i < self.checkLists.count; i++) { height += 44; @@ -213,6 +237,11 @@ - (IBAction)applyTap:(UIButton *)sender { [self.delegate alertViewController:self didApplyInput:self.inputText]; } } + else if (self.type == MDAlertOptionTypeMultipleInput) { + if ([self.delegate respondsToSelector:@selector(alertViewController:didApplyMultipleInput:)]) { + [self.delegate alertViewController:self didApplyMultipleInput:self.multipleInputTexts]; + } + } else { if ([self.delegate respondsToSelector:@selector(alertViewController:didApplyCheck:)]) { NSArray *indexPaths = self.tableView.indexPathsForSelectedRows; @@ -234,6 +263,9 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger else if (self.type == MDAlertOptionTypeInput) { return 1; } + else if (self.type == MDAlertOptionTypeMultipleInput) { + return 3; + } else { return self.checkLists.count; } @@ -247,6 +279,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N else if (self.type == MDAlertOptionTypeInput) { return self.inputCell; } + else if (self.type == MDAlertOptionTypeMultipleInput) { + MDAlertInputCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"MDAlertInputCell"]; + cell.textField.hint = self.inputPlaceholder; + cell.textField.text = self.multipleInputTexts[indexPath.row]; + cell.textField.tag = indexPath.row; + [cell.textField addTarget:self action:@selector(inputTextChanged:) forControlEvents:UIControlEventEditingChanged]; + return cell; + } else { MDAlertCheckCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MDAlertCheckCell"]; cell.titleLabel.text = self.checkLists[indexPath.row]; @@ -254,8 +294,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.type == MDAlertOptionTypeInput) { - return 50; + if (self.type == MDAlertOptionTypeInput || self.type == MDAlertOptionTypeMultipleInput) { + return MDAlertInputCellHeight; } else { return 44; @@ -266,8 +306,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } - (void)inputTextChanged:(MDTextField *)textField { - self.inputText = textField.text; - self.applyButton.enabled = textField.text.length > 0; + if (self.type == MDAlertOptionTypeInput) { + self.inputText = textField.text; + self.applyButton.enabled = textField.text.length > 0; + } + else if (self.type == MDAlertOptionTypeMultipleInput) { + NSMutableArray *mutable = [NSMutableArray arrayWithArray:self.multipleInputTexts]; + [mutable replaceObjectAtIndex:textField.tag withObject:textField.text]; + self.multipleInputTexts = [NSArray arrayWithArray:mutable]; + self.applyButton.enabled = [self.multipleInputTexts componentsJoinedByString:@""].length > 0; + } } @end diff --git a/MidtransDemo/MidtransDemo/MDOptionComposerCell.xib b/MidtransDemo/MidtransDemo/MDOptionComposerCell.xib index cddbfab3d..b036281e5 100644 --- a/MidtransDemo/MidtransDemo/MDOptionComposerCell.xib +++ b/MidtransDemo/MidtransDemo/MDOptionComposerCell.xib @@ -1,11 +1,11 @@ - + - + diff --git a/MidtransDemo/MidtransDemo/MDOptionManager.h b/MidtransDemo/MidtransDemo/MDOptionManager.h index 07a9788ee..4daa590a6 100644 --- a/MidtransDemo/MidtransDemo/MDOptionManager.h +++ b/MidtransDemo/MidtransDemo/MDOptionManager.h @@ -26,6 +26,7 @@ @property (nonatomic) MDOption *permataVAOption; @property (nonatomic) MDOption *bcaVAOption; @property (nonatomic) MDOption *bniVAOption; +@property (nonatomic) MDOption *customFieldOption; @property (nonatomic) MDOption *mandiriPointOption; @property (nonatomic) MDOption *installmentOption; @property (nonatomic) MDOption *paymentChannel; diff --git a/MidtransDemo/MidtransDemo/MDOptionManager.m b/MidtransDemo/MidtransDemo/MDOptionManager.m index ab3b53d9f..32241fb0d 100644 --- a/MidtransDemo/MidtransDemo/MDOptionManager.m +++ b/MidtransDemo/MidtransDemo/MDOptionManager.m @@ -44,6 +44,7 @@ - (instancetype)init { self.bcaVAOption = [self unArchivedObject:@"md_bca_va"]; self.bniVAOption = [self unArchivedObject:@"md_bni_va"];; self.bniPointOption = [self unArchivedObject:@"md_bni_point"]; + self.customFieldOption = [self unArchivedObject:@"md_custom_field"]; self.installmentOption = [self unArchivedObject:@"md_installment"]; self.paymentChannel = [self unArchivedObject:@"md_payment_channel"]; } @@ -118,6 +119,10 @@ - (void)setBniVAOption:(MDOption *)bniVAOption { _bniVAOption = bniVAOption; [self archiveObject:bniVAOption key:@"md_bni_va"]; } +- (void)setCustomFieldOption:(MDOption *)customFieldOption { + _customFieldOption = customFieldOption; + [self archiveObject:customFieldOption key:@"md_custom_field"]; +} - (void)setInstallmentOption:(MDOption *)installmentOption { _installmentOption = installmentOption; [self archiveObject:installmentOption key:@"md_installment"]; @@ -160,6 +165,7 @@ - (void)resetConfiguration { self.bcaVAOption = nil; self.bniPointOption =nil; self.installmentOption =nil; + self.customFieldOption = nil; self.paymentChannel = nil; } @end diff --git a/MidtransDemo/MidtransDemo/MDOptionsViewController.m b/MidtransDemo/MidtransDemo/MDOptionsViewController.m index 147ebffe3..02f5f2bde 100644 --- a/MidtransDemo/MidtransDemo/MDOptionsViewController.m +++ b/MidtransDemo/MidtransDemo/MDOptionsViewController.m @@ -72,11 +72,15 @@ - (void)initConfiguration{ MidtransTransactionExpire *minute = [[MidtransTransactionExpire alloc] initWithExpireTime:[NSDate date] expireDuration:1 withUnitTime:MindtransTimeUnitTypeMinute]; + MidtransTransactionExpire *fiveMinutes = [[MidtransTransactionExpire alloc] initWithExpireTime:[NSDate date] + expireDuration:5 + withUnitTime:MindtransTimeUnitTypeMinutes]; MidtransTransactionExpire *hour = [[MidtransTransactionExpire alloc] initWithExpireTime:[NSDate date] expireDuration:1 withUnitTime:MindtransTimeUnitTypeHour]; options = @[[MDOption optionGeneralWithName:@"No Expiry" value:nil], [MDOption optionGeneralWithName:@"1 Minute" value:minute], + [MDOption optionGeneralWithName:@"5 Minute" value:fiveMinutes], [MDOption optionGeneralWithName:@"1 Hour" value:hour]]; MDOptionView *optCustomExpiry = [MDOptionView viewWithIcon:[UIImage imageNamed:@"expiry"] titleTemplate:@"%@" @@ -186,6 +190,16 @@ - (void)initConfiguration{ identifier:OPTBNIVA]; [optBNIVA selectOptionAtIndex:[options indexOfOption:[MDOptionManager shared].bniVAOption]]; + ///////////// + //custom field + options = @[[MDOption optionGeneralWithName:@"Disable" value:nil], + [MDOption optionComposer:MDComposerTypeText name:@"Enable" value:@""]]; + MDOptionView *optCustomField = [MDOptionView viewWithIcon:[UIImage imageNamed:@"custom_bca_va"] + titleTemplate:@"Custom Field %@d" + options:options + identifier:OPTCustomField]; + [optCustomField selectOptionAtIndex:[options indexOfOption:[MDOptionManager shared].customFieldOption]]; + ///////////// //installment @@ -227,6 +241,7 @@ - (void)initConfiguration{ optPermataVA, optBCAVA, optBNIVA, + optCustomField, optInstallment, optPaymentChannels ]; @@ -342,6 +357,19 @@ - (void)alertViewController:(MDAlertViewController *)viewController didApplyInpu [viewController dismiss]; } +- (void)alertViewController:(MDAlertViewController *)viewController didApplyMultipleInput:(NSArray *)multipleInputText { + NSUInteger index = viewController.tag; + MDOption *option = self.selectedOptionView.options[index]; + option.value = multipleInputText; + NSInteger count = [[multipleInputText filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF.length > 0"]] count]; + option.subName = [NSString stringWithFormat:@"%@ Fields", @(count)]; + + [self.selectedOptionView selectOptionAtIndex:index]; + + [MDUtils saveOptionWithView:self.selectedOptionView option:option]; + + [viewController dismiss]; +} - (void)alertViewController:(MDAlertViewController *)viewController didApplyCheck:(NSArray *)values { NSUInteger index = viewController.tag; MDOption *option = self.selectedOptionView.options[index]; @@ -420,6 +448,15 @@ - (void)showAlertAtOptionView:(MDOptionView *)optionView alert.tag = [optionView.options indexOfObject:option]; [alert show]; } + else if ([idf isEqualToString:OPTCustomField]) { + MDAlertViewController *alert = [MDAlertViewController alertWithTitle:@"Enable Custom Field" + multipleTextfields:option.value + inputPlaceholder:@"Custom Field"]; + alert.delegate = self; + alert.multipleInputTexts = usePredefinedValue? option.value: nil; + alert.tag = [optionView.options indexOfObject:option]; + [alert show]; + } self.selectedOptionView = optionView; } diff --git a/MidtransDemo/MidtransDemo/MDOrderViewController.m b/MidtransDemo/MidtransDemo/MDOrderViewController.m index be5a642f5..6e691a6ea 100644 --- a/MidtransDemo/MidtransDemo/MDOrderViewController.m +++ b/MidtransDemo/MidtransDemo/MDOrderViewController.m @@ -71,18 +71,14 @@ - (void)viewDidLoad { merchantServerURL:merchantServer]; //forced to use token storage - UICONFIG.hideStatusPage = YES; - CC_CONFIG.tokenStorageEnabled = NO; - CC_CONFIG.authenticationType = [[MDOptionManager shared].authTypeOption.value integerValue]; - - CC_CONFIG.saveCardEnabled =[[MDOptionManager shared].saveCardOption.value boolValue]; - - CC_CONFIG.secure3DEnabled =[[MDOptionManager shared].secure3DOption.value boolValue]; - CC_CONFIG.authenticationType = MTAuthenticationType3DS; - CC_CONFIG.acquiringBank = [[MDOptionManager shared].issuingBankOption.value integerValue]; - CC_CONFIG.predefinedInstallment = [MDOptionManager shared].installmentOption.value; - CC_CONFIG.preauthEnabled = [[MDOptionManager shared].preauthOption.value boolValue]; - CC_CONFIG.promoEnabled = [[MDOptionManager shared].promoOption.value boolValue]; + UICONFIG.hideStatusPage = NO; + [[MidtransCreditCardConfig shared] setPaymentType:MTCreditCardPaymentTypeTwoclick]; + [MidtransCreditCardConfig shared].setDefaultCreditSaveCardEnabled = YES; + [[MidtransCreditCardConfig shared] setSaveCardEnabled:TRUE]; + [[MidtransCreditCardConfig shared] setSecure3DEnabled:TRUE]; + [[MidtransCreditCardConfig shared] setTokenStorageEnabled:TRUE]; + [[MidtransUIConfiguration shared] setHideStatusPage:FALSE]; + [[MidtransNetworkLogger shared] startLogging]; //CC_CONFIG.showFormCredentialsUser = YES; /*set custom free text for bca*/ @@ -92,7 +88,7 @@ - (void)viewDidLoad { NSDictionary *freeText = @{@"inquiry":@[inquiryConstructor,inquiryConstructor2],@"payment":@[paymentConstructor]}; CONFIG.customFreeText = freeText; - UICONFIG.hideStatusPage = YES; + UICONFIG.hideStatusPage = NO; CONFIG.customPaymentChannels = [[MDOptionManager shared].paymentChannel.value valueForKey:@"type"]; CONFIG.customBCAVANumber = [MDOptionManager shared].bcaVAOption.value; CONFIG.customBNIVANumber = [MDOptionManager shared].bniVAOption.value; @@ -129,11 +125,11 @@ - (IBAction)bayarPressed:(id)sender { cst.customerIdentifier = @"3A8788CE-B96F-449C-8180-B5901A08B50A"; MidtransItemDetail *itm = [[MidtransItemDetail alloc] initWithItemID:[NSString randomWithLength:20] name:@"Midtrans Pillow" - price:@255000 + price:@200000 quantity:@1]; MidtransTransactionDetails *trx = [[MidtransTransactionDetails alloc] initWithOrderID:[NSString randomWithLength:20] - andGrossAmount:@255000]; + andGrossAmount:@200000]; //configure theme MidtransUIFontSource *font = [[MidtransUIFontSource alloc] initWithFontNameBold:@"SourceSansPro-Bold" @@ -145,47 +141,71 @@ - (IBAction)bayarPressed:(id)sender { NSArray *binFilter = @[]; NSArray *blacklistBin = @[]; - + binFilter = @[@"4"]; //configure expire time [[MidtransNetworkLogger shared] startLogging]; - NSDate *mydate = [NSDate date]; - NSTimeInterval secondsInEightHours = 1 * 60 * 60; - NSDate *dateEightHoursAhead = [mydate dateByAddingTimeInterval:secondsInEightHours]; - MidtransTransactionExpire *expireTime = [[MidtransTransactionExpire alloc] initWithExpireTime:nil expireDuration:1 withUnitTime:MindtransTimeUnitTypeHour]; + MidtransTransactionExpire * optExpireTime = [[[MDOptionManager shared] expireTimeOption] value]; + MindtransTimeUnitType unit; + if ([optExpireTime.unit isEqualToString:@"MINUTE"]) { + unit = MindtransTimeUnitTypeMinute; + } + else if ([optExpireTime.unit isEqualToString:@"MINUTES"]) { + unit = MindtransTimeUnitTypeMinutes; + } + else if ([optExpireTime.unit isEqualToString:@"HOUR"]) { + unit = MindtransTimeUnitTypeHour; + } + else if ([optExpireTime.unit isEqualToString:@"HOURS"]) { + unit = MindtransTimeUnitTypeHours; + } + else if ([optExpireTime.unit isEqualToString:@"DAY"]) { + unit = MindtransTimeUnitTypeDay; + } + else if ([optExpireTime.unit isEqualToString:@"DAYS"]) { + unit = MindtransTimeUnitTypeDays; + } + else { + unit = MindtransTimeUnitTypeHour; + } + MidtransTransactionExpire *expireTime = [[MidtransTransactionExpire alloc] initWithExpireTime:[NSDate date] expireDuration:optExpireTime.duration withUnitTime:unit]; //show hud [self.progressHUD showInView:self.navigationController.view]; - //NSArray *cf = @[MIDTRANS_CUSTOMFIELD_1:@{@"voucher_code":@"123",@"amount":@"123"}]; NSMutableArray *arrayOfCustomField = [NSMutableArray new]; - [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_2:@"VN00000015-sw4g4o0cws"}]; - [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_3:@"0--14"}]; - - NSError *error; - NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{@"voucher":@"123",@"code":@"data"} // Here you can pass array or dictionary - options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string - error:&error]; - NSString *jsonString; - if (jsonData) { - jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; - //This is your JSON String - //NSUTF8StringEncoding encodes special characters using an escaping scheme - } else { - NSLog(@"Got an error: %@", error); - jsonString = @""; + NSArray *value = [[[MDOptionManager shared] customFieldOption] value]; + if (value[0]) { + [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_1:value[0]}]; } - + if (value[1]) { + [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_2:value[1]}]; + } + if (value[2]) { + [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_3:value[2]}]; + } +// NSError *error; +// NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{@"voucher":@"123",@"code":@"data"} // Here you can pass array or dictionary +// options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string +// error:&error]; +// NSString *jsonString; +// if (jsonData) { +// jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; +// //This is your JSON String +// //NSUTF8StringEncoding encodes special characters using an escaping scheme +// } else { +// NSLog(@"Got an error: %@", error); +// jsonString = @""; +// } +// [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_1:jsonString}]; - [arrayOfCustomField addObject:@{MIDTRANS_CUSTOMFIELD_1:jsonString}]; - [[MidtransMerchantClient shared] requestTransactionTokenWithTransactionDetails:trx itemDetails:@[itm] customerDetails:cst customField:arrayOfCustomField binFilter:binFilter blacklistBinFilter:blacklistBin - transactionExpireTime:nil + transactionExpireTime:expireTime completion:^(MidtransTransactionTokenResponse * _Nullable token, NSError * _Nullable error) { @@ -200,7 +220,7 @@ - (IBAction)bayarPressed:(id)sender { [alert show]; } else { - + MidtransUIPaymentViewController *paymentVC = [[MidtransUIPaymentViewController alloc] initWithToken:token]; paymentVC.paymentDelegate = self; [self.navigationController presentViewController:paymentVC animated:YES completion:nil]; diff --git a/MidtransDemo/MidtransDemo/MDOrderViewController.xib b/MidtransDemo/MidtransDemo/MDOrderViewController.xib index 45c4dbfa6..c13fa8387 100644 --- a/MidtransDemo/MidtransDemo/MDOrderViewController.xib +++ b/MidtransDemo/MidtransDemo/MDOrderViewController.xib @@ -1,11 +1,11 @@ - + - + @@ -39,14 +39,14 @@ - @@ -25,20 +28,20 @@ - + - + @@ -56,7 +59,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -132,7 +99,7 @@ - + @@ -64,18 +64,39 @@ + + - + + - + + + + - + + @@ -89,7 +110,7 @@ - + @@ -307,12 +328,12 @@ + - @@ -333,6 +354,7 @@ + diff --git a/MidtransKit/MidtransKit/resources/MidtransPaymentGCIViewController.xib b/MidtransKit/MidtransKit/resources/MidtransPaymentGCIViewController.xib index 2d3cc1d02..dff7008de 100644 --- a/MidtransKit/MidtransKit/resources/MidtransPaymentGCIViewController.xib +++ b/MidtransKit/MidtransKit/resources/MidtransPaymentGCIViewController.xib @@ -1,6 +1,6 @@ - + @@ -27,17 +27,17 @@ - + - + - + - + @@ -54,7 +54,7 @@ - + @@ -90,7 +90,7 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + + + + + + + + + + + + + - - - + - + + + @@ -184,27 +172,25 @@ - + + - + - - + + - - - - + - + - - + + diff --git a/MidtransKit/MidtransKit/resources/MidtransSavedCardController.xib b/MidtransKit/MidtransKit/resources/MidtransSavedCardController.xib index e742dc0e1..c0c24126b 100644 --- a/MidtransKit/MidtransKit/resources/MidtransSavedCardController.xib +++ b/MidtransKit/MidtransKit/resources/MidtransSavedCardController.xib @@ -12,14 +12,18 @@ SourceSansPro-Regular + + SourceSansPro-Semibold + + - - - + + + @@ -29,42 +33,63 @@ - + - - + + - - - - - - - - - - + + + + + + + + + + + + + + @@ -80,13 +105,13 @@ - - + - + + - + diff --git a/MidtransKit/MidtransKit/resources/MidtransUIPaymentDirectViewController.xib b/MidtransKit/MidtransKit/resources/MidtransUIPaymentDirectViewController.xib index 1b0e10ae9..06a84e925 100644 --- a/MidtransKit/MidtransKit/resources/MidtransUIPaymentDirectViewController.xib +++ b/MidtransKit/MidtransKit/resources/MidtransUIPaymentDirectViewController.xib @@ -1,11 +1,11 @@ - - + + - + @@ -25,11 +25,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -132,41 +86,108 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + - - - + + + diff --git a/MidtransKit/MidtransKit/resources/MidtransUIPaymentGeneralViewController.xib b/MidtransKit/MidtransKit/resources/MidtransUIPaymentGeneralViewController.xib index c8354e13c..8dde4d4cc 100644 --- a/MidtransKit/MidtransKit/resources/MidtransUIPaymentGeneralViewController.xib +++ b/MidtransKit/MidtransKit/resources/MidtransUIPaymentGeneralViewController.xib @@ -65,86 +65,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -174,40 +96,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - - - - - + - + - - - + + + diff --git a/MidtransKit/MidtransKit/resources/MidtransVAViewController.xib b/MidtransKit/MidtransKit/resources/MidtransVAViewController.xib index 83d41de42..552d0f8a4 100644 --- a/MidtransKit/MidtransKit/resources/MidtransVAViewController.xib +++ b/MidtransKit/MidtransKit/resources/MidtransVAViewController.xib @@ -1,11 +1,11 @@ - - + + - + @@ -19,22 +19,22 @@ - + + - - - + + - + - - + + + + + + + + + + + + + - - + - - - - - - - + + + + + + + + + + + + + + - - - + - + + + - - - - - - - - - - - - - - - - - + - + + + + + + - - - + - + + - + diff --git a/MidtransKit/MidtransKit/resources/SNPPostPaymentGeneralViewController.xib b/MidtransKit/MidtransKit/resources/SNPPostPaymentGeneralViewController.xib index 5b465e8dd..07c378421 100644 --- a/MidtransKit/MidtransKit/resources/SNPPostPaymentGeneralViewController.xib +++ b/MidtransKit/MidtransKit/resources/SNPPostPaymentGeneralViewController.xib @@ -19,7 +19,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -48,70 +48,92 @@ - - + + - - + - - - - - - - + + + + + + + + + + + + + + - - - + - + + + - - + + + - - + + - - + diff --git a/MidtransKit/MidtransKit/resources/SNPPostPaymentVAViewController.xib b/MidtransKit/MidtransKit/resources/SNPPostPaymentVAViewController.xib index f2ce66377..0c2d026ed 100644 --- a/MidtransKit/MidtransKit/resources/SNPPostPaymentVAViewController.xib +++ b/MidtransKit/MidtransKit/resources/SNPPostPaymentVAViewController.xib @@ -1,6 +1,6 @@ - + @@ -20,27 +20,24 @@ - + - - + + - + - + - - - - - + + - - + - - - - - - - - - + + + + + + + + + + + + + + - - - + - + + + - + + + + - - - + - + - + diff --git a/MidtransKit/MidtransKit/resources/VTMandiriClickpayController.xib b/MidtransKit/MidtransKit/resources/VTMandiriClickpayController.xib index 0076096e9..58a0a5888 100644 --- a/MidtransKit/MidtransKit/resources/VTMandiriClickpayController.xib +++ b/MidtransKit/MidtransKit/resources/VTMandiriClickpayController.xib @@ -1,11 +1,11 @@ - - + + - + @@ -20,7 +20,7 @@ - + @@ -33,15 +33,15 @@ + - - + - + @@ -56,7 +56,7 @@ - + @@ -101,52 +101,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -158,13 +114,13 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -407,7 +429,7 @@ - + @@ -416,17 +438,17 @@ + - - + - + diff --git a/MidtransKit/MidtransKit/resources/VTVAListController.xib b/MidtransKit/MidtransKit/resources/VTVAListController.xib index 4c196f7e8..82cfb5d15 100644 --- a/MidtransKit/MidtransKit/resources/VTVAListController.xib +++ b/MidtransKit/MidtransKit/resources/VTVAListController.xib @@ -1,6 +1,6 @@ - + @@ -16,84 +16,109 @@ + - - - + + + - + - - - - - - - - - - - - + + - - + - - - - - - - - - + + + + + + + + + + + + + + - - - + - + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + diff --git a/MidtransKit/MidtransResources/MIDDanamonOnlineViewController.xib b/MidtransKit/MidtransResources/MIDDanamonOnlineViewController.xib index 2e3288e19..006f903c9 100644 --- a/MidtransKit/MidtransResources/MIDDanamonOnlineViewController.xib +++ b/MidtransKit/MidtransResources/MIDDanamonOnlineViewController.xib @@ -1,11 +1,11 @@ - + - + @@ -19,15 +19,15 @@ - + - - + + @@ -48,53 +48,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - + - - - - - + + + + + + + + + + + + + + - - - + - + + + - - - - - + + - - + - + - + diff --git a/MidtransSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/MidtransSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/MidtransSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Podpecs/MidtransCoreKit.podspec b/Podpecs/MidtransCoreKit.podspec index a79051f8e..8055fa08b 100644 --- a/Podpecs/MidtransCoreKit.podspec +++ b/Podpecs/MidtransCoreKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MidtransCoreKit" -s.version = "1.12.0" +s.version = "1.12.1" s.summary = "Veritrans mobile SDK beta version" s.homepage = "https://veritrans.co.id/" s.license = 'MIT' diff --git a/Podpecs/MidtransKit.podspec b/Podpecs/MidtransKit.podspec index c2bd7bf4b..e7d5892f8 100644 --- a/Podpecs/MidtransKit.podspec +++ b/Podpecs/MidtransKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MidtransKit" -s.version = "1.12.0" +s.version = "1.12.1" s.summary = "Veritrans mobile SDK beta version" s.homepage = "https://veritrans.co.id/" s.license = 'MIT' @@ -17,7 +17,7 @@ s.source_files = 'MidtransKit/MidtransKit/**/*.{h,m}' s.resource_bundles = { 'MidtransKit' => ['MidtransKit/MidtransKit/resources/*'] } -s.dependency 'MidtransCoreKit', '~>1.12.0' +s.dependency 'MidtransCoreKit', '~>1.12.1' s.static_framework = true s.default_subspec = 'UI'