예제 #1
0
def paypal(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("pay_pal")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            # response = merchant.purchase(amount, credit_card, options={'request': request})
            response = merchant.recurring(amount, credit_card, options={'request': request})
    else:
        form = CreditCardForm(initial={'number': '4797503429879309',
                                       'verification_value': '037',
                                       'month': 1,
                                       'year': 2019,
                                       'card_type': 'visa'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Paypal'})
예제 #2
0
def stripepayment(request, campaign_id):
    campaign_obj = get_object_or_404(Campaign, pk=campaign_id)
    amount = int(campaign_obj.target_amount)
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        # import ipdb; ipdb.set_trace()
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("stripe")
            response = merchant.purchase(amount, credit_card)
            response_dict = {}
            response_dict.update({'status': response['status']})
            response_dict.update(response['response'])
            del response_dict['card']
            response_dict.update(response['response']['card'])
            request.session['response'] = response_dict
            return HttpResponseRedirect(
                reverse('paygate:payment_success', args=[campaign_id]))
    else:
        form = CreditCardForm(initial={'number': '4242424242424242'})
    return render_to_response('payment/stripe_payment_form.html', {
        'form': form,
        'campaign': campaign_obj
    },
                              context_instance=RequestContext(request))
예제 #3
0
def beanstream(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("beanstream")
            response = merchant.purchase(amount, credit_card,
                                         {"billing_address": {
                        "name": "%s %s" % (data["first_name"], data["last_name"]),
                        # below are hardcoded just for the sake of the example
                        # you can make these optional by toggling the customer name
                        # and address in the account dashboard.
                        "email": "*****@*****.**",
                        "phone": "555-555-555-555",
                        "address1": "Addr1",
                        "address2": "Addr2",
                        "city": "Hyd",
                        "state": "AP",
                        "country": "IN"
                        }
                                          })
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['beanstream'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount': amount,
                                             'response': response,
                                             'title': 'Beanstream'})
 def setUp(self):
     self.merchant = get_gateway("braintree_payments")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2020,
                                   number="4111111111111111",
                                   verification_value="100")
 def testCreditCardExpired(self):
     credit_card = CreditCard(first_name="Test", last_name="User",
                              month=10, year=2011,
                              number="4000111111111115",
                              verification_value="100")
     resp = self.merchant.purchase(2004, credit_card)
     self.assertNotEquals(resp["status"], "SUCCESS")
예제 #6
0
 def setUp(self):
     self.merchant = get_gateway("pin")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2020,
                                   number=VISA_SUCCESS,
                                   verification_value="100")
예제 #7
0
 def setUp(self):
     self.merchant = get_gateway("authorize_net")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2011, 
                                   number="4222222222222", 
                                   verification_value="100")
예제 #8
0
파일: views.py 프로젝트: shawnp/agiliq
def paylane(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("paylane")
            customer = PaylanePaymentCustomer()
            customer.name = "%s %s" % (data['first_name'], data['last_name'])
            customer.email = "*****@*****.**"
            customer.ip_address = "127.0.0.1"
            options = {}
            address = PaylanePaymentCustomerAddress()
            address.street_house = 'Av. 24 de Julho, 1117'
            address.city = 'Lisbon'
            address.zip_code = '1700-000'
            address.country_code = 'PT'
            customer.address = address
            options['customer'] = customer
            options['product'] = {}
            response = merchant.purchase(amount, credit_card, options=options)
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['paylane'])
    return render(
        request, 'app/index.html', {
            'form': form,
            'amount': amount,
            'response': response,
            'title': 'Paylane Gateway'
        })
예제 #9
0
파일: views.py 프로젝트: shawnp/agiliq
def paypal(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("pay_pal")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            # response = merchant.purchase(amount, credit_card, options={'request': request})
            response = merchant.recurring(amount,
                                          credit_card,
                                          options={'request': request})
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['paypal'])
    return render(request, 'app/index.html', {
        'form': form,
        'amount': amount,
        'response': response,
        'title': 'Paypal'
    })
예제 #10
0
 def testCreditCardExpired(self):
     credit_card = CreditCard(first_name="John",
                       last_name="Doe",
                       month=12, year=2011, # Use current date time to generate a date in the future
                       number = self.approved_cards["visa"]["number"],
                       verification_value = self.approved_cards["visa"]["cvd"])
     resp = self.merchant.purchase(8, credit_card)
     self.assertNotEquals(resp["status"], "SUCCESS")
