Beispiel #1
0
    def _payu_form_get_tx_from_data(self, data):
        """ Given a data dict coming from payu, verify it and find the related
        transaction record. """
        reference = data.get('REFERENCE')
        transaction = self.search([('reference', '=', reference)])

        if not transaction:
            error_msg = (
                _('PayU: received data for reference %s; no order found') %
                (reference))
            raise ValidationError(error_msg)
        elif len(transaction) > 1:
            error_msg = (
                _('PayU: received data for reference %s; multiple orders found'
                  ) % (reference))
            raise ValidationError(error_msg)
        return transaction
 def _check_tipiregie_activation_mode(self):
     self.ensure_one()
     if self.provider == 'tipiregie' and self.tipiregie_activation_mode and (
             not self.website_published
             or self.environment not in ['test']):
         raise ValidationError(
             _("TipiRégie: activation mode can be activate in test environment only and if "
               "the payment acquirer is published on the website."))
Beispiel #3
0
    def _marketpay_form_get_tx_from_data(self, data):
        """ Given a data dict coming from redsys, verify it and
        find the related transaction record. """

        print("form get ###################")

        parameters = data.get('Ds_MerchantParameters', '')
        parameters_dic = json.loads(base64.b64decode(parameters).decode())
        reference = urllib.parse.unquote(parameters_dic.get('Ds_Order', ''))
        pay_id = parameters_dic.get('Ds_AuthorisationCode')
        shasign = data.get('Ds_Signature', '').replace('_',
                                                       '/').replace('-', '+')
        test_env = http.request.session.get('test_enable', False)
        if not reference or not pay_id or not shasign:
            error_msg = 'Redsys: received data with missing reference' \
                        ' (%s) or pay_id (%s) or shashign (%s)' % (reference,
                                                                   pay_id, shasign)
            if not test_env:
                _logger.info(error_msg)
                raise ValidationError(error_msg)
            # For tests
            http.OpenERPSession.tx_error = True
        tx = self.search([('reference', '=', reference)])
        if not tx or len(tx) > 1:
            error_msg = 'Redsys: received data for reference %s' % (reference)
            if not tx:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            if not test_env:
                _logger.info(error_msg)
                raise ValidationError(error_msg)
            # For tests
            http.OpenERPSession.tx_error = True
        if tx and not test_env:
            # verify shasign
            shasign_check = tx.acquirer_id.sign_parameters(
                tx.acquirer_id.marketpay_secret_key, parameters)
            if shasign_check != shasign:
                error_msg = (
                    'Redsys: invalid shasign, received %s, computed %s, '
                    'for data %s' % (shasign, shasign_check, data))
                _logger.info(error_msg)
                raise ValidationError(error_msg)
        return tx
    def _tipiregie_check_web_service(self):
        self.ensure_one()

        soap_url = self._get_soap_url()
        soap_body = """
                    <soapenv:Envelope %s %s>
                       <soapenv:Header/>
                       <soapenv:Body>
                          <pai:recupererDetailClient>
                             <arg0>
                                <numCli>%s</numCli>
                             </arg0>
                          </pai:recupererDetailClient>
                       </soapenv:Body>
                    </soapenv:Envelope>
                    """ % (
            'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"',
            'xmlns:pai="http://securite.service.tpa.cp.finances.gouv.fr/services/mas_securite/'
            'contrat_paiement_securise/PaiementSecuriseService"',
            self.tipiregie_customer_number)

        try:
            soap_response = requests.post(soap_url,
                                          data=soap_body,
                                          headers={'content-type': 'text/xml'})
            root = ElementTree.fromstring(soap_response.content)
            fault = root.find(
                './/S:Fault',
                {'S': 'http://schemas.xmlsoap.org/soap/envelope/'})

            if fault is not None:
                error = _(
                    "It would appear that the customer number entered is not valid or that the Tipi Régie"
                    " contract is not properly configured.")
                error_desc = fault.find('.//descriptif')
                if error_desc is not None:
                    error += _(
                        "Tipi server returned the following error: \"%s\""
                    ) % error_desc.text
                raise ValidationError(error)
        except ConnectionError as e:
            raise ValidationError(
                _("It seems that the connection to the web service Tipi Régie is impossible.\n"
                  "%s\n\n"
                  "%s") % (self._get_soap_url(), e.message))
