{"_id":"564e038b8980c32b009e8bcf","project":"55b933b3146ef121002158d3","user":"55b932ba8fd1a02b00f496c8","category":{"_id":"564e13053b2b4a19000cd69b","__v":0,"project":"55b933b3146ef121002158d3","version":"5632a5e549e16d0d00122443","pages":[],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-19T18:20:53.223Z","from_sync":false,"order":14,"slug":"android","title":"Android"},"githubsync":"","version":{"_id":"5632a5e549e16d0d00122443","__v":6,"project":"55b933b3146ef121002158d3","createdAt":"2015-10-29T23:04:05.701Z","releaseDate":"2015-10-29T23:04:05.701Z","categories":["5632a5e749e16d0d00122444","5632a5e749e16d0d00122445","5632a5e749e16d0d00122446","5632a5e749e16d0d00122447","5632a5e749e16d0d00122448","5632a5e749e16d0d00122449","5632a5e749e16d0d0012244a","5632a5e749e16d0d0012244b","5632a5e749e16d0d0012244c","5632a5e749e16d0d0012244d","5632a5e749e16d0d0012244e","5632a5e749e16d0d0012244f","5632a5e749e16d0d00122450","5632b179df556c0d00cd095b","564e13053b2b4a19000cd69b","59caa9df65accc001a489c95","59cab50965accc001a489d28","59cadd464ab7b70024378e74"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1"},"__v":22,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-19T17:14:51.058Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"eBizCharge Android SDK and Payment Library Overview\"\n}\n[/block]\nThe eBizCharge Android SDK and payment library bundle offers developers two different options of implementing our payment gateway within their Android apps. The SDK provides complete access to the gateway, giving developers the tools to manage a wide range of features, including transactions, products, and customers. The payment library provides a prebuilt activity that developers can use to obtain payment information from the end-user. \n\nThe SDK and payment library both require Android 2.3.3+ (API 10+). \n\nDownload the bundle [ebizcharge-payment.zip](http://software.ebizcharge.net/cbs/assets/downloads/ebizcharge-payment.zip). It contains the SDK, the payment library, and a demo app for the payment library. \n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"eBizCharge SDK\"\n}\n[/block]\nThe documentation for this SDK can be found inside the bundle. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Payment Library\"\n}\n[/block]\nThe payment library uses the SDK to communicate with the gateway. The payment method is determined by the getCommand() method from the instance of TransactionRequest that is passed to this library's activity. See [below ](#example-code)for an example. \n\nThis library currently can only process credit card sales (Command.CC_SALE) and authorizations (Command.CC_AUTH). More payment methods will be added in the future. \n\nNote: This library uses the Android v7 appcompat support library. Please see Google's [Support Library Setup](https://developer.android.com/tools/support-library/setup.html) guide for more information on how to add the v7 support library. \n\n**Getting Started** \n\n1. Read Google's [Managing Projects](https://developer.android.com/tools/projects/projects-eclipse.html) guide to learn how to add this library into your new/existing projects.\n\n\n2. Once you have added this library to your project, go to the PaymentLibraryConstants class:\n\n  *  Set SANDBOX_MODE to true to use the sandbox environment for testing and development by using PaymentLibraryConstants.setSandboxMode(true). Set SANDBOX_MODE to false when your app is ready to go live.\n  *  Obtain the source key and pin from our website for these constants: SOURCE_KEY, SOURCE_PIN\n  *  Use PaymentLibraryConstants.setSourceKey(“sourcekey”) and PaymentLibraryConstants.setSourcePin(“sourcePin”) and their respective getters to set/get the source key and pin. \n\n\n\n3. Note, the source key and pin for the sandbox environment will differ from those for the production environment. Do not forget to update the source key and pin before your app goes live.\n4. If using Eclipse IDE, either go to your project's project.properties file and add the following line to the end: \n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"manifestmerger.enabled=true\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nor declare this library's activity in your app's manifest: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<activity\\n    android:name=\\\"com.ebizcharge.library.payment.PaymentLibraryActivity\\\"\\n    android:label=\\\":::at:::string/app_name\\\" />\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n5. This library requires permission to access the internet. Declare the following in your app's manifest if you did not choose the manifestmerger option in the previous step:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<uses-permission android:name=\\\"android.permission.INTERNET\\\" />\",\n      \"language\": \"java\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n6. Now you can launch this library from any of your activities.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example Code\"\n}\n[/block]\nHere is a code snippet for creating a new transaction request and calling this library to process the transaction as a credit card sale. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"CurrencyAmount subtotal = new CurrencyAmount(\\\"10.00\\\");\\nCurrencyAmount tax = new CurrencyAmount(0, 2);\\nString invoice = \\\"123456\\\";\\n \\nTransactionRequest request = new TransactionRequest();\\nrequest.setCommand(Command.CC_SALE); // credit card sale\\nrequest.setTotal(subtotal.add(tax));\\nrequest.setTax(tax);\\nrequest.setInvoice(invoice);\\n \\nIntent i = new Intent(this, PaymentLibraryActivity.class);\\ni.putExtra(PaymentLibraryConstants.TRANSACTION_REQUEST, request);\\nstartActivityForResult(i, REQUEST_PAYMENT_LIBRARY);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nThe results of the transaction processing will be returned in your activity's onActivityResult method. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@Override\\npublic void onActivityResult(int requestCode, int resultCode, Intent data) {\\n    if (resultCode == RESULT_OK && requestCode == REQUEST_PAYMENT_LIBRARY) {\\n        TransactionResponse response = data\\n                .getParcelableExtra(PaymentLibraryConstants.TRANSACTION_RESPONSE);\\n \\n        if (response == null) { // something wrong happened when communicating with the gateway\\n            GatewayException exception = data\\n                    .getParcelableExtra(PaymentLibraryConstants.GATEWAY_EXCEPTION);\\n            exception.printStackTrace();\\n        } else {\\n            String msg = \\\"Transaction #: \\\" + response.getRefNum() + \\\", Result: \\\"\\n                    + response.getResult() +\\\", Error: \\\" + response.getError();\\n            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n**Library Reference** \n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Class\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Link\",\n    \"0-0\": \"TransactionRequest\",\n    \"0-1\": \"Transaction details to submit\",\n    \"0-2\": \"See SDK reference for more information\",\n    \"1-0\": \"TransactionResponse\",\n    \"1-1\": \"Response from gateway\",\n    \"1-2\": \"See SDK reference for more information\",\n    \"2-0\": \"CurrencyAmount\",\n    \"2-1\": \"A class to handle money\",\n    \"2-2\": \"See SDK reference for more information\",\n    \"3-0\": \"GatewayException\",\n    \"3-1\": \"Exception if transaction couldn't be sent to gateway\",\n    \"3-2\": \"See SDK reference for more information\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n**Changelog** \n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Version\",\n    \"h-1\": \"Change\",\n    \"0-0\": \"1.1\",\n    \"1-0\": \"1.0\",\n    \"1-1\": \"Initial release\",\n    \"0-1\": \"Support for cash, check, and ACH payment methods\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]","excerpt":"","slug":"android-library","type":"basic","title":"Android Library"}
[block:api-header] { "type": "basic", "title": "eBizCharge Android SDK and Payment Library Overview" } [/block] The eBizCharge Android SDK and payment library bundle offers developers two different options of implementing our payment gateway within their Android apps. The SDK provides complete access to the gateway, giving developers the tools to manage a wide range of features, including transactions, products, and customers. The payment library provides a prebuilt activity that developers can use to obtain payment information from the end-user. The SDK and payment library both require Android 2.3.3+ (API 10+). Download the bundle [ebizcharge-payment.zip](http://software.ebizcharge.net/cbs/assets/downloads/ebizcharge-payment.zip). It contains the SDK, the payment library, and a demo app for the payment library. [block:api-header] { "type": "basic", "title": "eBizCharge SDK" } [/block] The documentation for this SDK can be found inside the bundle. [block:api-header] { "type": "basic", "title": "Payment Library" } [/block] The payment library uses the SDK to communicate with the gateway. The payment method is determined by the getCommand() method from the instance of TransactionRequest that is passed to this library's activity. See [below ](#example-code)for an example. This library currently can only process credit card sales (Command.CC_SALE) and authorizations (Command.CC_AUTH). More payment methods will be added in the future. Note: This library uses the Android v7 appcompat support library. Please see Google's [Support Library Setup](https://developer.android.com/tools/support-library/setup.html) guide for more information on how to add the v7 support library. **Getting Started** 1. Read Google's [Managing Projects](https://developer.android.com/tools/projects/projects-eclipse.html) guide to learn how to add this library into your new/existing projects. 2. Once you have added this library to your project, go to the PaymentLibraryConstants class: * Set SANDBOX_MODE to true to use the sandbox environment for testing and development by using PaymentLibraryConstants.setSandboxMode(true). Set SANDBOX_MODE to false when your app is ready to go live. * Obtain the source key and pin from our website for these constants: SOURCE_KEY, SOURCE_PIN * Use PaymentLibraryConstants.setSourceKey(“sourcekey”) and PaymentLibraryConstants.setSourcePin(“sourcePin”) and their respective getters to set/get the source key and pin. 3. Note, the source key and pin for the sandbox environment will differ from those for the production environment. Do not forget to update the source key and pin before your app goes live. 4. If using Eclipse IDE, either go to your project's project.properties file and add the following line to the end: [block:code] { "codes": [ { "code": "manifestmerger.enabled=true", "language": "java" } ] } [/block] or declare this library's activity in your app's manifest: [block:code] { "codes": [ { "code": "<activity\n android:name=\"com.ebizcharge.library.payment.PaymentLibraryActivity\"\n android:label=\"@string/app_name\" />", "language": "java" } ] } [/block] 5. This library requires permission to access the internet. Declare the following in your app's manifest if you did not choose the manifestmerger option in the previous step: [block:code] { "codes": [ { "code": "<uses-permission android:name=\"android.permission.INTERNET\" />", "language": "java", "name": null } ] } [/block] 6. Now you can launch this library from any of your activities. [block:api-header] { "type": "basic", "title": "Example Code" } [/block] Here is a code snippet for creating a new transaction request and calling this library to process the transaction as a credit card sale. [block:code] { "codes": [ { "code": "CurrencyAmount subtotal = new CurrencyAmount(\"10.00\");\nCurrencyAmount tax = new CurrencyAmount(0, 2);\nString invoice = \"123456\";\n \nTransactionRequest request = new TransactionRequest();\nrequest.setCommand(Command.CC_SALE); // credit card sale\nrequest.setTotal(subtotal.add(tax));\nrequest.setTax(tax);\nrequest.setInvoice(invoice);\n \nIntent i = new Intent(this, PaymentLibraryActivity.class);\ni.putExtra(PaymentLibraryConstants.TRANSACTION_REQUEST, request);\nstartActivityForResult(i, REQUEST_PAYMENT_LIBRARY);", "language": "java" } ] } [/block] The results of the transaction processing will be returned in your activity's onActivityResult method. [block:code] { "codes": [ { "code": "@Override\npublic void onActivityResult(int requestCode, int resultCode, Intent data) {\n if (resultCode == RESULT_OK && requestCode == REQUEST_PAYMENT_LIBRARY) {\n TransactionResponse response = data\n .getParcelableExtra(PaymentLibraryConstants.TRANSACTION_RESPONSE);\n \n if (response == null) { // something wrong happened when communicating with the gateway\n GatewayException exception = data\n .getParcelableExtra(PaymentLibraryConstants.GATEWAY_EXCEPTION);\n exception.printStackTrace();\n } else {\n String msg = \"Transaction #: \" + response.getRefNum() + \", Result: \"\n + response.getResult() +\", Error: \" + response.getError();\n Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();", "language": "java" } ] } [/block] **Library Reference** [block:parameters] { "data": { "h-0": "Class", "h-1": "Description", "h-2": "Link", "0-0": "TransactionRequest", "0-1": "Transaction details to submit", "0-2": "See SDK reference for more information", "1-0": "TransactionResponse", "1-1": "Response from gateway", "1-2": "See SDK reference for more information", "2-0": "CurrencyAmount", "2-1": "A class to handle money", "2-2": "See SDK reference for more information", "3-0": "GatewayException", "3-1": "Exception if transaction couldn't be sent to gateway", "3-2": "See SDK reference for more information" }, "cols": 3, "rows": 4 } [/block] **Changelog** [block:parameters] { "data": { "h-0": "Version", "h-1": "Change", "0-0": "1.1", "1-0": "1.0", "1-1": "Initial release", "0-1": "Support for cash, check, and ACH payment methods" }, "cols": 2, "rows": 2 } [/block]