예제 #11
0
 def setUp(self):
     self.merchant = get_gateway("stripe")
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2012,
                                   number="4242424242424242",
                                   verification_value="100")
     stripe.api_key = settings.STRIPE_API_KEY
     self.stripe = stripe
예제 #12
0
 def ccFactory(self, number, cvd):
     today = date.today()
     return CreditCard(first_name = "John",
                       last_name = "Doe",
                       month = str(today.month),
                       year = str(today.year + 1),
                       number = number,
                       verification_value = cvd)
예제 #13
0
 def setUp(self):
     self.merchant = get_gateway("pay_pal")
     self.merchant.test_mode = True
     self.credit_card = CreditCard(first_name="Test",
                                   last_name="User",
                                   month=10,
                                   year=2017,
                                   number="4500775008976759",
                                   verification_value="000")
예제 #14
0
    def direct_payment(self, credit_card_details, options=None):
        """
            Function that implement Direct Payment functionality provided by eWay.
                (Reference: http://www.eway.com.au/developers/api/direct-payments)

            Input Parameters:
                ( Please find the details here in this Gist: https://gist.github.com/08893221533daad49388 )
                credit_card   :    Customer Credit Card details
                options       :    Customer and Recurring Payment details

            Output Paramters:
                status: 'SUCCESS' or 'FAILURE'
                response : eWay Response in Dictionary format.
        """
        error_response = {}
        try:
            if (options and options.get('customer_details', False) and
                    options.get('payment_details', False)):
                customer_details = options.get('customer_details')
                payment_details = options.get('payment_details')
            else:
                error_response = {"reason": "Not enough information Available!"}
                raise

            """
                # Validate Entered credit card details.
            """
            credit_card = CreditCard(**credit_card_details)
            is_valid = self.validate_card(credit_card)
            if not is_valid:
                raise InvalidCard("Invalid Card")

            """
                # Create direct payment details
            """
            direct_payment_details = self.add_direct_payment_details(credit_card, customer_details, payment_details)

            """
                Process Direct Payment.
            """
            dpObj = DirectPaymentClient(self.direct_payment_url)
            response = dpObj.process_direct_payment(direct_payment_details)

            """
                Return value based on eWay Response
            """
            eway_response = response.get('ewayResponse', None)
            if eway_response and eway_response.get('ewayTrxnStatus', 'false').lower() == 'true':
                status = "SUCCESS"
            else:
                status = "FAILURE"

        except Exception as e:
            error_response['exception'] = e
            return {"status": "FAILURE", "response": error_response}

        return {"status": status, "response": response}
예제 #15
0
def eway(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("eway")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            billing_address = {
                'salutation': 'Mr.',
                'address1': 'test',
                'address2': ' street',
                'city': 'Sydney',
                'state': 'NSW',
                'company': 'Test Company',
                'zip': '2000',
                'country': 'au',
                'email': '*****@*****.**',
                'fax': '0267720000',
                'phone': '0267720000',
                'mobile': '0404085992',
                'customer_ref': 'REF100',
                'job_desc': 'test',
                'comments': 'any',
                'url': 'http://www.google.com.au',
            }
            response = merchant.purchase(amount,
                                         credit_card,
                                         options={
                                             'request': request,
                                             'billing_address': billing_address
                                         })
    else:
        form = CreditCardForm(
            initial={
                'number': '4444333322221111',
                'verification_value': '000',
                'month': 7,
                'year': 2012
            })
    return render(request, 'app/index.html', {
        'form': form,
        'amount': amount,
        'response': response,
        'title': 'Eway'
    })
예제 #16
0
def stripe(request):
    amount = 1
    response= None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("stripe")
            response = merchant.purchase(amount,credit_card)
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['stripe'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount':amount,
                                             'response':response,
                                             'title':'Stripe Payment'})
