{"_id":"56cd772dd98d851d00c0c447","parentDoc":null,"project":"56cacb1bc675f50b00a4b619","__v":22,"category":{"_id":"56cc10b7b4cbcf0b004a5df9","project":"56cacb1bc675f50b00a4b619","__v":5,"pages":["56cd503649abf10b0036a1f0","56cd585aa2a95b0b00c6ec0b","56cd591224f28913009575c4","56cd772dd98d851d00c0c447","56d5267b1c4de4130005d804"],"version":"56cacb1cc675f50b00a4b61c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-23T07:56:39.448Z","from_sync":false,"order":2,"slug":"sdk","title":"PHP SDK"},"user":"56caca84245b841300806def","version":{"_id":"56cacb1cc675f50b00a4b61c","project":"56cacb1bc675f50b00a4b619","__v":14,"createdAt":"2016-02-22T08:47:24.528Z","releaseDate":"2016-02-22T08:47:24.528Z","categories":["56cacb1dc675f50b00a4b61d","56cc10aaca43550b0028125a","56cc10b7b4cbcf0b004a5df9","56cc1bb2272aa4130002ccd2","56cc5834b4cbcf0b004a5f8b","56cda18bface161300dae13b","56d51f2873dcd20b00fb87bb","56fbe0610023171700b96105","57658310c176520e00ea9076","5772bdd48c48e00e00503638","577c1dfe87acf617003c3fcd","579525172979790e00771a15","582b4661cdfdc125000c8684","586365cedfe6cc3700a7be63"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-24T09:26:05.357Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"Loyalty service is a logical wrapper for Wallet service. This provides multiple set of logical rules for crediting or debiting credits from a users wallet. The configuration of this can be made in the CodeMojo dashboard\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"( AuthenticationService authenticationService, WalletService walletService )\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n  use CodeMojo\\\\Client\\\\Endpoints;\\n  use CodeMojo\\\\Client\\\\Exceptions\\\\Exceptions;\\n  use CodeMojo\\\\Client\\\\Services\\\\AuthenticationService;\\n\\tuse CodeMojo\\\\Client\\\\Services\\\\LoyaltyService;\\n\\n  const CLIENT_ID     = 'YOUR_CLIENT_ID';\\n  const CLIENT_SECRET = 'YOUR_CLIENT_SECRET';\\n\\n  $authService = new AuthenticationService(CLIENT_ID, CLIENT_SECRET, Endpoints::ENV_SANDBOX, function($type){\\n      // Handle the exceptions appropriately\\n  });\\n\\n$loyaltyService = new LoyaltyService($authService);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Parameters\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"authenticationService\",\n    \"0-1\": \"AuthenticationService\",\n    \"0-2\": \"An instance of authentication service. This also determines which server to connect to\",\n    \"1-0\": \"walletService\",\n    \"1-1\": \"WalletService\",\n    \"1-2\": \"An instance of wallet service.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"calculateLoyaltyPoints\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id, float transaction_value, String platform, String service)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Float **Throws** Exception, InvalidArgumentException\n\nCalculate how many points will be awarded for the transaction\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID to which the balance has to be added\",\n    \"1-0\": \"transaction_value\",\n    \"1-1\": \"Float\",\n    \"1-2\": \"The transaction value for which loyalty points have to be calculated and added to the user's wallet\",\n    \"2-0\": \"platform\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% cashback for users from Desktop but 10% cashback for Android & 12% cashback for iOS app users\",\n    \"3-0\": \"service\",\n    \"3-1\": \"String\",\n    \"3-2\": \"Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"addLoyaltyPoints\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id, float transaction_value, String platform, String service, int expires_in_days, String transaction_id, String meta, Boolean frozen)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Boolean **Throws** Exception, InvalidArgumentException\n\nAdd balance to a particular user's wallet\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Loyalty Tier Upgrade\",\n  \"body\": \"You will receive a **tier_upgrade** parameter when the user has been moved to a new loyalty tier\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID to which the balance has to be added\",\n    \"1-0\": \"transaction_value\",\n    \"1-1\": \"Float\",\n    \"1-2\": \"The transaction value for which loyalty points have to be calculated and added to the user's wallet\",\n    \"2-0\": \"platform\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% cashback for users from Desktop but 10% cashback for Android & 12% cashback for iOS app users\",\n    \"4-0\": \"expires_in_days\",\n    \"4-1\": \"Integer\",\n    \"4-2\": \"How many days is the new credit valid\",\n    \"5-0\": \"transaction_id\",\n    \"5-1\": \"String\",\n    \"5-2\": \"Any transaction id for your internal reference. This could be a order id or so\",\n    \"6-0\": \"meta\",\n    \"6-1\": \"String\",\n    \"6-2\": \"Any meta data to associate with the transaction\",\n    \"8-0\": \"frozen\",\n    \"8-1\": \"Boolean\",\n    \"8-2\": \"Whether the credit should be immediately reflected or should it be kept on hold till some future point. This is usually associated with the transaction_id. For example, you may want to provide cashback for a particular order but want to wait till it has been delivered. You can use the order id as the transaction id in this case and unfreeze the transaction once the delivery has been confirmed\",\n    \"3-0\": \"service\",\n    \"3-1\": \"String\",\n    \"3-2\": \"Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`\",\n    \"7-0\": \"tag\",\n    \"7-1\": \"String\",\n    \"7-2\": \"Tags to be associated with the transaction\"\n  },\n  \"cols\": 3,\n  \"rows\": 9\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"redeem\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id, float redemption_value, float transaction_value, int redeem_from = -1, String platform, String service, String transaction_id, String meta, String tag)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Boolean **Throws** BalanceExhaustedException, Exception, InvalidArgumentException\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"This method throws a BalanceExhaustedException. Please be sure to handle the error appropriately\",\n  \"title\": \"Error handling required\"\n}\n[/block]\nRedeem points from users wallet based on set rules\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID to which the balance has to be added\",\n    \"1-0\": \"redemption_value\",\n    \"1-1\": \"Float\",\n    \"1-2\": \"The maximum value to be redeemed. This may or may not be the actual value redeemed. Loyalty service will internally calculate the maximum redeemable value based on the set rules & will be compared with the requested redemption value, the least of which will be redeemed\",\n    \"2-0\": \"transaction_value\",\n    \"2-1\": \"Float\",\n    \"2-2\": \"The transaction value for which redemption is being mades & points to be calculated to be debited from the user's wallet\",\n    \"4-0\": \"platform\",\n    \"4-1\": \"String\",\n    \"4-2\": \"Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% redemption for users from Desktop but 10% redemption for Android & 12% redemption for iOS app users\",\n    \"5-0\": \"service\",\n    \"5-1\": \"String\",\n    \"7-1\": \"String\",\n    \"7-2\": \"Any meta data to associate with this transaction\",\n    \"7-0\": \"meta\",\n    \"5-2\": \"Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`\",\n    \"3-0\": \"redeem_from\",\n    \"3-1\": \"int\",\n    \"3-2\": \"Which transaction type balance to be redeemed from. Default is `-1` which is from both transactional & promotional\",\n    \"8-0\": \"tag\",\n    \"8-1\": \"String\",\n    \"8-2\": \"Tags to be associated with the transaction\",\n    \"6-0\": \"transaction_id\",\n    \"6-1\": \"String\",\n    \"6-2\": \"Transaction ID\"\n  },\n  \"cols\": 3,\n  \"rows\": 9\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"cancelTransaction\"\n}\n[/block]\nCancel / undo the transaction\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String transaction_id)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"transaction_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Transaction ID of the transaction to be cancelled\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"refund\"\n}\n[/block]\nRefund the complete or the remaining balance of the transaction\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String transaction_id)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"transaction_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Transaction ID of the transaction to be refunded\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"refundPartial\"\n}\n[/block]\nRefund a partial amount of the transaction\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String transaction_id, float sku_value)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"SKU Value\",\n  \"body\": \"This is different from the refund value. You should pass the SKU value of the refunded value/service, the refund to be given will be automatically calculated by the service\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"transaction_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Transaction ID of the transaction to be refunded\",\n    \"1-0\": \"sku_value\",\n    \"1-1\": \"float\",\n    \"1-2\": \"SKU value of the cancelled/returned service for which a refund needs to be made\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"maximumRedemption\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id, float transaction_value, String platform, String service)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Boolean **Throws** Exception, InvalidArgumentException\n\nTells you how much (maximum) value of the user's wallet can be redeemed against the given transaction value. Please note, this does not redeem from the wallet, rather think of this as a sneak peak function\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID to which the balance has to be added\",\n    \"1-0\": \"transaction_value\",\n    \"1-1\": \"Float\",\n    \"1-2\": \"The transaction value for which maximum redemption possible has to be calculated\",\n    \"2-0\": \"platform\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% redemption for users from Desktop but 10% redemption for Android & 12% redemption for iOS app users\",\n    \"3-0\": \"service\",\n    \"3-1\": \"String\",\n    \"3-2\": \"Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"getBalance\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Float **Throws** Exception, InvalidArgumentException\n\nGet the balance credits available from a user's wallet\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID to which the balance has to be calculated\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]","excerpt":"","slug":"loyalty-service","type":"basic","title":"Loyalty Service"}

Loyalty Service


Loyalty service is a logical wrapper for Wallet service. This provides multiple set of logical rules for crediting or debiting credits from a users wallet. The configuration of this can be made in the CodeMojo dashboard [block:code] { "codes": [ { "code": "( AuthenticationService authenticationService, WalletService walletService )", "language": "java", "name": "Signature" } ] } [/block] [block:code] { "codes": [ { "code": "<?php\n\n use CodeMojo\\Client\\Endpoints;\n use CodeMojo\\Client\\Exceptions\\Exceptions;\n use CodeMojo\\Client\\Services\\AuthenticationService;\n\tuse CodeMojo\\Client\\Services\\LoyaltyService;\n\n const CLIENT_ID = 'YOUR_CLIENT_ID';\n const CLIENT_SECRET = 'YOUR_CLIENT_SECRET';\n\n $authService = new AuthenticationService(CLIENT_ID, CLIENT_SECRET, Endpoints::ENV_SANDBOX, function($type){\n // Handle the exceptions appropriately\n });\n\n$loyaltyService = new LoyaltyService($authService);", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Parameters" } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "authenticationService", "0-1": "AuthenticationService", "0-2": "An instance of authentication service. This also determines which server to connect to", "1-0": "walletService", "1-1": "WalletService", "1-2": "An instance of wallet service." }, "cols": 3, "rows": 2 } [/block] [block:api-header] { "type": "fn", "title": "calculateLoyaltyPoints" } [/block] [block:code] { "codes": [ { "code": "(String user_id, float transaction_value, String platform, String service)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Float **Throws** Exception, InvalidArgumentException Calculate how many points will be awarded for the transaction [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID to which the balance has to be added", "1-0": "transaction_value", "1-1": "Float", "1-2": "The transaction value for which loyalty points have to be calculated and added to the user's wallet", "2-0": "platform", "2-1": "String", "2-2": "Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% cashback for users from Desktop but 10% cashback for Android & 12% cashback for iOS app users", "3-0": "service", "3-1": "String", "3-2": "Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`" }, "cols": 3, "rows": 4 } [/block] [block:api-header] { "type": "fn", "title": "addLoyaltyPoints" } [/block] [block:code] { "codes": [ { "code": "(String user_id, float transaction_value, String platform, String service, int expires_in_days, String transaction_id, String meta, Boolean frozen)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Boolean **Throws** Exception, InvalidArgumentException Add balance to a particular user's wallet [block:callout] { "type": "info", "title": "Loyalty Tier Upgrade", "body": "You will receive a **tier_upgrade** parameter when the user has been moved to a new loyalty tier" } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID to which the balance has to be added", "1-0": "transaction_value", "1-1": "Float", "1-2": "The transaction value for which loyalty points have to be calculated and added to the user's wallet", "2-0": "platform", "2-1": "String", "2-2": "Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% cashback for users from Desktop but 10% cashback for Android & 12% cashback for iOS app users", "4-0": "expires_in_days", "4-1": "Integer", "4-2": "How many days is the new credit valid", "5-0": "transaction_id", "5-1": "String", "5-2": "Any transaction id for your internal reference. This could be a order id or so", "6-0": "meta", "6-1": "String", "6-2": "Any meta data to associate with the transaction", "8-0": "frozen", "8-1": "Boolean", "8-2": "Whether the credit should be immediately reflected or should it be kept on hold till some future point. This is usually associated with the transaction_id. For example, you may want to provide cashback for a particular order but want to wait till it has been delivered. You can use the order id as the transaction id in this case and unfreeze the transaction once the delivery has been confirmed", "3-0": "service", "3-1": "String", "3-2": "Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`", "7-0": "tag", "7-1": "String", "7-2": "Tags to be associated with the transaction" }, "cols": 3, "rows": 9 } [/block] [block:api-header] { "type": "fn", "title": "redeem" } [/block] [block:code] { "codes": [ { "code": "(String user_id, float redemption_value, float transaction_value, int redeem_from = -1, String platform, String service, String transaction_id, String meta, String tag)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Boolean **Throws** BalanceExhaustedException, Exception, InvalidArgumentException [block:callout] { "type": "danger", "body": "This method throws a BalanceExhaustedException. Please be sure to handle the error appropriately", "title": "Error handling required" } [/block] Redeem points from users wallet based on set rules [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID to which the balance has to be added", "1-0": "redemption_value", "1-1": "Float", "1-2": "The maximum value to be redeemed. This may or may not be the actual value redeemed. Loyalty service will internally calculate the maximum redeemable value based on the set rules & will be compared with the requested redemption value, the least of which will be redeemed", "2-0": "transaction_value", "2-1": "Float", "2-2": "The transaction value for which redemption is being mades & points to be calculated to be debited from the user's wallet", "4-0": "platform", "4-1": "String", "4-2": "Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% redemption for users from Desktop but 10% redemption for Android & 12% redemption for iOS app users", "5-0": "service", "5-1": "String", "7-1": "String", "7-2": "Any meta data to associate with this transaction", "7-0": "meta", "5-2": "Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`", "3-0": "redeem_from", "3-1": "int", "3-2": "Which transaction type balance to be redeemed from. Default is `-1` which is from both transactional & promotional", "8-0": "tag", "8-1": "String", "8-2": "Tags to be associated with the transaction", "6-0": "transaction_id", "6-1": "String", "6-2": "Transaction ID" }, "cols": 3, "rows": 9 } [/block] [block:api-header] { "type": "fn", "title": "cancelTransaction" } [/block] Cancel / undo the transaction [block:code] { "codes": [ { "code": "(String transaction_id)", "language": "java", "name": "Signature" } ] } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "transaction_id", "0-1": "String", "0-2": "Transaction ID of the transaction to be cancelled" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "refund" } [/block] Refund the complete or the remaining balance of the transaction [block:code] { "codes": [ { "code": "(String transaction_id)", "language": "java", "name": "Signature" } ] } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "transaction_id", "0-1": "String", "0-2": "Transaction ID of the transaction to be refunded" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "refundPartial" } [/block] Refund a partial amount of the transaction [block:code] { "codes": [ { "code": "(String transaction_id, float sku_value)", "language": "java", "name": "Signature" } ] } [/block] [block:callout] { "type": "warning", "title": "SKU Value", "body": "This is different from the refund value. You should pass the SKU value of the refunded value/service, the refund to be given will be automatically calculated by the service" } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "transaction_id", "0-1": "String", "0-2": "Transaction ID of the transaction to be refunded", "1-0": "sku_value", "1-1": "float", "1-2": "SKU value of the cancelled/returned service for which a refund needs to be made" }, "cols": 3, "rows": 2 } [/block] [block:api-header] { "type": "fn", "title": "maximumRedemption" } [/block] [block:code] { "codes": [ { "code": "(String user_id, float transaction_value, String platform, String service)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Boolean **Throws** Exception, InvalidArgumentException Tells you how much (maximum) value of the user's wallet can be redeemed against the given transaction value. Please note, this does not redeem from the wallet, rather think of this as a sneak peak function [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID to which the balance has to be added", "1-0": "transaction_value", "1-1": "Float", "1-2": "The transaction value for which maximum redemption possible has to be calculated", "2-0": "platform", "2-1": "String", "2-2": "Which platform the user is performing the current transaction. You can use switch/select rules based on platform. For example, you can have 5% redemption for users from Desktop but 10% redemption for Android & 12% redemption for iOS app users", "3-0": "service", "3-1": "String", "3-2": "Which service slot should the current transaction use. For example `service1` could have `2%` and `service2` could have `5%`" }, "cols": 3, "rows": 4 } [/block] [block:api-header] { "type": "fn", "title": "getBalance" } [/block] [block:code] { "codes": [ { "code": "(String user_id)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Float **Throws** Exception, InvalidArgumentException Get the balance credits available from a user's wallet [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID to which the balance has to be calculated" }, "cols": 3, "rows": 1 } [/block]