Search in sources :

Example 1 with Fee

use of com.stripe.model.Fee in project alf.io by alfio-event.

the class StripeManager method getInfo.

Optional<PaymentInformation> getInfo(Transaction transaction, Event event) {
    try {
        Optional<RequestOptions> requestOptionsOptional = options(event);
        if (requestOptionsOptional.isPresent()) {
            RequestOptions options = requestOptionsOptional.get();
            Charge charge = Charge.retrieve(transaction.getTransactionId(), options);
            String paidAmount = MonetaryUtil.formatCents(charge.getAmount());
            String refundedAmount = MonetaryUtil.formatCents(charge.getAmountRefunded());
            List<Fee> fees = retrieveBalanceTransaction(charge.getBalanceTransaction(), options).getFeeDetails();
            return Optional.of(new PaymentInformation(paidAmount, refundedAmount, getFeeAmount(fees, "stripe_fee"), getFeeAmount(fees, "application_fee")));
        }
        return Optional.empty();
    } catch (StripeException e) {
        return Optional.empty();
    }
}
Also used : RequestOptions(com.stripe.net.RequestOptions) Fee(com.stripe.model.Fee) Charge(com.stripe.model.Charge) PaymentInformation(alfio.model.PaymentInformation)

Aggregations

PaymentInformation (alfio.model.PaymentInformation)1 Charge (com.stripe.model.Charge)1 Fee (com.stripe.model.Fee)1 RequestOptions (com.stripe.net.RequestOptions)1