Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Added Card.IO for iOS Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Apr 15, 2014
1 parent e8cdef8 commit c8c6e79
Show file tree
Hide file tree
Showing 16 changed files with 646 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CardIO/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ASSEMBLY=HockeyApp.iOS.dll
include ../Rules.make

25 changes: 25 additions & 0 deletions CardIO/binding/Additions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace Card.IO
{
public partial class PaymentViewControllerDelegate : BasePaymentViewControllerDelegate
{
public delegate void ScanCompleted(PaymentViewController viewController, CreditCardInfo cardInfo);
public event ScanCompleted OnScanCompleted;

public override void UserDidCancel (PaymentViewController paymentViewController)
{
var evt = OnScanCompleted;
if (evt != null)
evt(paymentViewController, null);
}

public override void UserDidProvideCreditCardInfo (CreditCardInfo cardInfo, PaymentViewController paymentViewController)
{
var evt = OnScanCompleted;
if (evt != null)
evt(paymentViewController, cardInfo);
}
}
}

179 changes: 179 additions & 0 deletions CardIO/binding/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
using System.Drawing;
using System;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.ObjCRuntime;

namespace Card.IO
{
[BaseType (typeof (NSObject))]
[Protocol]
public partial interface CreditCardInfo
{
[Export ("cardNumber", ArgumentSemantic.Copy)]
string CardNumber { get; set; }

[Export ("redactedCardNumber", ArgumentSemantic.Copy)]
string RedactedCardNumber { get; }

[Export ("expiryMonth")]
uint ExpiryMonth { get; set; }

[Export ("expiryYear")]
uint ExpiryYear { get; set; }

[Export ("cvv", ArgumentSemantic.Copy)]
string Cvv { get; set; }

[Export ("postalCode", ArgumentSemantic.Copy)]
string PostalCode { get; set; }

// [Export ("zip", ArgumentSemantic.Copy)]
// string Zip { [Bind ("postalCode")] get; [Bind ("setPostalCode:")] set; }

[Export ("scanned")]
bool Scanned { get; set; }

[Export ("cardType")]
CreditCardType CardType { get; }

[Static, Export ("displayStringForCardType:usingLanguageOrLocale:")]
string DisplayStringForCardType (CreditCardType cardType, string languageOrLocale);

[Static, Export ("logoForCardType:")]
UIImage LogoForCardType (CreditCardType cardType);
}

[Model, Protocol, BaseType (typeof (NSObject))]
public partial interface CardIOViewDelegate {

[Export ("cardIOView:didScanCard:")]
void DidScanCard (CardIOView cardIOView, CreditCardInfo cardInfo);
}

[BaseType (typeof (UIView))]
public partial interface CardIOView {

[Static, Export ("canReadCardWithCamera")]
bool CanReadCardWithCamera { get; }

[Export ("appToken", ArgumentSemantic.Copy)]
string AppToken { get; set; }

[Export ("delegate", ArgumentSemantic.Retain)]
CardIOViewDelegate Delegate { get; set; }

[Export ("languageOrLocale", ArgumentSemantic.Copy)]
string LanguageOrLocale { get; set; }

[Export ("guideColor", ArgumentSemantic.Retain)]
UIColor GuideColor { get; set; }

[Export ("useCardIOLogo")]
bool UseCardIOLogo { get; set; }

[Export ("allowFreelyRotatingCardGuide")]
bool AllowFreelyRotatingCardGuide { get; set; }

[Export ("scannedImageDuration")]
float ScannedImageDuration { get; set; }

[Export ("cameraPreviewFrame", ArgumentSemantic.Assign)]
RectangleF CameraPreviewFrame { get; }
}

[Model, Protocol, BaseType (typeof (NSObject), Name="CardIOPaymentViewControllerDelegate")]
public partial interface BasePaymentViewControllerDelegate {

[Export ("userDidCancelPaymentViewController:")]
//[EventArgs ("UserDidCancel")]
void UserDidCancel (PaymentViewController paymentViewController);

[Export ("userDidProvideCreditCardInfo:inPaymentViewController:")]
//[EventArgs ("UserDidProvideCreditCardInfo")]
void UserDidProvideCreditCardInfo (CreditCardInfo cardInfo, PaymentViewController paymentViewController);
}

public partial class PaymentViewControllerDelegate {
}

[BaseType (typeof (UINavigationController),
Name="CardIOPaymentViewController")]
public partial interface PaymentViewController {

//[Export("init")]
//IntPtr Constructor ();

[Export ("initWithPaymentDelegate:")]
IntPtr Constructor (BasePaymentViewControllerDelegate paymentDelegate);

[Export ("initWithPaymentDelegate:scanningEnabled:")]
IntPtr Constructor (BasePaymentViewControllerDelegate paymentDelegate, bool scanningEnabled);

[Export ("appToken", ArgumentSemantic.Copy)]
string AppToken { get; set; }

[Export ("languageOrLocale", ArgumentSemantic.Copy)]
string LanguageOrLocale { get; set; }

[Export ("keepStatusBarStyle")]
bool KeepStatusBarStyle { get; set; }

[Export ("navigationBarStyle")]
UIBarStyle NavigationBarStyle { get; set; }

[Export ("navigationBarTintColor", ArgumentSemantic.Retain)]
UIColor NavigationBarTintColor { get; set; }

[Export ("disableBlurWhenBackgrounding")]
bool DisableBlurWhenBackgrounding { get; set; }

[Export ("guideColor", ArgumentSemantic.Retain)]
UIColor GuideColor { get; set; }

[Export ("suppressScanConfirmation")]
bool SuppressScanConfirmation { get; set; }

[Export ("suppressScannedCardImage")]
bool SuppressScannedCardImage { get; set; }

[Export ("collectExpiry")]
bool CollectExpiry { get; set; }

[Export ("collectCVV")]
bool CollectCVV { get; set; }

[Export ("collectPostalCode")]
bool CollectPostalCode { get; set; }

// [Export ("collectZip")]
// bool CollectZip { [Bind ("collectPostalCode")] get; [Bind ("setCollectPostalCode:")] set; }

[Export ("useCardIOLogo")]
bool UseCardIOLogo { get; set; }

[Export ("allowFreelyRotatingCardGuide")]
bool AllowFreelyRotatingCardGuide { get; set; }

[Export ("disableManualEntryButtons")]
bool DisableManualEntryButtons { get; set; }

[Export("paymentDelegate", ArgumentSemantic.Assign)]
[NullAllowed]
NSObject WeakDelegate { get;set; }

[NullAllowed]
[Wrap("WeakDelegate")] //Export ("paymentDelegate", ArgumentSemantic.Assign)]
BasePaymentViewControllerDelegate Delegate { get; set; }

[Static, Export ("canReadCardWithCamera")]
bool CanReadCardWithCamera { get; }

[Static, Export ("libraryVersion")]
string LibraryVersion { get; }

[Export ("showsFirstUseAlert")]
bool ShowsFirstUseAlert { get; set; }
}
}
58 changes: 58 additions & 0 deletions CardIO/binding/Card.IO.iOS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{91D97F69-DE76-405B-BA3B-614B65B52143}</ProjectGuid>
<ProjectTypeGuids>{F5B4F3BC-B597-4E2B-B552-EF5D8A32436F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Card.IO.iOS</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>Card.IO.iOS</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="monotouch" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Xamarin.ObjcBinding.CSharp.targets" />
<ItemGroup>
<ObjcBindingNativeLibrary Include="libCardIO.a" />
</ItemGroup>
<ItemGroup>
<Compile Include="libCardIO.linkwith.cs">
<DependentUpon>libCardIO.a</DependentUpon>
</Compile>
<Compile Include="Additions.cs" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions CardIO/binding/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
BTOUCH=/Developer/MonoTouch/usr/bin/btouch
SMCS=/Developer/MonoTouch/usr/bin/smcs
MONOXBUILD=/Library/Frameworks/Mono.framework/Commands/xbuild
MDTOOL=/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool
VERSION=3.6.4
# Card.IO iOS Version 3.5.4

all: Card.IO.iOS.dll

Prepare:
curl -L -o Card.IO-iOS-$(VERSION).zip https://github.com/card-io/card.io-iOS-SDK/releases/download/v$(VERSION)/card.io_ios_sdk_$(VERSION).zip
unzip Card.IO-iOS-$(VERSION).zip
cp card.io_ios_sdk_$(VERSION)/CardIO/libCardIO.a libCardIO.a

Card.IO.iOS.dll: Prepare
$(MDTOOL) build -c:"Release" Card.IO.iOS.csproj
cp bin/Release/Card.IO.iOS.dll Card.IO.iOS.dll

clean:
-rm -rf Resources/ bin/ obj/ *.dll *.o *.mdb *.a card.io_ios_sdk_$(VERSION)/ *.zip
16 changes: 16 additions & 0 deletions CardIO/binding/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace Card.IO
{
public enum CreditCardType {
Unknown = 0,
Unrecognized = 0,
Ambiguous = 1,
Amex = 51 /* '3' */,
JCB = 74 /* 'J' */,
Visa = 52 /* '4' */,
Mastercard = 53 /* '5' */,
Discover = 54 /* '6' */
}
}

4 changes: 4 additions & 0 deletions CardIO/binding/libCardIO.linkwith.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System;
using MonoTouch.ObjCRuntime;

[assembly: LinkWith ("libCardIO.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true, IsCxx = true, WeakFrameworks="AudioToolbox AVFoundation CoreGraphics CoreMedia Foundation MobileCoreServices OpenGLES QuartzCore Security UIKit")]
56 changes: 56 additions & 0 deletions CardIO/samples/CardIOSampleiOS/CardIOSampleiOS.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CardIOSampleiOS", "CardIOSampleiOS\CardIOSampleiOS.csproj", "{951B31ED-C6B5-4F8E-B66E-78DD635B9151}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Card.IO.iOS", "..\..\binding\Card.IO.iOS.csproj", "{91D97F69-DE76-405B-BA3B-614B65B52143}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
Ad-Hoc|iPhone = Ad-Hoc|iPhone
AppStore|iPhone = AppStore|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91D97F69-DE76-405B-BA3B-614B65B52143}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.AppStore|iPhone.Build.0 = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Debug|iPhone.Build.0 = Debug|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Release|Any CPU.Build.0 = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Release|iPhone.ActiveCfg = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Release|iPhone.Build.0 = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{91D97F69-DE76-405B-BA3B-614B65B52143}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.AppStore|iPhone.Build.0 = AppStore|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Debug|iPhone.ActiveCfg = Debug|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Debug|iPhone.Build.0 = Debug|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Release|iPhone.ActiveCfg = Release|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Release|iPhone.Build.0 = Release|iPhone
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{951B31ED-C6B5-4F8E-B66E-78DD635B9151}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = CardIOSampleiOS\CardIOSampleiOS.csproj
EndGlobalSection
EndGlobal
Loading

0 comments on commit c8c6e79

Please sign in to comment.