-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8080145
Showing
42 changed files
with
1,611 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
android/dist/ | ||
android/libs/ | ||
android/build/ | ||
iphone/dist/ | ||
iphone/build/ | ||
iphone/*.zip | ||
iphone/CardIO/CardIO/libCardIO.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Appcelerator Card.io Module | ||
=========================== | ||
|
||
Appcelerator wrapper for the Card.io credit card scanning library. Use the phone's camera to read credit card numbers and expiration dates. | ||
|
||
See example/app.js for usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="android/src"/> | ||
<classpathentry kind="src" path="android/build/.apt_generated"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="/Library/Application Support/Titanium/mobilesdk/android-sdk-mac_x86/platforms/android-21/android.jar"/> | ||
<classpathentry kind="lib" path="/Library/Application Support/Titanium/mobilesdk/android-sdk-mac_x86/add-ons/addon-google_apis-google-21/libs/maps.jar"/> | ||
<classpathentry kind="lib" path="/Users/askinner/Library/Application Support/Titanium/mobilesdk/osx/4.0.1/android/titanium.jar"/> | ||
<classpathentry kind="lib" path="/Users/askinner/Library/Application Support/Titanium/mobilesdk/osx/4.0.1/android/kroll-common.jar"/> | ||
<classpathentry kind="lib" path="/Users/askinner/Library/Application Support/Titanium/mobilesdk/osx/4.0.1/android/kroll-apt.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ios</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.appcelerator.titanium.core.builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.aptana.ide.core.unifiedBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>com.appcelerator.titanium.mobile.module.nature</nature> | ||
<nature>com.aptana.projects.webnature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#Thu Sep 02 15:18:34 CDT 2010 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=true | ||
org.eclipse.jdt.apt.genSrcDir=.apt_generated | ||
org.eclipse.jdt.apt.reconcileEnabled=true | ||
|
||
org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=ios.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Thu Sep 02 15:18:34 CDT 2010 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.processAnnotations=enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
titanium.platform=/Users/askinner/Library/Application Support/Titanium/mobilesdk/osx/4.0.1/android | ||
android.platform=/Library/Application Support/Titanium/mobilesdk/android-sdk-mac_x86/platforms/android-21 | ||
google.apis=/Library/Application Support/Titanium/mobilesdk/android-sdk-mac_x86/add-ons/addon-google_apis-google-21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<project name="ios" default="dist"> | ||
<description> | ||
Ant build script for Titanium Android module ios | ||
</description> | ||
|
||
<property name="ti.module.root" location="${basedir}"/> | ||
<property file="build.properties" /> | ||
|
||
<!-- Make sure 'architectures' is in manifest file --> | ||
<property file="${ti.module.root}/manifest" prefix="manifest"/> | ||
<fail message="Missing required manifest key 'architectures'."> | ||
<condition> | ||
<not> | ||
<isset property="manifest.architectures"/> | ||
</not> | ||
</condition> | ||
</fail> | ||
|
||
<fail message="Manifest key 'architectures' has no value."> | ||
<condition> | ||
<not> | ||
<length string="${manifest.architectures}" trim="true" when="greater" length="0"/> | ||
</not> | ||
</condition> | ||
</fail> | ||
|
||
<!-- Copy documentation subdirectories --> | ||
<mkdir dir="${basedir}/documentation"/> | ||
<copy todir="${basedir}/documentation"> | ||
<fileset dir="${basedir}/../documentation"/> | ||
</copy> | ||
|
||
<!-- Copy example subdirectories --> | ||
<mkdir dir="${basedir}/example"/> | ||
<copy todir="${basedir}/example"> | ||
<fileset dir="${basedir}/../example"/> | ||
</copy> | ||
|
||
<!-- Copy assets subdirectories --> | ||
<mkdir dir="${basedir}/assets"/> | ||
<copy todir="${basedir}/assets"> | ||
<fileset dir="${basedir}/../assets"/> | ||
</copy> | ||
|
||
<!-- Copy license --> | ||
<copy todir="${basedir}" file="${basedir}/../LICENSE"/> | ||
|
||
<target name="cleancopy" description="Delete old copies"> | ||
<delete dir="${basedir}/documentation"/> | ||
<delete dir="${basedir}/example"/> | ||
<delete dir="${basedir}/assets"/> | ||
<delete file="${basedir}/LICENSE"/> | ||
</target> | ||
|
||
<target name="post.jar"> | ||
<copy todir="${libs}/armeabi"> | ||
<fileset dir="jniLibs/armeabi"> | ||
<include name="*.so"/> | ||
</fileset> | ||
</copy> | ||
<copy todir="${libs}/armeabi-v7a"> | ||
<fileset dir="jniLibs/armeabi-v7a"> | ||
<include name="*.so"/> | ||
</fileset> | ||
</copy> | ||
<copy todir="${libs}/x86"> | ||
<fileset dir="jniLibs/x86"> | ||
<include name="*.so"/> | ||
</fileset> | ||
</copy> | ||
</target> | ||
|
||
<import file="${titanium.platform}/../module/android/build.xml"/> | ||
</project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
You can place any .jar dependencies in this directory and they will be included | ||
when your module is being compiled. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# this is your module manifest and used by Titanium | ||
# during compilation, packaging, distribution, etc. | ||
# | ||
version: 1.0.0 | ||
apiversion: 2 | ||
architectures: armeabi armeabi-v7a x86 | ||
description: Appcelerator wrapper for the Card.io credit card scanning library. Use the phone's camera to read credit card numbers and expiration dates. | ||
author: Likely Solutions | ||
license: Free | ||
copyright: Copyright (c) 2015 by Likely Solutions | ||
|
||
# these should not be edited | ||
name: Card.io | ||
moduleid: com.likelysoft.cardio | ||
guid: c0304131-9611-4fff-9f83-f48bc9fa1714 | ||
platform: android | ||
minsdk: 4.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/** | ||
* This file was auto-generated by the Titanium Module SDK helper for Android | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
* | ||
*/ | ||
package com.likelysoft.cardio; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import org.appcelerator.kroll.KrollModule; | ||
import org.appcelerator.kroll.KrollFunction; | ||
import org.appcelerator.kroll.KrollDict; | ||
import org.appcelerator.kroll.KrollObject; | ||
import org.appcelerator.kroll.annotations.Kroll; | ||
import org.appcelerator.titanium.util.TiConvert; | ||
|
||
import org.appcelerator.titanium.TiApplication; | ||
import org.appcelerator.titanium.TiContext; | ||
import org.appcelerator.kroll.common.Log; | ||
import org.appcelerator.kroll.common.TiConfig; | ||
|
||
import io.card.payment.CardIOActivity; | ||
import io.card.payment.CreditCard; | ||
|
||
import org.appcelerator.titanium.util.TiActivityResultHandler; | ||
import org.appcelerator.titanium.util.TiActivitySupport; | ||
import org.appcelerator.titanium.util.TiIntentWrapper; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
|
||
@Kroll.module(name="CardIO", id="com.likelysoft.cardio") | ||
public class CardIOModule extends KrollModule | ||
{ | ||
private int MY_SCAN_REQUEST_CODE = 100; | ||
|
||
// Standard Debugging variables | ||
private static final String LCAT = "CardIOModule"; | ||
private static final boolean DBG = TiConfig.LOGD; | ||
|
||
public CardIOModule() | ||
{ | ||
super(); | ||
} | ||
|
||
@Kroll.onAppCreate | ||
public static void onAppCreate(TiApplication app) | ||
{ | ||
Log.d(LCAT, "inside onAppCreate"); | ||
} | ||
|
||
// Methods | ||
// Scan a card | ||
@Kroll.method | ||
public void scanCard(KrollFunction callback) throws Exception { | ||
Log.d(LCAT, "inside CardIO scanCard"); | ||
|
||
final Activity activity = TiApplication.getAppCurrentActivity(); | ||
final TiActivitySupport activitySupport = (TiActivitySupport) activity; | ||
|
||
final TiIntentWrapper scanIntent = new TiIntentWrapper(new Intent(activity, CardIOActivity.class)); | ||
scanIntent.setWindowId(TiIntentWrapper.createActivityName("CARDIOMODULE")); | ||
|
||
// Customize these values to suit your needs. | ||
scanIntent.getIntent().putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: true | ||
scanIntent.getIntent().putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true); // default: false | ||
|
||
// Hides the manual entry button | ||
scanIntent.getIntent().putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, true); // default: false | ||
|
||
CardIOResultHandler resultHandler = new CardIOResultHandler(); | ||
|
||
resultHandler.callback = callback; | ||
resultHandler.activitySupport = activitySupport; | ||
resultHandler.scanIntent = scanIntent.getIntent(); | ||
|
||
activity.runOnUiThread(resultHandler); | ||
} | ||
|
||
protected class CardIOResultHandler implements TiActivityResultHandler, Runnable { | ||
|
||
protected int code; | ||
protected KrollFunction callback; | ||
protected TiActivitySupport activitySupport; | ||
protected Intent scanIntent; | ||
|
||
public void run() { | ||
Log.d(LCAT, "inside CardIOResultHandler run"); | ||
code = activitySupport.getUniqueResultCode(); | ||
activitySupport.launchActivityForResult(scanIntent, code, this); | ||
} | ||
|
||
public void onError(Activity activity, int requestCode, Exception e) { | ||
String msg = "Problem with scanner; " + e.getMessage(); | ||
Log.d(LCAT, "inside CardIOResultHandler onError " + msg); | ||
|
||
HashMap<String, String> callbackDict = new HashMap<String, String>(); | ||
|
||
callbackDict.put("success", "false"); | ||
|
||
callback.callAsync((KrollObject)callback, callbackDict); | ||
} | ||
|
||
public void onResult(Activity activity, int requestCode, int resultCode, Intent data) { | ||
String resultStr; | ||
HashMap<String, String> callbackDict = new HashMap<String, String>(); | ||
|
||
Log.d(LCAT, "inside onResult"); | ||
|
||
// process the results | ||
if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { | ||
Log.d(LCAT, "got result"); | ||
|
||
CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); | ||
|
||
// Never log a raw card number. Avoid displaying it, but if | ||
// necessary use getFormattedCardNumber() | ||
resultStr = "Card Number: " + scanResult.getRedactedCardNumber() + "\n"; | ||
|
||
if (scanResult.isExpiryValid()) { | ||
resultStr += "Expiration Date: " + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n"; | ||
} | ||
|
||
if (scanResult.cvv != null) { | ||
// Never log or display a CVV | ||
resultStr += "CVV has " + scanResult.cvv.length() + " digits.\n"; | ||
} | ||
|
||
// get all of the data in a hash for returning | ||
callbackDict.put("success", "true"); | ||
callbackDict.put("cvv", TiConvert.toString(scanResult.cvv)); | ||
callbackDict.put("expiryMonth", TiConvert.toString(scanResult.expiryMonth)); | ||
callbackDict.put("expiryYear", TiConvert.toString(scanResult.expiryYear)); | ||
callbackDict.put("cardNumber", scanResult.getFormattedCardNumber()); | ||
|
||
callback.callAsync((KrollObject)callback, callbackDict); | ||
} | ||
else { | ||
resultStr = "Scan was canceled."; | ||
|
||
callbackDict.put("success", "false"); | ||
callbackDict.put("cancelled", resultStr); | ||
|
||
callback.callAsync((KrollObject)callback, callbackDict); | ||
} | ||
|
||
Log.d(LCAT, "Scan results: " + resultStr); | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ti:module xmlns:ti="http://ti.appcelerator.org" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- | ||
Similar to tiapp.xml, but contains module/platform specific | ||
configuration in <iphone>, <android>, and <mobileweb> sections | ||
--> | ||
<iphone> | ||
</iphone> | ||
<android xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" > | ||
<uses-sdk android:minSdkVersion="8" /> | ||
|
||
<!-- Permission to vibrate - recommended, allows vibration feedback on scan --> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
|
||
<!-- Permission to use camera - required --> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
|
||
<!-- Camera features - recommended --> | ||
<uses-feature android:name="android.hardware.camera" android:required="false" /> | ||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> | ||
<uses-feature android:name="android.hardware.camera.flash" android:required="false" /> | ||
|
||
<application> | ||
<!-- Activities responsible for gathering payment info --> | ||
<activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" /> | ||
<activity android:name="io.card.payment.DataEntryActivity" android:screenOrientation="portrait" /> | ||
</application> | ||
</manifest> | ||
</android> | ||
<mobileweb> | ||
</mobileweb> | ||
</ti:module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var cardio = require('com.likelysoft.cardio'); | ||
|
||
var win = Ti.UI.createWindow({ | ||
backgroundColor: 'white' | ||
}); | ||
|
||
var button = Ti.UI.createButton({ | ||
title: 'Scan Card' | ||
}); | ||
|
||
button.addEventListener('click', function() { | ||
// Open modal scanner window | ||
cardio.scanCard(function(data){ | ||
if(data.success == 'true') { | ||
// NOTE this is for demonstration only, never log the | ||
// complete credit card number. Use redactedCardNumber | ||
// instead. | ||
Ti.API.info("Card number: " + data.cardNumber); | ||
Ti.API.info("Redacted card number: " + data.redactedCardNumber); | ||
Ti.API.info("Expiration month: " + data.expiryMonth); | ||
Ti.API.info("Expiration year: " + data.expiryYear); | ||
Ti.API.info("CVV code: " + data.cvv) | ||
} | ||
else { | ||
// User canceled or there was an error | ||
} | ||
}); | ||
}); | ||
|
||
win.open(); |
Oops, something went wrong.