Beispiel #5
0
    def _weixin_form_get_tx_from_data(self, data):
        reference, txn_id = data.get('transaction_id'), data.get(
            'out_trade_no')
        if not reference or not txn_id:
            error_msg = 'weixin: received data with missing reference (%s) or txn_id (%s)' % (
                reference, txn_id)
            raise ValidationError(error_msg)

        # find tx -> @TDENOTE use txn_id ?
        tx_ids = self.search([('reference', '=', txn_id)])
        if not tx_ids or len(tx_ids) > 1:
            error_msg = 'weixin: received data for reference %s' % (reference)
            if not tx_ids:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            raise ValidationError(error_msg)
        return tx_ids[0]
Beispiel #6
0
 def _authorize_form_get_tx_from_data(self, data):
     """ Given a data dict coming from authorize, verify it and find the related
     transaction record. """
     reference, trans_id, fingerprint = data.get('x_invoice_num'), data.get('x_trans_id'), data.get('x_SHA2_Hash') or data.get('x_MD5_Hash')
     if not reference or not trans_id or not fingerprint:
         error_msg = _('Authorize: received data with missing reference (%s) or trans_id (%s) or fingerprint (%s)') % (reference, trans_id, fingerprint)
         _logger.info(error_msg)
         raise ValidationError(error_msg)
     tx = self.search([('reference', '=', reference)])
     if not tx or len(tx) > 1:
         error_msg = 'Authorize: received data for reference %s' % (reference)
         if not tx:
             error_msg += '; no order found'
         else:
             error_msg += '; multiple order found'
         _logger.info(error_msg)
         raise ValidationError(error_msg)
     return tx[0]
Beispiel #7
0
 def _paytm_form_get_tx_from_data(self, data):
     """ Given a data dict coming from Paytm, verify it and find the related
         transaction record. """
     reference = data.get('ORDERID')
     if not reference:
         raise ValidationError(
             _('Paytm: received data with missing reference (%s)') %
             (reference))
     transaction = self.search([('reference', '=', reference)])
     if not transaction or len(transaction) > 1:
         error_msg = _('Paytm: received data for reference %s') % (
             reference)
         if not transaction:
             error_msg += _('; no order found')
         else:
             error_msg += _('; multiple order found')
         raise ValidationError(error_msg)
     return transaction
    def _multisafepay_form_get_tx_from_data(self, data):
        multisafepay_order_id = data.get('transactionid')
        if multisafepay_order_id is None:
            raise ValidationError('Invalid transaction id')

        reference = multisafepay_order_id.split('_')[0]
        tx = self.search([('reference', '=', reference)])

        if not tx or len(tx) > 1:
            error_msg = _('received data for reference %s') % (
                pprint.pformat(reference))
            if not tx:
                error_msg += _('; no order found')
            else:
                error_msg += _('; multiple order found')
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return tx
    def _tipiregie_form_get_tx_from_data(self, data):
        reference = data.get('objet').replace('  slash  ', '/')
        if not reference:
            error_msg = _('Tipi Regie: received data with missing reference (%s)') % reference
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        # find tx -> @TDENOTE use txn_id ?
        txs = self.env['payment.transaction'].sudo().search([('reference', '=', reference)])
        if not txs or len(txs) > 1:
            error_msg = 'Tipi Regie: received data for reference %s' % reference
            if not txs:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.error(error_msg)
            raise ValidationError(error_msg)
        return txs[0]
