Added Receiver and PaymentResponse to admin interface

Dropping all Receiver and PaymentResponse in campaigntest.drop_all_transactions
Added a __unicode__ method to Receiver and PaymentResponse
Added some more documentation of PayPal status parameters
pull/1/head
Raymond Yee 2012-01-03 13:37:20 -05:00
parent 62a2a62efe
commit d3f25cd788
5 changed files with 49 additions and 7 deletions

View File

@ -56,6 +56,12 @@ class UserProfileAdmin(ModelAdmin):
class TransactionAdmin(ModelAdmin):
date_hierarchy = 'date_created'
class PaymentResponseAdmin(ModelAdmin):
pass
class ReceiverAdmin(ModelAdmin):
ordering = ('email',)
admin_site = RegluitAdmin("Admin")
@ -72,3 +78,5 @@ admin_site.register(models.Ebook, EbookAdmin)
admin_site.register(models.Wishlist, WishlistAdmin)
admin_site.register(models.UserProfile, UserProfileAdmin)
admin_site.register(payment.models.Transaction, TransactionAdmin)
admin_site.register(payment.models.PaymentResponse, PaymentResponseAdmin)
admin_site.register(payment.models.Receiver, ReceiverAdmin)

View File

@ -1,5 +1,5 @@
from regluit.core import models
from regluit.payment.models import Transaction
from regluit.payment.models import Transaction, PaymentResponse, Receiver
from regluit.payment.manager import PaymentManager
from regluit.payment.paypal import IPN_PAY_STATUS_ACTIVE, IPN_PAY_STATUS_INCOMPLETE, IPN_PAY_STATUS_COMPLETED
@ -31,7 +31,10 @@ def finish_campaigns(clist):
return [pm.finish_campaign(c) for c in clist]
def drop_all_transactions():
PaymentResponse.objects.all().delete()
Receiver.objects.all().delete()
Transaction.objects.all().delete()
# go through all Campaigns and set the self.left = self.target
for c in models.Campaign.objects.all():
c.left = c.target

View File

@ -95,7 +95,10 @@ class PaymentResponse(models.Model):
info = models.CharField(max_length=1024, null=True)
transaction = models.ForeignKey(Transaction, null=False)
def __unicode__(self):
return u"PaymentResponse -- api: {0} correlation_id: {1} transaction: {2}".format(self.api, self.correlation_id, unicode(self.transaction))
class Receiver(models.Model):
@ -110,6 +113,9 @@ class Receiver(models.Model):
txn_id = models.CharField(max_length=64)
transaction = models.ForeignKey(Transaction)
def __unicode__(self):
return u"Receiver -- email: {0} status: {1} transaction: {2}".format(self.email, self.status, unicode(self.transaction))
from django.db.models.signals import post_save, post_delete
import regluit.payment.manager

View File

@ -7,11 +7,11 @@ EXECUTE_TYPE_CHAINED_INSTANT = 1
EXECUTE_TYPE_CHAINED_DELAYED = 2
EXECUTE_TYPE_PARALLEL = 3
TARGET_TYPE_NONE = 0
TARGET_TYPE_CAMPAIGN = 1
TARGET_TYPE_LIST = 2
TARGET_TYPE_DONATION = 3
# these two following parameters are probably extraneous since I think we will compute dynamically where to return each time.
COMPLETE_URL = '/paymentcomplete'
CANCEL_URL = '/paymentcancel'

View File

@ -35,11 +35,20 @@ IPN_TYPE_ADJUSTMENT = 'Adjustment'
IPN_TYPE_PREAPPROVAL = 'Adaptive Payment PREAPPROVAL'
#pay API status constants
# I think 'NONE' is not something the API produces but is particular to our implementation
# couldn't we use the Python None?
# NONE' is not something the API produces but is particular to our implementation
IPN_PAY_STATUS_NONE = 'NONE'
# The following apply to INSTANT PAYMENTS
#The following apply to INSTANT PAYMENTS
#https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APPayAPI
#CREATED - The payment request was received; funds will be transferred once the payment is approved
#COMPLETED - The payment was successful
#INCOMPLETE - Some transfers succeeded and some failed for a parallel payment or, for a delayed chained payment, secondary receivers have not been paid
#ERROR - The payment failed and all attempted transfers failed or all completed transfers were successfully reversed
#REVERSALERROR - One or more transfers failed when attempting to reverse a payment
#PROCESSING - The payment is in progress
#PENDING - The payment is awaiting processing
IPN_PAY_STATUS_CREATED = 'CREATED'
IPN_PAY_STATUS_COMPLETED = 'COMPLETED'
IPN_PAY_STATUS_INCOMPLETE = 'INCOMPLETE'
@ -49,10 +58,26 @@ IPN_PAY_STATUS_PROCESSING = 'PROCESSING'
IPN_PAY_STATUS_PENDING = 'PENDING'
# particular to preapprovals -- may want to rename these constants to IPN_PREAPPROVAL_STATUS_*
# https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APPreapprovalDetails
#ACTIVE - The preapproval is active
#CANCELED - The preapproval was explicitly canceled by the sender or by PayPal
#DEACTIVED - The preapproval is not active; you can be reactivate it by resetting the personal identification number (PIN) or by contacting PayPal
IPN_PAY_STATUS_ACTIVE = "ACTIVE"
IPN_PAY_STATUS_CANCELED = "CANCELED"
IPN_PAY_STATUS_DEACTIVED = "DEACTIVED"
# https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APIPN
#COMPLETED - The sender's transaction has completed
#PENDING - The transaction is awaiting further processing
#CREATED - The payment request was received; funds will be transferred once approval is received
#PARTIALLY_REFUNDED - Transaction was partially refunded
#DENIED - The transaction was rejected by the receiver
#PROCESSING - The transaction is in progress
#REVERSED - The payment was returned to the sender
#REFUNDED - The payment was refunded
#FAILED - The payment failed
IPN_SENDER_STATUS_COMPLETED = 'COMPLETED'
IPN_SENDER_STATUS_PENDING = 'PENDING'
IPN_SENDER_STATUS_CREATED = 'CREATED'
@ -67,7 +92,7 @@ IPN_SENDER_STATUS_FAILED = 'FAILED'
IPN_ACTION_TYPE_PAY = 'PAY'
IPN_ACTION_TYPE_CREATE = 'CREATE'
# individual sender transaction constants
# individual sender transaction constants (???)
IPN_TXN_STATUS_COMPLETED = 'Completed'
IPN_TXN_STATUS_PENDING = 'Pending'
IPN_TXN_STATUS_REFUNDED = 'Refunded'