@@ -773,23 +773,16 @@ public static List<Payment> getForUser(String userId){
773773 return get ("userId=?" , userId );
774774 }
775775
776- public static List <Payment > getSubscriptionPaymentsForUser (String userId ){
776+ public static List <Payment > getUserSubscriptionPayments (String userId ){
777777 return whereUserId ().is (userId )
778778 .and (wherePaypalSubscriptionId ().isNotNull ()
779779 .or (whereStripeSubscriptionId ().isNotNull ()))
780780 .get ();
781781 // TODO ADD NEW PAYMENT PROCESSOR
782782 }
783783
784- /**
785- * List of payments that haven't been authorized or cancelled (or expired) yet and are in the future.
786- *
787- * @return list of payments, where {@link Payment#timestampAuthorized} is null, and
788- * {@link Payment#timestampCancelled} is null, and {@link Payment#timestampCreated} is bigger than now.
789- */
790- public static List <Payment > getPendingFuturePayments (String where , Object ... objs ) throws Exception {
791- return get ("timestampAuthorized = 0 AND timestampCancelled = 0 AND timestampCreated > " + System .currentTimeMillis () +
792- (where != null ? " AND " + where : "" ), objs );
784+ public static List <Payment > getUserPendingPayments (String userId ){
785+ return getPendingPayments ("userId=?" , userId );
793786 }
794787
795788 /**
@@ -798,7 +791,7 @@ public static List<Payment> getPendingFuturePayments(String where, Object... obj
798791 * @return list of payments, where {@link Payment#timestampAuthorized} is null, and
799792 * {@link Payment#timestampCancelled} is null, and {@link Payment#timestampCreated} is smaller than now and {@link Payment#timestampExpires} is bigger than now.
800793 */
801- public static List <Payment > getPendingPayments () throws Exception {
794+ public static List <Payment > getPendingPayments () {
802795 return getPendingPayments (null );
803796 }
804797
@@ -808,18 +801,22 @@ public static List<Payment> getPendingPayments() throws Exception {
808801 * @return list of payments, where {@link Payment#timestampAuthorized} is null, and
809802 * {@link Payment#timestampCancelled} is null, and {@link Payment#timestampCreated} is smaller than now and {@link Payment#timestampExpires} is bigger than now.
810803 */
811- public static List <Payment > getPendingPayments (String where , Object ... objs ) throws Exception {
812- return get ("timestampAuthorized = 0 AND timestampCancelled = 0 "
804+ public static List <Payment > getPendingPayments (String where , Object ... objs ) {
805+ return get ("WHERE timestampAuthorized = 0 AND timestampCancelled = 0 "
813806 + (where != null ? " AND " + where : "" ), objs );
814807 }
815808
809+ public static List <Payment > getUserAuthorizedPayments (String userId ) {
810+ return getAuthorizedPayments ("userId=?" , userId );
811+ }
812+
816813 /**
817814 * List of payments that have been authorized/completed/paid.
818815 *
819816 * @return list of payments, where {@link Payment#timestampAuthorized} is not null.
820817 * @see PayHook#onPaymentAuthorized
821818 */
822- public static List <Payment > getAuthorizedPayments () throws Exception {
819+ public static List <Payment > getAuthorizedPayments () {
823820 return getAuthorizedPayments (null );
824821 }
825822
@@ -829,8 +826,12 @@ public static List<Payment> getAuthorizedPayments() throws Exception {
829826 * @return list of payments, where {@link Payment#timestampAuthorized} is not null.
830827 * @see PayHook#onPaymentAuthorized
831828 */
832- public static List <Payment > getAuthorizedPayments (String where , Object ... objs ) throws Exception {
833- return get ("timestampAuthorized != 0 " + (where != null ? " AND " + where : "" ), objs );
829+ public static List <Payment > getAuthorizedPayments (String where , Object ... objs ) {
830+ return get ("WHERE timestampAuthorized != 0 " + (where != null ? " AND " + where : "" ), objs );
831+ }
832+
833+ public static List <Payment > getUserCancelledPayments (String userId ) {
834+ return getCancelledPayments ("userId=?" , userId );
834835 }
835836
836837 /**
@@ -839,7 +840,7 @@ public static List<Payment> getAuthorizedPayments(String where, Object... objs)
839840 * @return list of payments, where {@link Payment#timestampCancelled} is not null.
840841 * @see PayHook#onPaymentCancelled
841842 */
842- public static List <Payment > getCancelledPayments () throws Exception {
843+ public static List <Payment > getCancelledPayments () {
843844 return getCancelledPayments (null );
844845 }
845846
@@ -849,26 +850,30 @@ public static List<Payment> getCancelledPayments() throws Exception {
849850 * @return list of payments, where {@link Payment#timestampCancelled} is not null.
850851 * @see PayHook#onPaymentCancelled
851852 */
852- public static List <Payment > getCancelledPayments (String where , Object ... objs ) throws Exception {
853- return get ("timestampCancelled != 0 " + (where != null ? " AND " + where : "" ), objs );
853+ public static List <Payment > getCancelledPayments (String where , Object ... objs ) {
854+ return get ("WHERE timestampCancelled != 0 " + (where != null ? " AND " + where : "" ), objs );
855+ }
856+
857+ public static List <Payment > getUserRefundedPayments (String userId ) {
858+ return getRefundedPayments ("userId=?" , userId );
854859 }
855860
856861 /**
857862 * List of payments that have been refunded.
858863 *
859- * @return list of payments, where {@link Payment#charge } is smaller than 0.
864+ * @return list of payments, where {@link Payment#timestampRefunded } is not 0.
860865 */
861- public static List <Payment > getRefundedPayments () throws Exception {
866+ public static List <Payment > getRefundedPayments () {
862867 return getRefundedPayments (null );
863868 }
864869
865870 /**
866871 * List of payments that have been refunded.
867872 *
868- * @return list of payments, where {@link Payment#charge } is smaller than 0.
873+ * @return list of payments, where {@link Payment#timestampRefunded } is not 0.
869874 */
870- public static List <Payment > getRefundedPayments (String where , Object ... objs ) throws Exception {
871- return get ("charge < = 0 " + (where != null ? " AND " + where : "" ), objs );
875+ public static List <Payment > getRefundedPayments (String where , Object ... objs ) {
876+ return get ("WHERE timestampRefunded ! = 0 " + (where != null ? " AND " + where : "" ), objs );
872877 }
873878
874879 public PaymentProcessor getPaymentProcessor () {
0 commit comments