Beispiel #10
0
    def _square_form_get_tx_from_data(self, data):
        reference = data.get('reference_id') or data.get('referenceId')
        if not reference:
            error_msg = 'Square: received data with missing reference (%s)' % (
                reference)
            _logger.error(error_msg)
            raise ValidationError(error_msg)

        tx = self.search([('reference', '=', reference)])
        if not tx or len(tx) > 1:
            error_msg = 'Square: received data for reference %s' % reference
            if not tx:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return tx[0]
Beispiel #11
0
    def _paypal_form_get_tx_from_data(self, data):
        reference, txn_id = data.get('item_number'), data.get('txn_id')
        if not reference or not txn_id:
            error_msg = _('Paypal: received data with missing reference (%s) or txn_id (%s)') % (reference, txn_id)
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        # find tx -> @TDENOTE use txn_id ?
        txs = self.env['payment.transaction'].search([('reference', '=', reference)])
        if not txs or len(txs) > 1:
            error_msg = 'Paypal: received data for reference %s' % (reference)
            if not txs:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return txs[0]
Beispiel #12
0
 def _stripe_form_get_tx_from_data(self, data):
     """ Given a data dict coming from stripe, verify it and find the related
     transaction record. """
     reference = data['metadata']['reference']
     if not reference:
         error_msg = _('Stripe: invalid reply received from provider, missing reference')
         _logger.error(error_msg, data['metadata'])
         raise ValidationError(error_msg)
     tx = self.search([('reference', '=', reference)])
     if not tx:
         error_msg = (_('Stripe: no order found for reference %s') % reference)
         _logger.error(error_msg)
         raise ValidationError(error_msg)
     elif len(tx) > 1:
         error_msg = (_('Stripe: %s orders found for reference %s') % (len(tx), reference))
         _logger.error(error_msg)
         raise ValidationError(error_msg)
     return tx[0]
Beispiel #13
0
 def _redsys_form_get_tx_from_data(self, data):
     """ Given a data dict coming from redsys, verify it and
     find the related transaction record. """
     parameters = data.get("Ds_MerchantParameters", "")
     parameters_dic = json.loads(base64.b64decode(parameters).decode())
     reference = urllib.parse.unquote(parameters_dic.get("Ds_Order", ""))
     pay_id = parameters_dic.get("Ds_AuthorisationCode")
     shasign = data.get("Ds_Signature", "").replace("_", "/").replace("-", "+")
     test_env = config["test_enable"]
     if not reference or not pay_id or not shasign:
         error_msg = (
             "Redsys: received data with missing reference"
             " (%s) or pay_id (%s) or shashign (%s)" % (reference, pay_id, shasign)
         )
         if not test_env:
             _logger.error(error_msg)
             raise ValidationError(error_msg)
         # For tests
         http.OpenERPSession.tx_error = True
     tx = self.search([("reference", "=", reference)])
     if not tx or len(tx) > 1:
         error_msg = "Redsys: received data for reference %s" % (reference)
         if not tx:
             error_msg += "; no order found"
         else:
             error_msg += "; multiple order found"
         if not test_env:
             _logger.error(error_msg)
             raise ValidationError(error_msg)
         # For tests
         http.OpenERPSession.tx_error = True
     if tx and not test_env:
         # verify shasign
         shasign_check = tx.acquirer_id.sign_parameters(
             tx.acquirer_id.redsys_secret_key, parameters
         )
         if shasign_check != shasign:
             error_msg = (
                 "Redsys: invalid shasign, received %s, computed %s, "
                 "for data %s" % (shasign, shasign_check, data)
             )
             _logger.error(error_msg)
             raise ValidationError(error_msg)
     return tx
