Exemple #1
0
def process_credit_card(request):
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            paypal_provider = get_gateway("pay_pal")
            cc = CreditCard(first_name=form.cleaned_data['first_name'],
                            last_name=form.cleaned_data['last_name'],
                            month=form.cleaned_data['month'],
                            year=form.cleaned_data['year'],
                            number=form.cleaned_data['number'],
                            verification_value=form.cleaned_data['verify_val'])
            basket = Basket.objects.get(user=request.user)
            total_price = get_total_price(basket, request)
            paypal_provider.purchase(total_price,
                                     cc,
                                     options={"request": request})
            #  PayPalFailure('Security header is not valid')
            current_user = request.user.customer
            for item in basket.basket_items.all():
                current_user.items_history.add(item)
            basket.basket_items.clear()
            current_user.discounts.clear()
    return render(request,
                  "basket/payment_done.html",
                  {"success": "Successfully purchased!"})
Exemple #2
0
 def update_status(self):
     # Updating transaction status
     payzone_gt = get_gateway('payzone')
     transaction_status = payzone_gt.payzone.transaction.status(
         self.merchant_token
     )
     self.status = transaction_status['status'].lower()
     self.transaction_id = transaction_status['transactionID']
     self.save()
Exemple #3
0
    def test_purchase_fail(self):
        received_signals = []
        def receive(sender, **kwargs):
            received_signals.append(kwargs.get("signal"))
        transaction_was_unsuccessful.connect(receive)

        gateway = get_gateway('global_iris')
        card = self.get_visa_card()
        gateway.validate_card(card)
        response = gateway.purchase(Decimal("45.00"), card, options={'order_id': 1})
        # Difficult to test success, because we need dummy card numbers etc.
        # But we can at least test we aren't getting exceptions.
        self.assertEqual(response['status'], 'FAILURE')

        self.assertEqual(received_signals, [transaction_was_unsuccessful])
Exemple #4
0
    def test_purchase_fail(self):
        received_signals = []
        def receive(sender, **kwargs):
            received_signals.append(kwargs.get("signal"))
        transaction_was_unsuccessful.connect(receive)

        gateway = get_gateway('global_iris')
        card = self.get_visa_card()
        gateway.validate_card(card)
        response = gateway.purchase(Decimal("45.00"), card, options={'order_id': 1})
        # Difficult to test success, because we need dummy card numbers etc.
        # But we can at least test we aren't getting exceptions.
        self.assertEqual(response['status'], 'FAILURE')

        self.assertEqual(received_signals, [transaction_was_unsuccessful])
Exemple #5
0
def process_credit_card(request):
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            paypal_provider = get_gateway("pay_pal")
            cc = CreditCard(first_name=form.cleaned_data['first_name'],
                            last_name=form.cleaned_data['last_name'],
                            month=form.cleaned_data['month'],
                            year=form.cleaned_data['year'],
                            number=form.cleaned_data['number'],
                            verification_value=form.cleaned_data['verify_val'])
            basket = Basket.objects.get(user=request.user)
            total_price = get_total_price(basket, request)
            paypal_provider.purchase(total_price,
                                     cc,
                                     options={"request": request})
            #  PayPalFailure('Security header is not valid')
            current_user = request.user.customer
            for item in basket.basket_items.all():
                current_user.items_history.add(item)
            basket.basket_items.clear()
            current_user.discounts.clear()
    return render(request, "basket/payment_done.html",
                  {"success": "Successfully purchased!"})