public async Task <StripeTransactionResult> HandleAsync( UserId userId, DateTime timestamp, TransactionReference transactionReference, TaxamoTransactionResult taxamoTransaction, UserPaymentOriginResult origin, UserType userType) { userId.AssertNotNull("userId"); transactionReference.AssertNotNull("transactionReference"); taxamoTransaction.AssertNotNull("taxamoTransaction"); origin.AssertNotNull("origin"); // Perform stripe transaction. if (origin.PaymentOriginKeyType != PaymentOriginKeyType.Stripe) { throw new InvalidOperationException("Unexpected payment origin: " + origin.PaymentOriginKeyType); } var stripeChargeId = await this.performStripeCharge.ExecuteAsync( origin.PaymentOriginKey, taxamoTransaction.TotalAmount, userId, transactionReference, taxamoTransaction.Key, userType); return(new StripeTransactionResult(timestamp, transactionReference, stripeChargeId)); }
public async Task HandleAsync( UserId userId, TaxamoTransactionResult taxamoTransaction, UserPaymentOriginResult origin, StripeTransactionResult stripeTransaction) { userId.AssertNotNull("userId"); taxamoTransaction.AssertNotNull("taxamoTransaction"); origin.AssertNotNull("origin"); stripeTransaction.AssertNotNull("stripeTransaction"); // Persist credit to ledger. await this.saveCustomerCreditToLedger.ExecuteAsync( userId, stripeTransaction.Timestamp, taxamoTransaction.TotalAmount, taxamoTransaction.Amount, stripeTransaction.TransactionReference, stripeTransaction.StripeChargeId, taxamoTransaction.Key); // Clear the billing status, in case it a previous billing attempt failed. await this.clearPaymentStatus.ExecuteAsync(userId); // Store original taxamo transaction key if not already stored. if (origin.OriginalTaxamoTransactionKey == null) { await this.setUserPaymentOriginOriginalTaxamoTransactionKey.ExecuteAsync(userId, taxamoTransaction.Key); } // Update account balance. await this.updateAccountBalances.ExecuteAsync(userId, stripeTransaction.Timestamp); }