Beispiel #14
0
    def _ogone_form_get_tx_from_data(self, data):
        """ Given a data dict coming from ogone, verify it and find the related
        transaction record. Create a payment token if an alias is returned."""
        reference, pay_id, shasign, alias = data.get('orderID'), data.get('PAYID'), data.get('SHASIGN'), data.get('ALIAS')
        if not reference or not pay_id or not shasign:
            error_msg = _('Ogone: received data with missing reference (%s) or pay_id (%s) or shasign (%s)') % (reference, pay_id, shasign)
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        # find tx -> @TDENOTE use paytid ?
        tx = self.search([('reference', '=', reference)])
        if not tx or len(tx) > 1:
            error_msg = _('Ogone: received data for reference %s') % (reference)
            if not tx:
                error_msg += _('; no order found')
            else:
                error_msg += _('; multiple order found')
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        # verify shasign
        shasign_check = tx.acquirer_id._ogone_generate_shasign('out', data)
        if shasign_check.upper() != shasign.upper():
            error_msg = _('Ogone: invalid shasign, received %s, computed %s, for data %s') % (shasign, shasign_check, data)
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        if not tx.acquirer_reference:
            tx.acquirer_reference = pay_id

        # alias was created on ogone server, store it
        if alias:
            Method = self.env['payment.token']
            domain = [('acquirer_ref', '=', alias)]
            cardholder = data.get('CN')
            if not Method.search_count(domain):
                _logger.info('Ogone: saving alias %s for partner %s' % (data.get('CARDNO'), tx.partner_id))
                ref = Method.create({'name': data.get('CARDNO') + (' - ' + cardholder if cardholder else ''),
                                     'partner_id': tx.partner_id.id,
                                     'acquirer_id': tx.acquirer_id.id,
                                     'acquirer_ref': alias})
                tx.write({'payment_token_id': ref})

        return tx
Beispiel #15
0
    def weixin_form_generate_values(self, tx_values):
        self.ensure_one()
        base_url = self.env['ir.config_parameter'].get_param('web.base.url')
        amount = int(tx_values.get('amount', 0) * 100)
        nonce_str = self.random_generator()
        data_post = {}
        now_time = time.strftime('%Y%m%d%H%M%S')
        data_post.update({
            'appid':
            self.weixin_appid,
            'body':
            tx_values['reference'],
            'mch_id':
            self.weixin_mch_id,
            'nonce_str':
            nonce_str,
            'notify_url':
            '%s' % urlparse.urljoin(base_url, WeixinController._notify_url),
            'out_trade_no':
            now_time,
            'spbill_create_ip':
            self._get_ipaddress(),
            'total_fee':
            amount,
            'trade_type':
            'NATIVE',
        })

        _, prestr = util.params_filter(data_post)
        sign = util.build_mysign(prestr, self.weixin_key, 'MD5')
        data_post['sign'] = sign
        # payid=self.env['payment.transaction'].search([('create_uid','=',self.env.uid),('state','=','draft'),('acquirer_id','=',self.id)])
        # for payid in payid:
        #     payid.acquirer_reference=data_post['out_trade_no']

        data_xml = "<xml>" + self.json2xml(data_post) + "</xml>"
        url = self._get_weixin_urls(self.environment)['weixin_url']
        request = urllib2.Request(url, data_xml)
        result = self._try_url(request, tries=3)
        data_post.update({
            'data_xml': data_xml,
        })
        return_xml = etree.fromstring(result)
        if return_xml.find(
                'return_code'
        ).text == "SUCCESS" and return_xml.find('code_url').text != False:
            qrcode = return_xml.find('code_url').text
            data_post.update({
                'qrcode': qrcode,
            })
        else:
            return_code = return_xml.find('return_code').text
            return_msg = return_xml.find('return_msg').text
            raise ValidationError("%s, %s" % (return_code, return_msg))
        tx_values = data_post
        return tx_values
