From 090d36de66eaeb959663eea8844b69be2842c384 Mon Sep 17 00:00:00 2001 From: Raymond Yee Date: Wed, 9 May 2012 17:16:49 -0700 Subject: [PATCH] [#29272807] implemented storage of FPS_* keys in the db --- payment/amazon.py | 20 +++++++++++++------- settings/dev.py | 8 -------- test/campaign_starter.sql | 25 ------------------------- 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/payment/amazon.py b/payment/amazon.py index eecfe433..4cb2ec26 100644 --- a/payment/amazon.py +++ b/payment/amazon.py @@ -1,4 +1,5 @@ from regluit.payment.parameters import * +from regluit.core.models import Key from django.core.urlresolvers import reverse from django.conf import settings from regluit.payment.models import Transaction, PaymentResponse @@ -49,6 +50,11 @@ AMAZON_OPERATION_TYPE_PAY = 'PAY' AMAZON_OPERATION_TYPE_REFUND = 'REFUND' AMAZON_OPERATION_TYPE_CANCEL = 'CANCEL' +# load FPS_ACCESS_KEY and FPS_SECRET_KEY from the database + +FPS_ACCESS_KEY = Key.objects.get(name="FPS_ACCESS_KEY").value +FPS_SECRET_KEY = Key.objects.get(name="FPS_SECRET_KEY").value + def ProcessIPN(request): ''' @@ -81,7 +87,7 @@ def ProcessIPN(request): uri = request.build_absolute_uri() parsed_url = urlparse.urlparse(uri) - connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) # Check the validity of the IPN resp = connection.verify_signature("%s://%s%s" %(parsed_url.scheme, @@ -382,7 +388,7 @@ class Pay( AmazonRequest ): self.original_return_url = return_url return_url = settings.BASE_URL + reverse('AmazonPaymentReturn') - self.connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + self.connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) receiver_list = [] receivers = transaction.receiver_set.all() @@ -467,7 +473,7 @@ class Execute(AmazonRequest): logging.debug("Amazon EXECUTE action for transaction id: %d" % transaction.id) # Use the boto class top open a connection - self.connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + self.connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) self.transaction = transaction # BUGBUG, handle multiple receivers! For now we just send the money to ourselves @@ -557,7 +563,7 @@ class PaymentDetails(AmazonRequest): logging.debug("Amazon PAYMENTDETAILS API for transaction id: %d" % transaction.id) # Use the boto class top open a connection - self.connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + self.connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) self.transaction = transaction if not transaction.preapproval_key: @@ -638,7 +644,7 @@ class CancelPreapproval(AmazonRequest): logging.debug("Amazon CANCELPREAPPROVAL api called for transaction id: %d" % transaction.id) # Use the boto class top open a connection - self.connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + self.connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) self.transaction = transaction params = {} @@ -692,7 +698,7 @@ class RefundPayment(AmazonRequest): logging.debug("Amazon REFUNDPAYMENT API called for transaction id: %d", transaction.id) # Use the boto class top open a connection - self.connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + self.connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) self.transaction = transaction if not transaction.preapproval_key: @@ -745,7 +751,7 @@ class PreapprovalDetails(AmazonRequest): logging.debug("Amazon PREAPPROVALDETAILS API called for transaction id: %d", transaction.id) # Use the boto class top open a connection - self.connection = FPSConnection(settings.FPS_ACCESS_KEY, settings.FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) + self.connection = FPSConnection(FPS_ACCESS_KEY, FPS_SECRET_KEY, host=settings.AMAZON_FPS_HOST) self.transaction = transaction diff --git a/settings/dev.py b/settings/dev.py index 9a9cd30b..20921ed5 100644 --- a/settings/dev.py +++ b/settings/dev.py @@ -68,14 +68,6 @@ GOOGLE_BOOKS_API_KEY = '' # Payment processor switch PAYMENT_PROCESSOR = 'amazon' -# Amazon credentials (for fps) -AWS_ACCESS_KEY = '' -AWS_SECRET_ACCESS_KEY = '' - -# Amazon FPS Credentials -FPS_ACCESS_KEY = '' -FPS_SECRET_KEY = '' - # set -- sandbox or production Amazon FPS? AMAZON_FPS_HOST = "fps.sandbox.amazonaws.com" #AMAZON_FPS_HOST = "fps.amazonaws.com" diff --git a/test/campaign_starter.sql b/test/campaign_starter.sql index 77d240de..c0b7e342 100644 --- a/test/campaign_starter.sql +++ b/test/campaign_starter.sql @@ -582,31 +582,6 @@ INSERT INTO `core_identifier` VALUES (1,'goog','wtPxGztYx-UC',1,1),(2,'isbn','97 /*!40000 ALTER TABLE `core_identifier` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `core_key` --- - -DROP TABLE IF EXISTS `core_key`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `core_key` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `encrypted_value` longtext, - PRIMARY KEY (`id`), - UNIQUE KEY `core_key_name_uniq` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `core_key` --- - -LOCK TABLES `core_key` WRITE; -/*!40000 ALTER TABLE `core_key` DISABLE KEYS */; -/*!40000 ALTER TABLE `core_key` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `core_premium` --