use of org.thoughtcrime.securesms.payments.Payments in project Signal-Android by WhisperSystems.
the class PaymentTransactionCheckJob method onRun.
@Override
protected void onRun() throws Exception {
PaymentDatabase paymentDatabase = SignalDatabase.payments();
PaymentDatabase.PaymentTransaction payment = paymentDatabase.getPayment(uuid);
if (payment == null) {
Log.w(TAG, "No payment found for UUID " + uuid);
return;
}
Payments payments = ApplicationDependencies.getPayments();
switch(payment.getDirection()) {
case SENT:
{
Log.i(TAG, "Checking sent status of " + uuid);
PaymentTransactionId paymentTransactionId = new PaymentTransactionId.MobileCoin(Objects.requireNonNull(payment.getTransaction()), Objects.requireNonNull(payment.getReceipt()), payment.getFee().requireMobileCoin());
Wallet.TransactionStatusResult status = payments.getWallet().getSentTransactionStatus(paymentTransactionId);
switch(status.getTransactionStatus()) {
case COMPLETE:
paymentDatabase.markPaymentSuccessful(uuid, status.getBlockIndex());
Log.i(TAG, "Marked sent payment successful " + uuid);
break;
case FAILED:
paymentDatabase.markPaymentFailed(uuid, FailureReason.UNKNOWN);
Log.i(TAG, "Marked sent payment failed " + uuid);
break;
case IN_PROGRESS:
Log.i(TAG, "Sent payment still in progress " + uuid);
throw new IncompleteTransactionException();
default:
throw new AssertionError();
}
break;
}
case RECEIVED:
{
Log.i(TAG, "Checking received status of " + uuid);
Wallet.ReceivedTransactionStatus transactionStatus = payments.getWallet().getReceivedTransactionStatus(Objects.requireNonNull(payment.getReceipt()));
switch(transactionStatus.getStatus()) {
case COMPLETE:
paymentDatabase.markReceivedPaymentSuccessful(uuid, transactionStatus.getAmount(), transactionStatus.getBlockIndex());
Log.i(TAG, "Marked received payment successful " + uuid);
break;
case FAILED:
paymentDatabase.markPaymentFailed(uuid, FailureReason.UNKNOWN);
Log.i(TAG, "Marked received payment failed " + uuid);
break;
case IN_PROGRESS:
Log.i(TAG, "Received payment still in progress " + uuid);
throw new IncompleteTransactionException();
default:
throw new AssertionError();
}
break;
}
default:
{
throw new AssertionError();
}
}
}
use of org.thoughtcrime.securesms.payments.Payments in project Signal-Android by signalapp.
the class PaymentTransactionCheckJob method onRun.
@Override
protected void onRun() throws Exception {
PaymentDatabase paymentDatabase = SignalDatabase.payments();
PaymentDatabase.PaymentTransaction payment = paymentDatabase.getPayment(uuid);
if (payment == null) {
Log.w(TAG, "No payment found for UUID " + uuid);
return;
}
Payments payments = ApplicationDependencies.getPayments();
switch(payment.getDirection()) {
case SENT:
{
Log.i(TAG, "Checking sent status of " + uuid);
PaymentTransactionId paymentTransactionId = new PaymentTransactionId.MobileCoin(Objects.requireNonNull(payment.getTransaction()), Objects.requireNonNull(payment.getReceipt()), payment.getFee().requireMobileCoin());
Wallet.TransactionStatusResult status = payments.getWallet().getSentTransactionStatus(paymentTransactionId);
switch(status.getTransactionStatus()) {
case COMPLETE:
paymentDatabase.markPaymentSuccessful(uuid, status.getBlockIndex());
Log.i(TAG, "Marked sent payment successful " + uuid);
break;
case FAILED:
paymentDatabase.markPaymentFailed(uuid, FailureReason.UNKNOWN);
Log.i(TAG, "Marked sent payment failed " + uuid);
break;
case IN_PROGRESS:
Log.i(TAG, "Sent payment still in progress " + uuid);
throw new IncompleteTransactionException();
default:
throw new AssertionError();
}
break;
}
case RECEIVED:
{
Log.i(TAG, "Checking received status of " + uuid);
Wallet.ReceivedTransactionStatus transactionStatus = payments.getWallet().getReceivedTransactionStatus(Objects.requireNonNull(payment.getReceipt()));
switch(transactionStatus.getStatus()) {
case COMPLETE:
paymentDatabase.markReceivedPaymentSuccessful(uuid, transactionStatus.getAmount(), transactionStatus.getBlockIndex());
Log.i(TAG, "Marked received payment successful " + uuid);
break;
case FAILED:
paymentDatabase.markPaymentFailed(uuid, FailureReason.UNKNOWN);
Log.i(TAG, "Marked received payment failed " + uuid);
break;
case IN_PROGRESS:
Log.i(TAG, "Received payment still in progress " + uuid);
throw new IncompleteTransactionException();
default:
throw new AssertionError();
}
break;
}
default:
{
throw new AssertionError();
}
}
}
Aggregations