Beispiel #16
0
    def _alipay_form_get_tx_from_data(self, data):
        reference, txn_id = data.get('out_trade_no'), data.get('trade_no')
        if not reference or not txn_id:
            error_msg = 'Alipay: received data with missing reference (%s) or txn_id (%s)' % (
                reference, txn_id)
            _logger.error(error_msg)
            raise ValidationError(error_msg)

        tx = self.env['payment.transaction'].search([('reference', '=',
                                                      reference)])
        if not tx or len(tx) > 1:
            error_msg = 'Alipay: received data for reference %s' % (reference)
            if not tx:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.error(error_msg)
            raise ValidationError(error_msg)
        return tx
    def _get_hesabe_form_generate_values(self, values):
        self.ensure_one()
        base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
        payload = {
            "merchantCode": self.merchant_code,
            "currency": values['currency'] and values['currency'].name or '',
            "amount": values['amount'],
            "responseUrl": urls.url_join(base_url, '/payment/hesabe/%s/return' % ('knet' if self.provider == 'hesabe_knet' else 'mpgs')),
            "paymentType": 1 if self.provider == 'hesabe_knet' else 2,
            "version": self.api_version,
            "orderReferenceNumber": values['reference'],
            "failureUrl": urls.url_join(base_url, '/payment/hesabe/%s/fail' % ('knet' if self.provider == 'hesabe_knet' else 'mpgs')),
            # Add more variables here
            # "variable1": values['reference'],
            # Use to compare with response value amount
            "variable2": values['amount'],
            # "variable3": values['reference'],
            # "variable4": values['reference'],
            # "variable5": values['reference'],
        }

        url = self._get_hesabe_urls(self.state)['hesabe_form_url']

        encryptedText = encrypt(str(json.dumps(payload)), self.secret_key, self.iv_key)
        checkoutToken = checkout(encryptedText, url, self.access_code, 'production' if self.state == 'enabled' else 'test')
        if '"status":false' in checkoutToken:
            raise ValidationError(_("This Merchant doesn't support this payment method!"))
        else:
            result = decrypt(checkoutToken, self.secret_key, self.iv_key)
            if '"status":false' in result:
                raise ValidationError(
                    _("Service Unavailable: We are sorry the service is not available for this account. Please contact the business team for further information."))
            response = json.loads(result)
            decryptToken = response['response']['data']
            if decryptToken != '':
                url = urls.url_join(url, "/payment?data=%s" % (decryptToken))
            else:
                url = "/shop"

        vals = {
            'form_url': url
        }
        return vals
Beispiel #18
0
 def _paygate_form_get_tx_from_data(self, data=None):
     if not data:
         data = {}
     ref = data.get('REFERENCE')
     tx = self.search([('reference', '=', ref)])
     if not tx or len(tx) > 1:
         error_msg = _('received data for reference %s') % (ref)
         if not tx:
             error_msg += _('; no order found')
         else:
             error_msg += _('; multiple order found')
         _logger.info(error_msg)
         raise ValidationError(error_msg)
     if data.get('CHECKSUM'):
         is_valid, _ = validate_checksum(data)
         if not is_valid:
             error_msg = _('Transaction has been tempered. wrong checksum')
             raise ValidationError(error_msg)
         return tx
Beispiel #19
0
    def _paymaya_form_get_tx_from_data(self, data):

        reference = data.get('reference')

        transaction = self.search([('reference', '=', reference)])

        if not transaction:
            error_msg = (
                _('PayMaya: received data for reference %s; no order found') %
                (reference))
            raise ValidationError(error_msg)

        elif len(transaction) > 1:
            error_msg = (_(
                'PayMaya: received data for reference %s; multiple orders found'
            ) % (reference))
            raise ValidationError(error_msg)

        return transaction
Beispiel #20
0
    def _mesomb_form_get_tx_from_data(self, data):
        reference = data.get('reference')
        if not reference:
            error_msg = _('MeSomb: received data with missing reference (%s) '
                          ) % reference
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        txs = self.env['payment.transaction'].search([('reference', '=',
                                                       reference)])
        if not txs or len(txs) > 1:
            error_msg = 'MeSomb: received data for reference %s' % reference
            if not txs:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return txs[0]
