Created
June 29, 2012 16:37
-
-
Save jdeoliveira/3019061 to your computer and use it in GitHub Desktop.
Analyze credit request PHP script
This file contains hidden or 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
<scripting:component doc:name="Analyze credit request"> | |
<scripting:script engine="php"> | |
<scripting:text> | |
<![CDATA[ | |
<?php | |
$log->info("Hello from PHP, mule!"); | |
$request = json_decode($payload, true); | |
if (strcmp(substr($request["customerId"], 0, 3), "ABC") == 0) $factor = 3; | |
else if (strcmp(substr($request["customerId"], 0, 3), "DEF") == 0) $factor = 2; | |
if ($request["requestedAmount"] > ($factor * $request["averageIncome"])) { | |
$message->setOutboundProperty("outcome", "rejected"); | |
$request["maxAmount"] = ($factor * $request["averageIncome"]); | |
} else { | |
$message->setOutboundProperty("outcome", "approved"); | |
} | |
return json_encode($request); | |
?> | |
]]> | |
</scripting:text> | |
</scripting:script> | |
</scripting:component> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment