コード例 #1
0
ファイル: views.py プロジェクト: agiliq/django-ogone
def order_status_update(request):
    '''
    Updates the order status with ogone data.
    There are two ways of reaching this flow
    
    - payment redirect (user gets redirected through this flow)
    - ogone server side call (in case of problems ogone will post to our server
    with an updated version ofo the payment status)
    
    For testing order flow updates
    http://localhost:8080/order_status_update/?orderID=12&currency=EUR&amount=680.44&PM=CreditCard&ACCEPTANCE=test123&STATUS=5&CARDNO=XXXXXXXXXXXX1111&ED=0114&CN=thierry&TRXDATE=09/21/10&PAYID=8254874&NCERROR=0&BRAND=VISA&IPCTY=NL&CCCTY=US&ECI=12&CVCCheck=NO&AAVCheck=NO&VC=NO&IP=85.145.6.230&SHASIGN=B02C883D4D31D9665305EA05CC81D3DED7726C68F18C870A8C8F3119DC1B460D9103944692B6E44D47EEA402630770A8122F6D1B7028CC5FD58847DC43D7C082
    '''
    params = request.POST or request.GET
    ogone = Ogone(params)
    
    if ogone.is_valid():
        #update the order data, different for each site
        #need the ogone data and custom logic, use signals for this
        ogone_signals.ogone_update_order.send(sender=Ogone, ogone=ogone)
        
        #redirect to the appropriate view
        order_id = ogone.get_order_id()
        url = '%s?transaction_id=%s' % (reverse('checkout'), order_id)
        
        return HttpResponseRedirect(url)
コード例 #2
0
def order_status_update(request):
    '''
    Updates the order status with ogone data.
    There are two ways of reaching this flow

    - payment redirect (user gets redirected through this flow)
    - ogone server side call (in case of problems ogone will post to our server
    with an updated version ofo the payment status)

    For testing order flow updates
    http://localhost:8080/order_status_update/?orderID=12&currency=EUR&amount=680.44&PM=CreditCard&ACCEPTANCE=test123&STATUS=5&CARDNO=XXXXXXXXXXXX1111&ED=0114&CN=thierry&TRXDATE=09/21/10&PAYID=8254874&NCERROR=0&BRAND=VISA&IPCTY=NL&CCCTY=US&ECI=12&CVCCheck=NO&AAVCheck=NO&VC=NO&IP=85.145.6.230&SHASIGN=B02C883D4D31D9665305EA05CC81D3DED7726C68F18C870A8C8F3119DC1B460D9103944692B6E44D47EEA402630770A8122F6D1B7028CC5FD58847DC43D7C082
    Accented characters with sha1
    http://127.0.0.1:8000/order_status_update/?orderID=44&currency=CHF&amount=10&PM=CreditCard&ACCEPTANCE=test123&STATUS=5&CARDNO=XXXXXXXXXXXX1111&ED=0115&CN=S%E9bastien+Fievet&TRXDATE=11%2F02%2F10&PAYID=8580040&NCERROR=0&BRAND=VISA&IPCTY=CH&CCCTY=US&ECI=7&CVCCheck=NO&AAVCheck=NO&VC=NO&IP=188%2E62%2E236%2E12&SHASIGN=861D83EAC408746F5A7CFA3F5BDD3C7C6C145817
    '''
    # Workaround because Ogone deals with latin1 characters and we want
    # our website to use another ``DEFAULT_CHARSET`` (default: utf8).
    from django.http import QueryDict
    params = QueryDict(request.META['QUERY_STRING'], encoding='latin1')
    # --//--
    ogone = Ogone(params)

    if ogone.is_valid():
        #update the order data, different for each site
        #need the ogone data and custom logic, use signals for this
        ogone_signals.ogone_update_order.send(sender=Ogone, ogone=ogone)

        #redirect to the appropriate view
        order_id = ogone.get_order_id()
        url = reverse('tracking', args=[order_id])

        return HttpResponseRedirect(url)
コード例 #3
0
    def ogone_notify_handler(self, request):
        response = Ogone(request=request, settings=self.settings)
        if response.is_valid():
            fpath = request.get_full_path()
            query_string = fpath.split("?", 1)[1]
            transaction_feedback = query_string.split('&')
            result = {}
            for item in transaction_feedback:
                k, v = item.split("=")
                result[k] = v

            # Default transaction feedback parameters
            status = result.get('STATUS', False)
            orderid = result.get('orderID', '')
            payid = result.get('PAYID', '')
            ncerror = result.get('NCERROR', '')

            amount = result.get('amount', '')
            currency = result.get('currency', '')

            if status and get_status_category(int(status)) == SUCCESS_STATUS:
                ogone_payment_accepted.send(sender=self, order_id=orderid, \
                    amount=amount, currency=currency, pay_id=payid, status=status, ncerror=ncerror)
                return self.ogone_success_handler(
                    request,
                    response=result,
                    description=get_status_description(int(status)))

            if status and get_status_category(int(status)) == CANCEL_STATUS:
                ogone_payment_cancelled.send(sender=self, order_id=orderid, \
                    amount=amount, currency=currency, pay_id=payid, status=status, ncerror=ncerror)
                return self.ogone_cancel_handler(
                    request,
                    response=result,
                    description=get_status_description(int(status)))

            if status and get_status_category(
                    int(status)) == DECLINE_STATUS or EXCEPTION_STATUS:
                ogone_payment_failed.send(sender=self, order_id=orderid, \
                    amount=amount, currency=currency, pay_id=payid, status=status, ncerror=ncerror)
                return self.ogone_failure_handler(
                    request,
                    response=result,
                    description=get_status_description(int(status)))
        else:
            return HttpResponse('signature validation failed!')