Beispiel #21
0
    def _iqcn_form_get_tx_from_data(self, data):
        reference = data.get('payment_id')
        if not reference:
            error_msg = _('ICQN: received data with missing reference (%s)'
                          ) % (reference, )
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        txs = self.env['payment.transaction'].search([('acquirer_reference',
                                                       '=', reference)])
        if not txs or len(txs) > 1:
            error_msg = 'ICQN: received data for reference %s' % (reference)
            if not txs:
                error_msg += '; no transaction found'
            else:
                error_msg += '; multiple transactions found'
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return txs[0]
Beispiel #22
0
    def _todopago_form_get_tx_from_data(self, data):
        Answer = data.get('Answer')
        reference = data.get('OPERATIONID')
        if not reference:
            error_msg = (
                'TodoPago: received data with missing reference (%s) or '
                'collection_id (%s)' % (Answer, reference))
            _logger.error(error_msg)
            raise ValidationError(error_msg)
        transaction = self.search([('reference', '=', reference)], limit=1)

        if not transaction:
            error_msg = (
                'TodoPago: received data for reference %s; no order found' %
                (reference))
            _logger.error(error_msg)
            raise ValidationError(error_msg)
        transaction.todopago_Answer = Answer
        return transaction
Beispiel #23
0
    def _weaccept_form_get_tx_from_data(self, data):
        orderid, amount_cents = data.get('merchant_order_id'), data.get('amount_cents')
        amount = '{:,.2f}'.format(int(amount_cents)/100.0)

        merchant_id, response_code = data.get('profile_id'), data.get('txn_response_code')
        if not orderid or not amount or not merchant_id or not response_code:
            error_msg = _(
                'WeAccept: Received data with missing orderid (%s) or amount (%s) or merchantcode (%s)'
            ) % (orderid, amount, merchant_id)
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        tx = self.search([('reference', '=', orderid)])
        if not tx:
            order_id = self.env['sale.order'].search([('name', '=', orderid)]).id
            tx = self.search([('sale_order_ids', 'in', [order_id])], order="id DESC", limit=1)

        if not tx or len(tx) > 1:
            error_msg = _('WeAccept: Received data for Orderid %s') % (orderid)
            if not tx:
                error_msg += _('No order found.')
            else:
                error_msg += _('Multiple order found.')
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        if response_code == 'APPROVED' or response_code == '0':
            _logger.info('WeAccept: Payment revalidated Successfully.')
            tx.write({
                'weaccept_order_no': data.get('order'),
                'weaccept_sub_type': data.get('source_data.sub_type'),
                'weaccept_type': data.get('source_data.type'),
                'weaccept_hmac': data.get('hmac'),
                'weaccept_currency': data.get('currency'),
                'weaccept_amount_cents': data.get('amount_cents'),
                'weaccept_message': data.get('data.message'),
            })
        else:
            error_msg = _('WeAccept: Payment revalidated failed.')
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return tx
    def refund_payment(self, amount=None):
        if not self.stripe_checkout_payment_intent:
            raise ValidationError(
                _('Only transactions having the acquirer reference can be refund.'
                  ))

        if not amount:
            amount = self.amount
        amount = int(amount if str(self.currency_id.name) in
                     ZERO_DECIMAL_CURRENCIES else float_round(amount * 100, 2))
        res = self.acquirer_id._stripe_call(method='_refunds',
                                            operation='create',
                                            **{
                                                'charge':
                                                self.acquirer_reference,
                                                'amount': amount
                                            })
        if not res['status']:
            raise ValidationError(res['message'])
        return res
Beispiel #25
0
    def _dotpay_form_get_tx_from_data(self, data):
        status = data.get('operation_status')
        control=data.get('control')
        try:
            partner_id=int(control)
        except:
            partner_id=0
        if partner_id>0:
            transaction = self.search([('partner_id', '=', partner_id),('state','=','draft')])
        else:
            transaction = self.search([('reference', '=', control)])
        if not transaction:
            error_msg = (_('Dotpay: received data for reference %s no order found') % (partner_id))
            raise ValidationError(error_msg)
