Ignore:
Timestamp:
5 Nov 2019, 23:19:58 (5 years ago)
Author:
Henrik Bettermann
Message:

Prepare all payment gateway modules for net amount fee configuration. In the future, provider and gateway surcharges will be determined and added just before the data are being send to the gateways for the first time.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants/payment.py

    r15730 r15755  
    4141        return
    4242
    43     @property
    44     def net_amt(self):
    45         return self.amount_auth - self.provider_amt - self.gateway_amt
    46 
    4743NigeriaApplicantOnlinePayment = attrs_to_fields(
    48     NigeriaApplicantOnlinePayment, omit=['display_item', 'net_amt'])
     44    NigeriaApplicantOnlinePayment, omit=['display_item',])
    4945
    5046# Applicant online payments must be importable. So we might need a factory.
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/applicantsbrowser.py

    r15702 r15755  
    3333
    3434from kofacustom.nigeria.etranzact.tests import (
    35     TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL)
     35    TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL, GATEWAY_AMT)
    3636
    3737grok.templatedir('browser_templates')
     
    9393    terminal_id = TERMINAL_ID
    9494    logo_url = LOGO_URL
     95    gateway_amt = GATEWAY_AMT
    9596
    9697    @property
     
    101102
    102103    def init_update(self):
     104        if not module_activated(self.context.__parent__.__parent__.year):
     105            return _("Etranzact payments deactivated.")
    103106        if self.context.p_state == 'paid':
    104107            return _("Payment ticket can't be re-sent to Etranzact.")
     
    116119        # which authenticates the response.
    117120        self.responseurl = self.url(self.context, 'receive_etranzact')
    118         # Already now it becomes a Etranzact payment
    119         self.context.r_company = u'etranzact'
    120         hashargs =      self.amount + self.terminal_id+self.transaction_id \
     121        self.transaction_id = self.context.p_id
     122        hashargs =      self.amount + self.terminal_id + self.transaction_id \
    121123            + self.responseurl + self.secret_key
    122124        self.hashvalue = hashlib.md5(hashargs).hexdigest()
     
    125127
    126128    def update(self):
    127         if not module_activated(self.context.__parent__.__parent__.year):
    128             return
    129         self.transaction_id = self.context.p_id
     129        # Already now it becomes an Etranzact payment. We set the net amount
     130        # and add the gateway amount.
     131        if not self.context.r_company:
     132            self.context.net_amt = self.context.amount_auth
     133            self.context.amount_auth += self.gateway_amt
     134            self.context.gateway_amt = self.gateway_amt
     135            self.context.r_company = u'etranzact'
    130136        self.amount = "%.1f" % self.context.amount_auth
    131137        error = self.init_update()
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/helpers.py

    r15734 r15755  
    181181    payment.r_card_num = "%s %s" % (form.get('CARD_TYPE', None),
    182182                                    form.get('CARD_NO', None))
    183     payment.r_company = u'etranzact'
    184183    if payment.r_code != '0':
    185184        msg = _('Unsuccessful response: ${a}', mapping = {'a': payment.r_desc})
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/payoutletbrowser.py

    r15730 r15755  
    3939from kofacustom.nigeria.students.interfaces import INigeriaStudentOnlinePayment
    4040from kofacustom.nigeria.applicants.interfaces import INigeriaApplicantOnlinePayment
    41 from kofacustom.nigeria.etranzact.tests import HOST, TERMINAL_ID, HTTPS
     41from kofacustom.nigeria.etranzact.tests import HOST, TERMINAL_ID, HTTPS, GATEWAY_AMT
    4242from kofacustom.nigeria.etranzact.helpers import query_payoutlet
    4343
     
    8484
    8585class EtranzactEnterPinPageStudent(KofaPage):
    86     """
     86    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent`
    8787    """
    8888    grok.context(INigeriaStudentOnlinePayment)
     
    9595    action = 'query_payoutlet_history'
    9696    placeholder = _('Confirmation Number (PIN)')
     97    gateway_amt = GATEWAY_AMT
    9798
    9899    def update(self):
    99100        if not module_activated(self.context.student.current_session):
    100101            return
     102        if self.context.r_company and self.context.r_company != 'etranzact':
     103            return _("Payment ticket has been used for another payment gateway.")
    101104        super(EtranzactEnterPinPageStudent, self).update()
     105        # Already now it becomes an Etranzact payment. We set the net amount
     106        # and add the gateway amount.
     107        if not self.context.r_company:
     108            self.context.net_amt = self.context.amount_auth
     109            self.context.amount_auth += self.gateway_amt
     110            self.context.gateway_amt = self.gateway_amt
     111            self.context.r_company = u'etranzact'
    102112        return
    103113
    104114class EtranzactEnterPinPageApplicant(EtranzactEnterPinPageStudent):
    105     """
     115    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
    106116    """
    107117    grok.require('waeup.payApplicant')
     
    155165        if not module_activated(self.context.__parent__.__parent__.year):
    156166            return
    157         ob_class = self.__implemented__.__name__
    158167        if self.context.p_state == 'paid':
    159168            self.flash(_('This ticket has already been paid.'))
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/studentsbrowser.py

    r15702 r15755  
    3333
    3434from kofacustom.nigeria.etranzact.tests import (
    35     TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL)
     35    TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL, GATEWAY_AMT)
    3636
    3737grok.templatedir('browser_templates')
     
    9393    terminal_id = TERMINAL_ID
    9494    logo_url = LOGO_URL
     95    gateway_amt = GATEWAY_AMT
    9596
    9697    @property
     
    101102
    102103    def init_update(self):
     104        if not module_activated(self.context.student.current_session):
     105            return _("Etranzact payments deactivated.")
    103106        if self.context.p_state == 'paid':
    104107            return _("Payment ticket can't be re-sent to Etranzact.")
     
    116119        # which authenticates the response.
    117120        self.responseurl = self.url(self.context, 'receive_etranzact')
    118         # Already now it becomes a Etranzact payment
    119         self.context.r_company = u'etranzact'
    120         hashargs =      self.amount + self.terminal_id+self.transaction_id \
     121        self.transaction_id = self.context.p_id
     122        hashargs =      self.amount + self.terminal_id + self.transaction_id \
    121123            + self.responseurl + self.secret_key
    122124        self.hashvalue = hashlib.md5(hashargs).hexdigest()
     
    125127
    126128    def update(self):
    127         if not module_activated(self.context.student.current_session):
    128             return
    129         self.transaction_id = self.context.p_id
     129        # Already now it becomes an Etranzact payment. We set the net amount
     130        # and add the gateway amount.
     131        if not self.context.r_company:
     132            self.context.net_amt = self.context.amount_auth
     133            self.context.amount_auth += self.gateway_amt
     134            self.context.gateway_amt = self.gateway_amt
     135            self.context.r_company = u'etranzact'
    130136        self.amount = "%.1f" % self.context.amount_auth
    131137        error = self.init_update()
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/tests.py

    r15734 r15755  
    4141#   do exist really and are not bothered by being spammed by a test programme.
    4242
    43 EXTERNAL_TESTS = True
     43EXTERNAL_TESTS = False
    4444
    4545TERMINAL_ID = '5003021194'
     
    4848SECRET_KEY = 'DEMO_KEY'
    4949LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png'
     50GATEWAY_AMT = 500.0
    5051
    5152# Valid transaction id in Etranzact system
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/browser.py

    r15727 r15755  
    3434from kofacustom.nigeria.interfaces import MessageFactory as _
    3535
     36GATEWAY_AMT = 300.0
     37
    3638# Buttons
    3739
     
    306308    xml_data = None
    307309    hashvalue = None
     310    gateway_amt = GATEWAY_AMT
    308311
    309312    def init_update(self):
     
    317320        if time_delta.days > 7:
    318321            return _("This payment ticket is too old. Please create a new ticket.")
     322        if self.context.r_company and self.context.r_company != 'interswitch':
     323            return _("Payment ticket has been used for another payment gateway.")
    319324        student = self.context.student
    320325        certificate = getattr(student['studycourse'],'certificate',None)
     
    326331            self.context.p_item, self.context.p_session):
    327332            return _("This type of payment has already been made.")
    328         self.amount_auth = int(100 * self.context.amount_auth)
    329333        xmldict = {}
    330334        if certificate is not None:
     
    341345        self.student = student
    342346        self.xmldict = xmldict
    343         self.context.r_company = u'interswitch'
    344347        return
    345348
     
    351354            self.flash(error, type='danger')
    352355            self.redirect(self.url(self.context, '@@index'))
     356        # Already now it becomes an Interswitch payment. We set the net amount
     357        # and add the gateway amount.
     358        if not self.context.r_company:
     359            self.context.net_amt = self.context.amount_auth
     360            self.context.amount_auth += self.gateway_amt
     361            self.context.gateway_amt = self.gateway_amt
     362            self.context.r_company = u'interswitch'
     363        self.amount_auth = int(100 * self.context.amount_auth)
    353364        return
    354365
     
    363374    label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
    364375    submit_button = _('Submit')
    365     hashvalue = None
    366376
    367377    action = None
     
    371381    product_id = None
    372382    xml_data = None
     383    hashvalue = None
     384    gateway_amt = GATEWAY_AMT
    373385
    374386    def init_update(self):
     
    379391            return _("Payment ticket can't be send to CollegePAY. "
    380392                     "Application period has expired.")
     393        if self.context.r_company and self.context.r_company != 'interswitch':
     394            return _("Payment ticket has been used for another payment gateway.")
    381395        tz = getUtility(IKofaUtils).tzinfo
    382396        time_delta = datetime.utcnow() - self.context.creation_date
     
    384398            return _("This payment ticket is too old. Please create a new ticket.")
    385399        self.applicant = self.context.__parent__
    386         self.amount_auth = int(100 * self.context.amount_auth)
    387400        self.category = self.context.category
    388401        tz = getUtility(IKofaUtils).tzinfo
     
    390403            self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    391404        self.site_redirect_url = self.url(self.context, 'request_webservice')
    392         self.context.r_company = u'interswitch'
    393405        return
    394406
     
    400412            self.flash(error, type='danger')
    401413            self.redirect(self.url(self.context, '@@index'))
    402         return
     414        # Already now it becomes an Interswitch payment. We set the net amount
     415        # and add the gateway amount.
     416        if not self.context.r_company:
     417            self.context.net_amt = self.context.amount_auth
     418            self.context.amount_auth += self.gateway_amt
     419            self.context.gateway_amt = self.gateway_amt
     420            self.context.r_company = u'interswitch'
     421        self.amount_auth = int(100 * self.context.amount_auth)
     422        return
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py

    r15702 r15755  
    103103        # Split amounts have been set.
    104104        self.assertEqual(self.student['payments'][value].provider_amt, 0.0)
    105         self.assertEqual(self.student['payments'][value].gateway_amt, 0.0)
     105        self.assertEqual(self.student['payments'][value].gateway_amt, 300.0)
    106106        self.assertMatches('...<input type="hidden" name="pay_item_id" />...',
    107107                           self.browser.contents)
    108         self.assertMatches(
    109             '...<input type="hidden" name="amount" value="2000000" />...',
     108        self.assertTrue(
     109            '<input type="hidden" name="amount" value="2030000" />' in
    110110            self.browser.contents)
    111111
     
    118118                           self.browser.contents)
    119119        self.assertEqual(self.student.current_mode, 'ug_ft')
    120         self.assertMatches(
    121             '...<input type="hidden" name="amount" value="4000000" />...',
     120        self.assertTrue(
     121            '<input type="hidden" name="amount" value="4030000" />' in
    122122            self.browser.contents)
    123123        delta = timedelta(days=8)
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/payments/interfaces.py

    r15731 r15755  
    111111        default = 0.0,
    112112        required = False,
    113         readonly = True,
     113        readonly = False,
    114114        )
    115115
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/applicantsbrowser.py

    r15529 r15755  
    3434
    3535from kofacustom.nigeria.remita.tests import (
    36     MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID)
     36    MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID, GATEWAY_AMT)
    3737
    3838grok.templatedir('browser_templates')
     
    235235        if self.context.p_state == 'paid':
    236236            return _("Payment ticket can't be re-sent to Remita.")
     237        if self.context.r_company and self.context.r_company != 'remita':
     238            return _("Payment ticket has been used for another payment gateway.")
    237239        now = datetime.utcnow()
    238240        if self.context.creation_date.tzinfo is not None:
     
    260262        if resp.get('statuscode') not in ('021', '025', '055'):
    261263            return 'RRR generation message from Remita: ' + resp.get('status')
    262         # Already now it becomes a Remita payment
    263         self.context.r_company = u'remita'
    264264        self.rrr = self.context.r_pay_reference = resp['RRR'].rstrip()
    265265        hashargs =      self.merchantId + self.rrr + self.api_key
     
    269269            'RRR retrieved: %s, ServiceTypeId: %s'
    270270            % (self.rrr, self.serviceTypeId))
    271 
    272271        return
    273272
     
    281280            self.redirect(self.url(self.context, '@@index'))
    282281            return
    283         return
     282        # Already now it becomes a Remita payment. We set the net amount
     283        # and add the gateway amount.
     284        if not self.context.r_company:
     285            self.context.net_amt = self.context.amount_auth
     286            self.context.amount_auth += self.gateway_amt
     287            self.context.gateway_amt = self.gateway_amt
     288            self.context.r_company = u'remita'
     289        self.amount_auth = int(100 * self.context.amount_auth)
     290        return
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/studentsbrowser.py

    r14805 r15755  
    3434
    3535from kofacustom.nigeria.remita.tests import (
    36     MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID)
     36    MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID, GATEWAY_AMT)
    3737
    3838grok.templatedir('browser_templates')
     
    221221    api_key = API_KEY
    222222    serviceTypeId = SERVICETYPEID
     223    gateway_amt = GATEWAY_AMT
    223224
    224225    #orderId = '3456346346'
     
    243244        if self.context.p_state == 'paid':
    244245            return _("Payment ticket can't be re-sent to Remita.")
     246        if self.context.r_company and self.context.r_company != 'remita':
     247            return _("Payment ticket has been used for another payment gateway.")
    245248        now = datetime.utcnow()
    246249        if self.context.creation_date.tzinfo is not None:
     
    276279        if resp.get('statuscode') not in ('021', '025', '055'):
    277280            return 'RRR generation message from Remita: ' + resp.get('status')
    278         # Already now it becomes a Remita payment
    279         self.context.r_company = u'remita'
    280281        self.rrr = self.context.r_pay_reference = resp['RRR'].rstrip()
    281282        hashargs =      self.merchantId + self.rrr + self.api_key
     
    296297            self.redirect(self.url(self.context, '@@index'))
    297298            return
    298         return
     299        # Already now it becomes a Remita payment. We set the net amount
     300        # and add the gateway amount.
     301        if not self.context.r_company:
     302            self.context.net_amt = self.context.amount_auth
     303            self.context.amount_auth += self.gateway_amt
     304            self.context.gateway_amt = self.gateway_amt
     305            self.context.r_company = u'remita'
     306        self.amount_auth = int(100 * self.context.amount_auth)
     307        return
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py

    r15468 r15755  
    4444API_KEY = '1946'
    4545SERVICETYPEID = '4430731'
     46GATEWAY_AMT = 0.0
    4647
    4748def external_test(func):
     
    8687                lineitems=self.lineitems)
    8788        return resp
     89
     90    def test_dummytest(self):
     91        return
    8892
    8993    @external_test
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/payments.py

    r15730 r15755  
    6464            return None
    6565
    66     @property
    67     def net_amt(self):
    68         return self.amount_auth - self.provider_amt - self.gateway_amt
    69 
    7066NigeriaStudentOnlinePayment = attrs_to_fields(NigeriaStudentOnlinePayment,
    71     omit=['display_item', 'net_amt'])
     67    omit=['display_item',])
    7268
    7369class NigeriaStudentOnlinePaymentFactory(StudentOnlinePaymentFactory):
Note: See TracChangeset for help on using the changeset viewer.