예제 #17
0
def chargebee(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("chargebee")
            response = merchant.purchase(amount, credit_card,
                                         {"plan_id": "professional",
                                          "description": "Quick Purchase"})
    else:
        form = CreditCardForm(initial=GATEWAY_INITIAL['chargebee'])
    return render(request, 'app/index.html',{'form': form,
                                             'amount': amount,
                                             'response': response,
                                             'title': 'Chargebee'})
예제 #18
0
def samurai(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("samurai")
            response = merchant.purchase(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number': '4111111111111111'})
    return render(request, 'app/index.html', {
        'form': form,
        'amount': amount,
        'response': response,
        'title': 'Samurai'
    })
예제 #19
0
 def get_credit_card(self):
     d = self.cleaned_data
     d['month'] = d['expiry_month']
     d['year'] = d['expiry_year']
     d['verification_value'] = d['cvc']
     card = CreditCard(**d)
     options = {
         'email': d['email'],
         'description': d['description'],
         'billing_address': {
             'address1': d['address_line1'],
             'address2': d.get('address_line2'),
             'city': d['address_city'],
             'zip': d['address_postcode'],
             'state': d['address_state'],
             'country': d['address_country'],
         }
     }
     return card, options
예제 #20
0
def braintree(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("braintree_payments")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            response = merchant.purchase(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number':'4111111111111111'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Braintree Payments (S2S)'})
예제 #21
0
def authorize(request):
    amount = 1
    response = None
    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            credit_card = CreditCard(**data)
            merchant = get_gateway("authorize_net")
            try:
                merchant.validate_card(credit_card)
            except CardNotSupported:
                response = "Credit Card Not Supported"
            response = merchant.purchase(amount, credit_card)
            #response = merchant.recurring(amount, credit_card)
    else:
        form = CreditCardForm(initial={'number': '4222222222222'})
    return render(request, 'app/index.html', {'form': form,
                                              'amount': amount,
                                              'response': response,
                                              'title': 'Authorize'})
예제 #22
0
    def recurring(self, credit_card_details, options=None):
        """
            Recurring Payment Implementation using eWay recurring API (http://www.eway.com.au/developers/api/recurring)

            Input Parameters:
                ( Please find the details here in this Gist: https://gist.github.com/df67e02f7ffb39f415e6 )
                credit_card   :    Customer Credit Card details
                options       :    Customer and Recurring Payment details

            Output Dict:
                status: 'SUCCESS' or 'FAILURE'
                response : Response list of rebill event request in order of provided input
                           in options["customer_rebill_details"] list.
        """
        error_response = {}
        try:
            if not options:
                error_response = {"reason": "Not enough information Available!"}
                raise

            """
                # Validate Entered credit card details.
            """
            credit_card = CreditCard(**credit_card_details)
            if not self.validate_card(credit_card):
                raise InvalidCard("Invalid Card")

            rebillClient = RebillEwayClient(
                customer_id=self.customer_id,
                username=self.eway_username,
                password=self.eway_password,
                url=self.rebill_url,
            )
            # CustomerDetails : To create rebill Customer
            customer_detail = rebillClient.client.factory.create("CustomerDetails")
            self.add_customer_details(credit_card, customer_detail, options)
            """
                # Create Rebill customer and retrieve customer rebill ID.
            """
            rebill_customer_response = rebillClient.create_rebill_customer(customer_detail)

            # Handler error in create_rebill_customer response
            if rebill_customer_response.ErrorSeverity:
                transaction_was_unsuccessful.send(sender=self,
                                                  type="recurringCreateRebill",
                                                  response=rebill_customer_response)
                error_response = rebill_customer_response
                raise

            rebile_customer_id = rebill_customer_response.RebillCustomerID
            """
                For Each rebill profile
                # Create Rebill events using rebill customer ID and customer rebill details.
            """
            rebill_event_response_list = []
            for each_rebill_profile in options.get("customer_rebill_details", []):
                rebill_detail = rebillClient.client.factory.create("RebillEventDetails")
                self.add_rebill_details(rebill_detail, rebile_customer_id, credit_card, each_rebill_profile)

                rebill_event_response = rebillClient.create_rebill_event(rebill_detail)

                # Handler error in create_rebill_event response
                if rebill_event_response.ErrorSeverity:
                    transaction_was_unsuccessful.send(sender=self,
                                                      type="recurringRebillEvent",
                                                      response=rebill_event_response)
                    error_response = rebill_event_response
                    raise

                rebill_event_response_list.append(rebill_event_response)

            transaction_was_successful.send(sender=self,
                                            type="recurring",
                                            response=rebill_event_response_list)
        except Exception as e:
            error_response['exception'] = e
            return {"status": "Failure", "response": error_response}

        return {"status": "SUCCESS", "response": rebill_event_response_list}
예제 #23
0
 def setUp(self):
     self.merchant = get_gateway("samurai")
     self.credit_card = CreditCard(first_name="Test", last_name="User",
                                   month=10, year=2012,
                                   number="4111111111111111",
                                   verification_value="100")
예제 #24
0
파일: forms.py 프로젝트: sq9mev/merchant
 def clean(self):
     data = self.cleaned_data
     credit_card = CreditCard(**data)
     if not credit_card.is_valid():
         raise forms.ValidationError('Credit card validation failed')
     return data