#            return self #
        elif len(transaction) > 1:
            error_msg = (_('Dotpay: received data for reference %s multiple orders found') % (partner_id))
            raise ValidationError(error_msg)
#            return self #
        return transaction
Beispiel #26
0
 def flow_form_feedback(self, acquirer_id=None, **post):
     _logger.warning("post %s, acquirer_id %s" % (post, acquirer_id))
     if not acquirer_id:
         return
     tx_data = acquirer_id.flow_getTransaction(post)
     tx_data._token = post['token']
     res = request.env['payment.transaction'].sudo().form_feedback(
         tx_data, 'flow')
     if not res:
         raise ValidationError("Transacción no esperada")
     return werkzeug.utils.redirect('/payment/process')
Beispiel #27
0
    def _pagadito_form_get_tx_from_data(self, data):
        if not data.get('token'):
            error_msg = _('Pagadito: received data with missing token')
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        # find tx -> @TDENOTE use txn_id ?
        txs = self.env['payment.transaction'].search([
            ('pagadito_txn_token', '=', data.get('token'))
        ])
        if not txs or len(txs) > 1:
            error_msg = 'Pagadito: received data for reference %s' % (
                txs.reference)
            if not txs:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return txs[0]
Beispiel #28
0
    def _payulatam_form_get_tx_from_data(self, data):
        """ Given a data dict coming from payulatam, verify it and find the related
        transaction record. """
        reference, txnid, sign = data.get('referenceCode'), data.get('transactionId'), data.get('signature')
        if not reference or not txnid or not sign:
            raise ValidationError(_('PayU Latam: received data with missing reference (%s) or transaction id (%s) or sign (%s)') % (reference, txnid, sign))

        transaction = self.search([('reference', '=', reference)])

        if not transaction:
            error_msg = (_('PayU Latam: received data for reference %s; no order found') % (reference))
            raise ValidationError(error_msg)
        elif len(transaction) > 1:
            error_msg = (_('PayU Latam: received data for reference %s; multiple orders found') % (reference))
            raise ValidationError(error_msg)

        # verify shasign
        sign_check = transaction.acquirer_id._payulatam_generate_sign('out', data)
        if sign_check.upper() != sign.upper():
            raise ValidationError(('PayU Latam: invalid sign, received %s, computed %s, for data %s') % (sign, sign_check, data))
        return transaction
Beispiel #29
0
    def _cointopay_form_get_tx_from_data(self, data):
        """ Given a data dict coming from cointopay, verify it and find the related
        transaction record. """
        origin_data = dict(data)
        reference = data.get('CustomerReferenceNr')
        transaction_id = data.get('TransactionID')

        transaction = self.search([('reference', '=', reference)])

        if not transaction:
            error_msg = (
                _('Cointopay: received data for reference %s; no order found')
                % reference)
            raise ValidationError(error_msg)
        elif len(transaction) > 1:
            error_msg = (_(
                'Cointopay: received data for reference %s; multiple orders found'
            ) % reference)
            raise ValidationError(error_msg)

        return transaction
Beispiel #30
0
    def _paytm_payment_form_get_tx_from_data(self, data):
        """ Verify the validity of data coming from paytm """
        reference = data.get('ORDERID')
        if not reference:
            error_msg = _('paytm: received data with missing reference (%s)'
                          ) % (reference)
            _logger.info(error_msg)
            raise ValidationError(error_msg)

        # find tx -> @TDENOTE use txn_id ?
        tx_ids = self.env['payment.transaction'].search([('reference', '=',
                                                          reference)])
        if not tx_ids or len(tx_ids) > 1:
            error_msg = 'Paytm: received data for reference %s' % (reference)
            if not tx_ids:
                error_msg += '; no order found'
            else:
                error_msg += '; multiple order found'
            _logger.info(error_msg)
            raise ValidationError(error_msg)
        return tx_ids[0]