Ejemplo n.º 1
0
def __create_credit_card_transaction():
    customer = Customer(id='cus_bd838e3611d34d598',
                        firstName='John',
                        lastName='Doe',
                        email='*****@*****.**',
                        country='US')

    payment = Payment(paymentOption='CreditCard',
                      holder='John Doe',
                      creditCardNumber='4111111111111111',
                      CVV2='222',
                      creditCardType='visa',
                      expirationYear='2019',
                      expirationMonth='12')

    redirectUrls = RedirectUrls(
        returnUrl='http://2000charge.com/message/success.html',
        cancelUrl='http://2000charge.com/message/failure.html')

    return Transaction.create({
        'customer': customer,
        'payment': payment,
        'amount': 500,
        'currency': 'EUR',
        'iPAddress': '127.0.0.1',
        'redirectUrls': redirectUrls
    })
Ejemplo n.º 2
0
def __create_brazil_pay_bank_transfer_transaction():
    customer = Customer(firstName='Jose',
                        lastName='Silva',
                        email='*****@*****.**',
                        address='Rua E',
                        address2='1040',
                        city='Maracanau',
                        zip='61919-230',
                        country='BR',
                        state='CE',
                        birthDate='12/04/1979',
                        phone='+5572222312')

    payment = Payment(paymentOption='BrazilPayBankTransfer',
                      holder='Jose Silva',
                      documentId='853.513.468-93',
                      bankCode='hsbc')

    redirectUrls = RedirectUrls(
        returnUrl='http://2000charge.com/message/success.html',
        cancelUrl='http://2000charge.com/message/failure.html')

    return Transaction.create({
        'customer': customer,
        'payment': payment,
        'amount': 4500,
        'currency': 'EUR',
        'iPAddress': '127.0.0.1',
        'redirectUrls': redirectUrls
    })
Ejemplo n.º 3
0
    def test_transaction(self):
        customer = Customer(id="cus_bd838e3611d34d598",
                            firstName="John",
                            lastName="Doe",
                            email="*****@*****.**",
                            country="DE")

        payment = Payment(paymentOption="SEPA",
                          holder="John Doe",
                          iban="BE88271080782541")

        transaction = Transaction(customer=customer,
                                  payment=payment,
                                  amount=500,
                                  currency="EUR",
                                  description="test sepa php sdk",
                                  merchantPassThruData="test_sepa_123",
                                  iPAddress="127.0.0.1")

        assert_equal(transaction.customer.id, "cus_bd838e3611d34d598")
        assert_equal(transaction.customer.firstName, "John")
        assert_equal(transaction.customer.lastName, "Doe")
        assert_equal(transaction.customer.email, "*****@*****.**")
        assert_equal(transaction.customer.country, "DE")

        assert_equal(transaction.payment.paymentOption, "SEPA")
        assert_equal(transaction.payment.holder, "John Doe")
        assert_equal(transaction.payment.iban, "BE88271080782541")

        assert_equal(transaction.amount, 500)
        assert_equal(transaction.currency, "EUR")
        assert_equal(transaction.description, "test sepa php sdk")
        assert_equal(transaction.merchantPassThruData, "test_sepa_123")
        assert_equal(transaction.iPAddress, "127.0.0.1")
Ejemplo n.º 4
0
    def test_payment(self):
        payment = Payment(paymentOption='SEPA',
                          holder='John Doe',
                          iban='BE88271080782541')

        assert_equal(payment.paymentOption, 'SEPA')
        assert_equal(payment.holder, 'John Doe')
        assert_equal(payment.iban, 'BE88271080782541')
Ejemplo n.º 5
0
def add_subscription(request):
    template = loader.get_template('subscription/add_subscription.html')

    plan_name = request.POST.get("plan_name")
    plan_amount = request.POST.get("plan_amount")
    email = request.POST.get("email")

    context = {}

    if plan_name != None and plan_name != "" \
        and plan_amount != None and plan_amount != "" \
        and email != None and email != "":

        plan = Plan.create({
            'interval': 1,
            'period': Period.DAY,
            'amount': plan_amount,
            'currency': 'EUR',
            'name': plan_name,
            'description': 'Test plan'
        })

        customer = Customer(firstName='John',
                            lastName='Doe',
                            email=email,
                            country='DE')

        payment = Payment(paymentOption='SEPA',
                          holder='John Doe',
                          iban='BE88271080782541')

        transaction = Transaction.create({
            'customer': customer,
            'payment': payment,
            'amount': 500,
            'currency': 'EUR',
            'description': 'test sepa php sdk',
            'merchantPassThruData': 'test_sepa_123',
            'iPAddress': '127.0.0.1'
        })

        subscription = Subscription.create({
            'paymentId': transaction.payment.id,
            'customerId': transaction.customer.id,
            'planId': plan.id
        })

        context = {'subscription': subscription}

    return HttpResponse(template.render(context, request))
Ejemplo n.º 6
0
def __create_sepa_transaction():
    customer = Customer(id='cus_bd838e3611d34d598',
                        firstName='John',
                        lastName='Doe',
                        email='*****@*****.**',
                        country='DE')

    payment = Payment(paymentOption='SEPA',
                      holder='John Doe',
                      iban='BE88271080782541')

    return Transaction.create({
        'customer': customer,
        'payment': payment,
        'amount': 500,
        'currency': 'EUR',
        'description': 'test sepa php sdk',
        'merchantPassThruData': 'test_sepa_123',
        'iPAddress': '127.0.0.1'
    })
Ejemplo n.º 7
0
def __create_directpay_transaction():
    customer = Customer(id='cus_bd838e3611d34d598',
                        firstName='John',
                        lastName='Doe',
                        email='*****@*****.**',
                        country='DE')

    payment = Payment(paymentOption='directpay', holder='John Doe')

    redirectUrls = RedirectUrls(
        returnUrl='http://2000charge.com/message/success.html',
        cancelUrl='http://2000charge.com/message/failure.html')

    return Transaction.create({
        'customer': customer,
        'payment': payment,
        'amount': 100,
        'currency': 'EUR',
        'iPAddress': '127.0.0.1',
        'redirectUrls': redirectUrls
    })