Skip to content

Instantly share code, notes, and snippets.

@msulima
Created August 14, 2013 19:07
Show Gist options
  • Save msulima/6234443 to your computer and use it in GitHub Desktop.
Save msulima/6234443 to your computer and use it in GitHub Desktop.
public Transaction createTransaction(Sale sale, Customer customer) {
Transaction transaction = new Transaction();
populatePaymentDetails(transaction, sale);
populateCustomerDetails(transaction, customer);
sale.setProcessed(true);
return transaction;
}
private void populatePaymentDetails(Transaction transaction, Sale sale) {
transaction.setPayerId(transaction.getCustomerId());
transaction.setCurrency(sale.getCurrency());
transaction.setAmount(sale.getAmount());
}
private void populateCustomerDetails(Transaction transaction, Customer customer) {
transaction.setCustomerId(customer.getId());
/** ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment