Skip to content

Commit db36acc

Browse files
authored
Merge pull request #46 from amimishr/master
Master
2 parents 6588491 + d603a43 commit db36acc

File tree

7 files changed

+149
-25
lines changed

7 files changed

+149
-25
lines changed

README.md

Lines changed: 80 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,16 @@ public interface QuickChipTransactionSessionListener extends EMVTransactionListe
132132
void onTransactionStatusUpdate(String transactionStatus);
133133
void onPrepareQuickChipDataSuccessful();
134134
void onPrepareQuickChipDataError(EMVErrorCode error, String cause);
135+
136+
//bluetooth connection callbacks
137+
void onReturnBluetoothDevices(List<BluetoothDevice> bluetoothDeviceList);
138+
void onBluetoothDeviceConnected(BluetoothDevice bluetoothDevice);
139+
void onBluetoothDeviceDisConnected();
135140
}
136141
```
137142
We support Quick Chip with UI and Quick Chip in the background.
138143

139-
### Quick chip with SDK provided UI
144+
### Quick Chip with SDK-Provided UI
140145

141146
The `startQuickChipTransaction` call works in the same way as `startEMVTransaction`:
142147
1. Provide the `EMVTransaction`, `QuickChipTransactionSessionListener` objects with transaction details and callbacks.
@@ -178,6 +183,22 @@ public void onPrepareQuickChipDataSuccessful() {
178183
public void onPrepareQuickChipDataError(EMVErrorCode error, String cause) {
179184

180185
}
186+
187+
@Override
188+
public void onReturnBluetoothDevices(final List<BluetoothDevice> bluetoothDeviceList) {
189+
190+
}
191+
192+
@Override
193+
public void onBluetoothDeviceConnected(BluetoothDevice bluetoothDevice) {
194+
195+
}
196+
197+
@Override
198+
public void onBluetoothDeviceDisConnected() {
199+
200+
}
201+
181202
};
182203

183204
// Construct the transaction object.
@@ -214,11 +235,11 @@ emvTransaction.setEmployeeId("EMPLOYEE 1");
214235
EMVTransactionManager.startQuickChipTransaction(emvTransaction, iemvTransaction, context);
215236
```
216237

217-
### Quick Chip in the Background
238+
### Quick Chip in the Background (No UI)
218239

219-
To use Quick Chip without the UI component, being the transaction by calling `prepareDataForQuickChipTransaction`. Here are the steps:
240+
To use Quick Chip without the UI component, begin the transaction by calling `prepareDataForQuickChipTransaction`. Here are the steps:
220241

221-
1. Provide a `QuickChipTransactionSessionListener` object that listens to SDK status changes as it communicates with reader. Information and error messages will be shown through `QuickChipTransactionSessionListener` callbacks.
242+
1. Provide a `QuickChipTransactionSessionListener` object that listens to SDK status changes as it communicates with the reader. Information and error messages will be shown through `QuickChipTransactionSessionListener` callbacks.
222243
2. After a `onPrepareQuickChipDataSuccessful` callback, card data will be temporarily stored inside the SDK. To finish the transaction, just initiate `startQuickChipTransaction` with the transaction details and finish the transaction.
223244
3. You can check if there is any stored card data using `hasStoredQuickChipData`, or choose to discard that data using `clearStoredQuickChipData`.
224245

@@ -274,9 +295,9 @@ EMVTransactionManager.clearStoredQuickChipData();
274295
EMVTransactionManager.startQuickChipTransaction(emvTransaction, iemvTransaction, context);
275296
```
276297

277-
**NOTE:** To use Quick Chip functionality, the card reader has to be on updated firmware version and config. Refer to the OTA Update section for more details.
298+
**NOTE:** To use Quick Chip functionality, the card reader must have the latest firmware version and configuration. Refer to the OTA Update section for more details.
278299

279-
### Bluetooth support
300+
### Bluetooth Support
280301
The In-Person SDK for Android now supports a Bluetooth connection mode with AnywhereCommerce Walker C2X BT readers. To enable the Bluetooth connection, follow these steps from class `EMVTransactionManager`:
281302

282303
1. Set the connection mode to Bluetooth.
@@ -316,7 +337,7 @@ EMVTransactionManager.startEMVTransaction(EMVTransaction emvTransaction, final E
316337
EMVTransactionManager.clearSavedBTDevice(Context context);
317338
```
318339

319-
### Swipe only mode
340+
### Swipe-Only Mode
320341
When you use a AnywhereCommerce Walker C2X device, EMV/Quick Chip is turned on by default. However, you can choose to use the Magnetic Stripe Reader by calling this before the transaction:
321342
```java
322343
public enum TerminalMode{
@@ -373,16 +394,16 @@ You can configure the UI of the In-Person SDK to better match the UI of the merc
373394

374395
The merchant app can configure the following UI parameters:
375396

376-
**SDK Font color:**
397+
**SDK font color:**
377398
`EmvSdkUISettings.setFontColorId(R.color.black);`
378399

379-
**SDK Button font color:**
400+
**SDK button font color:**
380401
`EmvSdkUISettings.setButtonTextColor(R.color.font_green);`
381402

382403
**SDK background color:**
383404
`EmvSdkUISettings.setBackgroundColorId(R.color.light_blue);`
384405

385-
**Banner/Top bar background color:**
406+
**Banner/top bar background color:**
386407
`EmvSdkUISettings.setBannerBackgroundColor(R.color.white);`
387408

388409
For the color properties listed above, the merchant application must define color values and pass the color IDs to the In-Person SDK:
@@ -397,6 +418,20 @@ The merchant application must have a drawable file in the resource file. The dra
397418

398419
The merchant application must define a drawable. SDK supports state list drawables also. The merchant application must provide the drawable ID to the EMV SDK.
399420

421+
You can also customize the signature screen with following APIs:
422+
423+
**Signature screen background color:**
424+
`EmvSdkUISettings.setSignViewBackgroundResId(R.color.white);`
425+
426+
**Signature screen background drawable:**
427+
`EmvSdkUISettings.setSignViewBackgroundResId(R.drawable.apple);`
428+
429+
**Signature view Border color:**
430+
`EmvSdkUISettings.setSignViewBorderColor(R.color.light_blue)`
431+
432+
**Signature view background color:**
433+
`EmvSdkUISettings.setSignCaptureBgResId(R.color.white)`
434+
400435
## Non-EMV Transaction Processing
401436

402437
The SDK supports the following transaction types that can be posted to Authorize.Net gateway:
@@ -419,7 +454,7 @@ CASH;
419454

420455
### Non-EMV Code Samples
421456

422-
The following code samples use keyed in credit card information. To use another transaction type, simply replace `TransactionType.AUTH_CAPTURE` with the type of transaction you want (shown in the list above). For example, TransactionType.AUTH_ONLY or TransactionType.CREDIT.
457+
The following code samples use keyed-in credit card information. To use another transaction type, simply replace `TransactionType.AUTH_CAPTURE` with the type of transaction you want (shown in the list above). For example, `TransactionType.AUTH_ONLY` or `TransactionType.CREDIT`.
423458

424459
```java
425460
//login to gateway to get valid session token
@@ -458,7 +493,7 @@ order.setTotalAmount(new BigDecimal(1.1));
458493
net.authorize.aim.Result authCaptureResult = (net.authorize.aim.Result) testMerchant.postTransaction(authCaptureTransaction);
459494
```
460495

461-
### Code Sample for Non-EMV transactions Using Encrypted Swiper Data
496+
### Code Sample for Non-EMV Transactions Using Encrypted Swiper Data
462497

463498
```java
464499
//login to gateway to get valid session token
@@ -611,3 +646,36 @@ Field Order | Response Code | Response Reason Code | Text
611646
3 | 2 | 360 | An error occurred during the decryption of the EMV data.
612647
3 | 2 | 361 | The EMV version is invalid.
613648
3 | 2 | 362 | x_emv_version is required.
649+
650+
## Auto Configuration of Audio Readers
651+
652+
Android hardware varies between different manufacturers, and there is a possibility that default audio configuration does not work in all Android devices.
653+
For audio jack readers, if we check reader information by `getDeviceInfo()` API, and the error returned is `OTAUpdateManager.HeadlessOTAUpdateError.COMM_ERROR`, this implies that default
654+
configuration are not working for the attached reader and auto configuration is required to setup it up.
655+
656+
The following API from `OTAUpdateManager` can be used to start auto configuration:
657+
658+
public static void startAutoConfig(Context context, boolean demoMode, HeadlessOTAUpdateListener listener)
659+
660+
661+
The following interface methods have been added to `HeadlessOTAUpdateListener` to monitor and update configuration process:
662+
663+
1- `void onAudioAutoConfigProgressUpdate(double var1)`;
664+
Return the auto configuration progress in percentage.
665+
666+
2- `void onAudioAutoConfigCompleted(boolean isDefaultSettings, String autoConfigSettings)`;
667+
The auto configuration completed. If it is not default settings, the auto configuration settings are returned.
668+
669+
3- `void onAudioAutoConfigError(AudioAutoConfigError error)`;
670+
The auto config resulted in some error.
671+
672+
673+
Apart from the three additions to `HeadlessOTAUpdateListener` for auto configuration, shown above, another interface method is added to notify when bluetooth device gets disconnected.
674+
675+
4- `void onBluetoothDeviceDisConnected()`;
676+
Bluetooth device got disconnected.
677+
678+
679+
At anytime if it is required to cancel the auto configuration, use following API from `OTAUpdateManager` -
680+
681+
`public static void cancelAutoConfig(Context context, boolean demoMode, HeadlessOTAUpdateListener listener)`

emv-anet-sdk.aar

1.78 MB
Binary file not shown.

sampleapp/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<category android:name="android.intent.category.LAUNCHER" />
2929
</intent-filter>
3030
</activity>
31+
32+
<activity
33+
android:name=".LastTransactionActivity"
34+
android:label="@string/last_transaction"/>
35+
3136
</application>
3237

3338
</manifest>

sampleapp/app/src/main/java/authorize/net/inperson_sdk_android/MainActivity.java

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.os.Handler;
1717
import android.os.Message;
1818
import android.support.v4.app.ActivityCompat;
19+
import android.support.v4.content.ContextCompat;
1920
import android.support.v7.app.ActionBarActivity;
2021
import android.util.Log;
2122
import android.view.Menu;
@@ -29,6 +30,8 @@
2930
import android.widget.Toast;
3031
import android.widget.ToggleButton;
3132

33+
import com.bbpos.bbdevice.BBDeviceController;
34+
3235
import net.authorize.ResponseReasonCode;
3336
import net.authorize.aim.emv.EMVDeviceConnectionType;
3437
import net.authorize.aim.emv.EMVErrorCode;
@@ -75,6 +78,7 @@ public class MainActivity extends ActionBarActivity {
7578
Button startBTScanButton;
7679
Button connectBTButton;
7780
private Dialog dialog;
81+
AlertDialog alertDialog = null;
7882

7983
Handler myHandler = new Handler(){
8084

@@ -148,7 +152,12 @@ protected void onCreate(Bundle savedInstanceState) {
148152
void setUIPreferences() {
149153
// EmvSdkUISettings.setBackgroundDrawableId(R.drawable.emvbackground);
150154
EmvSdkUISettings.setToastColor(Color.GREEN);
155+
EmvSdkUISettings.setSignViewBorderColor(R.color.primary_dark,(int)getResources().getDimension(R.dimen.signature_view_border_thickness));
151156

157+
EmvSdkUISettings.setBackgroundDrawableId(R.drawable.emvbackground);
158+
EmvSdkUISettings.setSignViewBackgroundResId(R.color.white);
159+
EmvSdkUISettings.setSignCaptureBgResId(R.color.white);
160+
EmvSdkUISettings.setSignViewBorderColor(ContextCompat.getColor(this, R.color.red), (int)getResources().getDimension(R.dimen.signature_view_border_thickness));
152161
}
153162

154163
@Override
@@ -212,33 +221,40 @@ private void checkRuntimePermissions() {
212221
EMVTransactionManager.QuickChipTransactionSessionListener iemvTransaction = new EMVTransactionManager.QuickChipTransactionSessionListener() {
213222
@Override
214223
public void onReturnBluetoothDevices(final List<BluetoothDevice> bluetoothDeviceList) {
215-
// setup the alert builder
224+
if (null != alertDialog) {
225+
alertDialog.dismiss();
226+
alertDialog = null;
227+
}
228+
216229
AlertDialog.Builder builder = new AlertDialog.Builder(context);
217230
builder.setTitle("Bluetooth Devices");
218231

219232
String[] titles = new String[bluetoothDeviceList.size()];
220-
for (int i=0;i<bluetoothDeviceList.size();i++) {
233+
for (int i = 0; i < bluetoothDeviceList.size(); i++) {
221234
titles[i] = bluetoothDeviceList.get(i).getName();
222235
}
223236
builder.setItems(titles, new DialogInterface.OnClickListener() {
224237
@Override
225238
public void onClick(DialogInterface dialog, int which) {
226-
EMVTransactionManager.connectBTDevice(MainActivity.this, bluetoothDeviceList.get(0), iemvTransaction);
239+
EMVTransactionManager.connectBTDevice(MainActivity.this, bluetoothDeviceList.get(which), iemvTransaction);
227240
}
228241
});
229242

230243
// create and show the alert dialog
231-
AlertDialog dialog = builder.create();
232-
dialog.show();
233-
234-
244+
alertDialog = builder.create();
245+
alertDialog.show();
235246
}
236247

237248
@Override
238249
public void onBluetoothDeviceConnected(BluetoothDevice bluetoothDevice) {
239250
Log.d("Bluetooth device", "bluetooth device connected : " + bluetoothDevice.getName());
240251
}
241252

253+
@Override
254+
public void onBluetoothDeviceDisConnected() {
255+
Log.d("Bluetooth device", "bluetooth device disconnected");
256+
}
257+
242258
@Override
243259
public void onTransactionStatusUpdate(String transactionStatus) {
244260
statusTextView.setTextColor(Color.GREEN);
@@ -571,6 +587,26 @@ public void onReturnBluetoothDevices(List<BluetoothDevice> list) {
571587
public void onBluetoothDeviceConnected(BluetoothDevice bluetoothDevice) {
572588

573589
}
590+
591+
@Override
592+
public void onBluetoothDeviceDisConnected() {
593+
594+
}
595+
596+
@Override
597+
public void onAudioAutoConfigProgressUpdate(double v) {
598+
599+
}
600+
601+
@Override
602+
public void onAudioAutoConfigCompleted(boolean b, String s) {
603+
604+
}
605+
606+
@Override
607+
public void onAudioAutoConfigError(BBDeviceController.AudioAutoConfigError audioAutoConfigError) {
608+
609+
}
574610
};
575611

576612

@@ -619,12 +655,25 @@ public void onClick(View view) {
619655
EMVDeviceConnectionType.BLUETOOTH : EMVDeviceConnectionType.AUDIO;
620656
EMVTransactionManager.setDeviceConnectionType(deviceConnectionType);
621657

622-
if (view == emvButton) {
623-
EMVTransactionManager.startEMVTransaction(emvTransaction, iemvTransaction, context);
624-
} else if (view == quickChipButton) {
625-
EMVTransactionManager.startQuickChipTransaction(emvTransaction, iemvTransaction, context);
626-
} else if (view == prepareDataButton) {
627-
EMVTransactionManager.prepareDataForQuickChipTransaction(context, iemvTransaction);
658+
if (view == emvButton || view == quickChipButton || view == prepareDataButton) {
659+
double amountVal = 0;
660+
try {
661+
amountVal = Double.parseDouble(amount.getText().toString());
662+
}catch (Exception e){
663+
amountVal = 0;
664+
e.printStackTrace();
665+
}
666+
if (amountVal > 0) {
667+
if (view == emvButton) {
668+
EMVTransactionManager.startEMVTransaction(emvTransaction, iemvTransaction, context);
669+
} else if (view == quickChipButton) {
670+
EMVTransactionManager.startQuickChipTransaction(emvTransaction, iemvTransaction, context);
671+
} else {
672+
EMVTransactionManager.prepareDataForQuickChipTransaction(context, iemvTransaction);
673+
}
674+
} else {
675+
Toast.makeText(getApplicationContext(), "Please enter valid amount", Toast.LENGTH_LONG).show();
676+
}
628677
} else if (view == clearDataButton) {
629678
EMVTransactionManager.clearStoredQuickChipData(iemvTransaction);
630679
} else if (view == clearSavedBTDeviceButton) {

sampleapp/app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<!-- Default screen margins, per the Android Design guidelines. -->
33
<dimen name="activity_horizontal_margin">16dp</dimen>
44
<dimen name="activity_vertical_margin">16dp</dimen>
5+
<dimen name="signature_view_border_thickness">2dp</dimen>
56
</resources>

sampleapp/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
<item>$9</item>
2222
<item>$10</item>
2323
</string-array>
24+
<string name="last_transaction">Last Transaction</string>
2425
</resources>
1.78 MB
Binary file not shown.

0 commit comments

Comments
 (0)