Esempio n. 1
0
    def capture_payment(self, testing=False, order=None, amount=NOTSET):
        """process the transaction through tclink"""
        if not order:
            order = self.order

        if amount == NOTSET:
            amount = order.balance

        self.prepare_post(order, amount)

        result = tclink.send(self.transactionData)
        status = result ['status']
        payment = None
        success = False
        
        if status == 'approved':
            payment = self.record_payment(order=order, amount=amount, 
                transaction_id="", reason_code=status)
            success = True
            msg = unicode(result)

        if status == 'decline':
            msg = _(u'Transaction was declined.  Reason: %s' % result['declinetype'])

        if status == 'baddata':
            msg = _(u'Improperly formatted data. Offending fields: %s' % result['offenders'])

        else:
            msg = _(u'An error occurred: %s' % result['errortype'])

        return ProcessorResult(self.key, success, msg, payment=payment)
Esempio n. 2
0
def transact(ccnum, exprdate, amount):
    """
    ccnum: str
    exprdate: str
    amount: Decimal
    """
    amount = str((amount * 100).to_integral())
    import tclink
    params = {
        'custid':    'TestMerchant',
        'password':  '******',
        'action':    'sale',
        'cc':        ccnum,
        'exp':       exprdate,
        'amount':    amount,
        'avs':       'n'
    }
    result = tclink.send(params)
    if result['status'] == 'approved':
        status = True
        message = 'Success'
    else:
        status = False
        message = 'Failure'
    transid = result['transid']
    transdata = str(result)
    return status, transid, transdata, message
    def capture_payment(self):
        """
        process the transaction through tclink
        """

        if self.order:
            self.prepare_post()
            result = tclink.send(self.transactionData)
            status = result['status']
            success = False

            if status == 'approved' or status == 'accepted':
                success = True
                msg = result
            else:
                if status == 'decline':
                    msg = result['declinetype']
                elif status == 'baddata':
                    #msg = result['offenders']
                    msg = result
                elif status == 'error':
                    msg = result['errortype']
                else:
                    status = "error"
                    msg = 'An error occurred: %s' % result

            self.status = status
            self.success = success
            self.msg = msg

        return self
Esempio n. 4
0
    def capture_payment(self, testing=False, order=None, amount=None):
        """process the transaction through tclink"""
        if not order:
            order = self.order

        if amount is None:
            amount = order.balance

        if order.paid_in_full:
            self.log_extra('%s is paid in full, no capture attempted.', order)
            self.record_payment()
            return ProcessorResult(self.key, True,
                                   _("No charge needed, paid in full."))

        self.log_extra('Capturing payment for %s', order)

        self.prepare_post(order, amount)

        result = tclink.send(self.transactionData)
        status = result['status']
        payment = None
        success = False

        if status == 'approved':
            payment = self.record_payment(order=order,
                                          amount=amount,
                                          transaction_id="",
                                          reason_code=status)
            success = True
            msg = unicode(result)

        else:
            if status == 'decline':
                msg = _(u'Transaction was declined.  Reason: %s' %
                        result['declinetype'])
                failmsg = u'Transaction was declined.  Reason: %s' % result[
                    'declinetype']

            elif status == 'baddata':
                msg = _(u'Improperly formatted data. Offending fields: %s' %
                        result['offenders'])
                failmsg = u'Improperly formatted data. Offending fields: %s' % result[
                    'offenders']

            else:
                status = "error"
                msg = _(u'An error occurred: %s' % result['errortype'])
                failmsg = u'An error occurred: %s' % result['errortype']

            payment = self.record_failure(order=order,
                                          amount=amount,
                                          transaction_id="",
                                          reason_code=status,
                                          details=failmsg)

        return ProcessorResult(self.key, success, msg, payment=payment)
Esempio n. 5
0
    def get_context_data(self):
        order = Order.objects.get(id=self.request.POST.get('order_id'))
        result = tclink.send(prepere_payment_information(order,
                                        self.request.session['payment_data']))

        del self.request.session['payment_data']

        status = result['status']

        if status == 'approved':
            order.confirm()
            Cart.objects.remove_cart_from_session(self.request)
            return {'order': order}

        self.template_name = 'payment_error.html'
        return {'message': get_error_message(result)}
Esempio n. 6
0
 def process(self):
     # process the transaction through tclink
     result = tclink.send(self.transactionData)
     status = result ['status']
     if status == 'approved':
         record_payment(self.order, self.settings, amount=self.order.balance)
         return (True, status, result)
     if status == 'decline':
         msg = _(u'Transaction was declined.  Reason: %s' % result['declinetype'])
         return (False, status, msg)
     if status == 'baddata':
         msg = _(u'Improperly formatted data. Offending fields: %s' % result['offenders'])
         return (False, status, msg)
     else:
         msg = _(u'An error occurred: %s' % result['errortype'])
         return (False, status, msg)
Esempio n. 7
0
 def process(self):
     # process thre transaction through tclink
     result = tclink.send (self.transactionData)
     status = result ['status']
     if status == 'approved':
         self.order.order_success()
         return (True, status, result)
     if status == 'decline':
         msg = _(u'Transaction was declined.  Reason: %s' % result['declinetype'])
         return (False, status, msg)
     if status == 'baddata':
         msg = _(u'Improperly formatted data. Offending fields: %s' % result['offenders'])
         return (False, status, msg)
     else:
         msg = _(u'An error occurred: %s' % result['errortype'])
         return (False, status, msg)
Esempio n. 8
0
    def capture_payment(self, testing=False, order=None, amount=None):
        """process the transaction through tclink"""
        if not order:
            order = self.order

        if amount is None:
            amount = order.balance

        if order.paid_in_full:
            self.log_extra('%s is paid in full, no capture attempted.', order)
            self.record_payment()
            return ProcessorResult(self.key, True, _("No charge needed, paid in full."))

        self.log_extra('Capturing payment for %s', order)

        self.prepare_post(order, amount)

        result = tclink.send(self.transactionData)
        status = result ['status']
        payment = None
        success = False

        if status == 'approved':
            payment = self.record_payment(order=order, amount=amount,
                transaction_id="", reason_code=status)
            success = True
            msg = unicode(result)

        else:
            if status == 'decline':
                msg = _(u'Transaction was declined.  Reason: %s' % result['declinetype'])
                failmsg = u'Transaction was declined.  Reason: %s' % result['declinetype']

            elif status == 'baddata':
                msg = _(u'Improperly formatted data. Offending fields: %s' % result['offenders'])
                failmsg = u'Improperly formatted data. Offending fields: %s' % result['offenders']

            else:
                status = "error"
                msg = _(u'An error occurred: %s' % result['errortype'])
                failmsg = u'An error occurred: %s' % result['errortype']

            payment = self.record_failure(order=order, amount=amount,
                transaction_id="", reason_code=status,
                details=failmsg)

        return ProcessorResult(self.key, success, msg, payment=payment)