- //
- // CompraDatosPago_ViewController.m
- // Cinépolis
- //
- // Created by jgaona on 22/07/13.
- // Copyright (c) 2013 IA Interactive. All rights reserved.
- //
- #import "CompraDatosPago_ViewController.h"
- #import "AppDelegate.h"
- #import "Compra_ViewController.h"
- #import "AppDelegate.h"
- #import "CompraConfirmacion_ViewController.h"
- #import "Global.h"
- #import "TarjetaBancaria.h"
- #import "Datos.h"
- #import "TSMessage.h"
- #import "LocalizationSystem.h"
- #import "Cinecash.h"
- #import "CargandoCinepolis.h"
- #import "UIFont+CustomInit.h"
- #import "InstructionsView.h"
- #import "UIAlertView+Blocks.h"
- #import "Cartelera_ViewController.h"
- #import "CarteleraIPhonePlus_ViewController.h"
- #import "UIViewController+IniciaConEstilo.h"
- #import <TrustDefenderMobile/TrustDefenderMobile.h>
- ============
- @interface CompraDatosPago_ViewController ()
- {
- UIButton *btn_visa;
- BOOL usando_visa;
- }
- @property (strong, nonatomic) VisaCheckout *visaCheckout;
- @end
- ============
- btn_visa = [[UIButton alloc] initWithFrame:self.btn_adelante.frame];
- btn_visa.hidden = YES;
- [btn_visa setBackgroundImage:[UIImage imageNamed:@"visa_checkout_btn"] forState:UIControlStateNormal];
- [btn_visa addTarget:self action:@selector(invokeVISASDKDirectly) forControlEvents:UIControlEventTouchDown];
- [self.btn_adelante.superview addSubview:btn_visa];
- ============
- #pragma mark - Visa Invoke
- - (void)invokeVISASDKDirectly {
- [self.visaCheckout invokeVisaCheckout:^(NSError *error) {
- if (error) {
- NSLog(@"Error Details..%@", [error localizedDescription]);
- }
- } withOptions:nil withDelegate:self];
- }
- #pragma mark - Visa Checkout delegate
- - (void)checkoutSuccessWithSummary:(VisaPaymentSummary*)paymentSummary {
- NSLog(@"success");
- NSString *successResponse = [NSString stringWithFormat:@"callID: %@\r lastFourDigits: %@\r cardBrand: %@\r cardType: %@\r countryCode: %@\r postalCode: %@\r encKey: %@\r encPaymentData: %@",paymentSummary.callId,
- paymentSummary.lastFourDigits, paymentSummary.cardBrand, paymentSummary.cardType, paymentSummary.countryCode, paymentSummary.postalCode, paymentSummary.encKey, paymentSummary.encPaymentData];
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Payment successful!" message:successResponse delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
- [alertView show];
- }
- - (void)checkoutFailedWithError:(NSError*)error{
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
- [alertView show];
- NSLog(@"Error - %@", [error description]);
- }
- - (void)checkoutCancelled {
- NSLog(@"Cancelled");
- }
- ============
- - (VisaPaymentInfo *)paymentInfo {
- VisaPaymentInfo *paymentInfo = [[VisaPaymentInfo alloc] init];
- [paymentInfo setAmount:[NSDecimalNumber decimalNumberWithString:@"12"]];
- [paymentInfo setCurrency:VCurrencyCodeUS];
- paymentInfo.merchantRequestId = @"a001";
- paymentInfo.subtotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%f", [[Global sharedInstance].compra TotalCantidadEnCentavos:YES]]];
- paymentInfo.shippingHandlingCharges = [NSDecimalNumber decimalNumberWithString:@"0"];
- paymentInfo.tax = [NSDecimalNumber decimalNumberWithString:@"0"];
- paymentInfo.discount = [NSDecimalNumber decimalNumberWithString:@"0"];
- paymentInfo.giftWrapCharges = [NSDecimalNumber decimalNumberWithString:@"0"];
- paymentInfo.miscCharges = [NSDecimalNumber decimalNumberWithString:@"0"];
- paymentInfo.paymentDescription = @"tickets";
- paymentInfo.orderId = @"111";
- paymentInfo.promoCode = @"freeCheckout";
- paymentInfo.isShippingAddressRequired = YES;
- paymentInfo.datalevel = @"SUMMARY";
- // Pass merchant informationu
- VisaMerchantInfo *merchantInfo = [[VisaMerchantInfo alloc] init];
- merchantInfo.merchantAPIKey = @"LXFQZOKJIXXFYO20OMI313Hal2ScbAZYETLKqaXZpHFqZ8bDw";
- merchantInfo.userReviewAction = kVisaUserReviewActionContinue;
- merchantInfo.displayName = @"Cinépolis";
- merchantInfo.externalProfileId = @"defaultprofile";
- merchantInfo.merchantLogoAssetName = @"mercLogo";
- merchantInfo.canadianDebitCardSupport = VAcceptCanadianDebitCard;
- merchantInfo.preferredLocale = VLocale_enUS;
- paymentInfo.merchantInfo = merchantInfo;
- //set up 3DS
- VisaThreeDSSetUp *threeDSSetUp = [VisaThreeDSSetUp new];
- threeDSSetUp.threeDSActive = VisaActivate3DS;
- paymentInfo.threeDSSetUp = threeDSSetUp;
- NSMutableArray *cardBrandArray = [[NSMutableArray alloc] initWithObjects:@"Visa", @"MasterCard", @"AMEX", @"Discover", nil];
- paymentInfo.acceptedPaymentTypesAndBrands = cardBrandArray;
- //set accepted countries for shipping
- NSMutableArray *acceptedShippingCountryList = [[NSMutableArray alloc] initWithObjects:@"MX", nil];
- paymentInfo.acceptedShippingCountries = acceptedShippingCountryList;
- //set accepted countries for billing
- NSMutableArray *acceptedBillingCountryList = [[NSMutableArray alloc] initWithObjects:@"MX", nil];
- paymentInfo.acceptedBillingCountries = acceptedBillingCountryList;
- return paymentInfo;
- }