Last active
April 24, 2017 08:15
-
-
Save berndruecker/b815b0fcb698ce88350fcb458afa7bc0 to your computer and use it in GitHub Desktop.
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
public class RetrievePaymentRestAdapter implements JavaDelegate { | |
@Inject private OrderRepository orderRepository; // e.g. using Spring | |
@Inject private RestTemplate rest; // e.g. using Spring | |
public void execute(DelegateExecution context) throws Exception { | |
// Input mapping | |
String orderId = context.getVariable("orderId"); | |
Order o = orderRepository.findOrder(orderId); | |
CreateChargeRequest request = new CreateChargeRequest(); | |
request.setAmount( o.getAmount() ); | |
// Service call by technology of choice (e.g. Spring RestTemplate) | |
CreateChargeResponse response = rest.postForObject("https://api.stripe.com", | |
request, CreateChargeResponse.class); | |
// Output mapping | |
context.setVariable("stripeTransactionId", response.getBalanceTransaction()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment