コード例 #1
0
def create_payment_request(pan, amount=None, preauth=False):
    customer_id = randomString(15)
    return PaymentRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PaymentRequestMerchantOrder(
            id=generateMerchantOrderId(), description=fake.sentence()),
        payment_method=PAYMENT_METHOD_BANKCARD,
        payment_data=PaymentRequestPaymentData(
            currency=TERMINAL_CURRENCY,
            amount=generateAmount() if not amount else amount,
            note=fake.sentence(),
            preauth=preauth),
        card_account=PaymentRequestCardAccount(card=PaymentRequestCard(
            pan=pan,
            holder=fake.name().upper(),
            expiration=formatExpirationDate(generateCardExpiration()),
            security_code="123")),
        customer=PaymentRequestCustomer(id=customer_id,
                                        full_name=fake.name(),
                                        email=generateEmail(customer_id),
                                        birth_date=formatBirthDate(
                                            fake.profile()['birthdate']),
                                        phone=generatePhoneNumber()),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))
コード例 #2
0
def test_create_payment_gateway_mode_with_3ds():
    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    amount = generateAmount()
    currency = TERMINAL_CURRENCY
    note = fake.sentence()

    # card data
    cardPan = CARD_3DS_CONFIRMED
    cardHolder = fake.name().upper()
    cardExpiration = formatExpirationDate(generateCardExpiration())
    securityCode = "100"

    # customer data
    customerId = randomString(15)
    customerFullname = fake.name()
    customerBirthdate = formatBirthDate(fake.profile()['birthdate'])
    customerEmail = generateEmail(customerId)
    customerPhoneNumber = generatePhoneNumber()

    # prepare request data
    request = PaymentRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PaymentRequestMerchantOrder(
            id=merchantOrderId, description=merchantDescription),
        payment_method=PAYMENT_METHOD_BANKCARD,
        card_account=PaymentRequestCardAccount(
            card=PaymentRequestCard(pan=cardPan,
                                    holder=cardHolder,
                                    expiration=cardExpiration,
                                    security_code=securityCode)),
        payment_data=PaymentRequestPaymentData(currency=currency,
                                               amount=amount,
                                               note=note),
        customer=PaymentRequestCustomer(id=customerId,
                                        full_name=customerFullname,
                                        email=customerEmail,
                                        birth_date=customerBirthdate,
                                        phone=customerPhoneNumber),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))

    logger.info(request)

    # perform api call
    response = payments.create_payment(request)

    # Emulate customer behaviour performing GET request to redirect url
    do_get(response.redirect_url)

    # explore response result
    payment = fetch_payment_by_merchant_order_id(payments, merchantOrderId)
    logger.info(payment)

    data = payment.payment_data
    assert data.Status.IN_PROGRESS == data.status
def test_create_payment_gateway_mode():
    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    amount = generateAmount()
    currency = TERMINAL_CURRENCY
    initiator = "cit"

    # card data
    cardPan = CARD_NON3DS_CONFIRMED
    cardHolder = fake.name().upper()
    cardExpiration = formatExpirationDate(generateCardExpiration())
    securityCode = "100"

    # customer data
    customerId = randomString(15)
    customerEmail = generateEmail(customerId)

    # prepare request data
    request = RecurringCreationRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PaymentRequestMerchantOrder(
            id=merchantOrderId, description=merchantDescription),
        payment_method=PAYMENT_METHOD_BANKCARD,
        card_account=PaymentRequestCardAccount(
            card=PaymentRequestCard(pan=cardPan,
                                    holder=cardHolder,
                                    expiration=cardExpiration,
                                    security_code=securityCode)),
        customer=PaymentRequestCustomer(id=customerId, email=customerEmail),
        recurring_data=RecurringRequestRecurringData(initiator=initiator,
                                                     currency=currency,
                                                     amount=amount),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))

    logger.info(request)

    response = recurrings.create_recurring(request)
    logger.info(response)

    # get redirect url
    redirect_url = response.redirect_url
    assert redirect_url is not None

    # Emulate customer behaviour performing GET request to redirect url
    do_get(response.redirect_url)

    # explore response result
    recurring = fetch_recurring(recurrings, merchantOrderId)
    assert recurring is not None
    logger.info(recurring)

    data = recurring.recurring_data
    assert data is not None
    assert data.Status.COMPLETED == data.status
コード例 #4
0
def test_link_a_card_without_an_existing_subscription():
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Filling Data
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    initiator = "cit"

    # card data
    cardPan = CARD_NON3DS_CONFIRMED
    cardHolder = fake.name().upper()
    cardExpiration = formatExpirationDate(generateCardExpiration())
    securityCode = "100"

    # customer data
    customerId = randomString(15)
    customerFullname = fake.name()
    customerBirthdate = formatBirthDate(fake.profile()['birthdate'])
    customerEmail = generateEmail(customerId)
    customerPhoneNumber = generatePhoneNumber()

    #  prepare filing request data
    request = FilingRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PaymentRequestMerchantOrder(
            id=merchantOrderId, description=merchantDescription),
        customer=PaymentRequestCustomer(id=customerId,
                                        full_name=customerFullname,
                                        email=customerEmail,
                                        birth_date=customerBirthdate,
                                        phone=customerPhoneNumber),
        payment_method=PAYMENT_METHOD_BANKCARD,
        card_account=PaymentRequestCardAccount(
            card=PaymentRequestCard(pan=cardPan,
                                    holder=cardHolder,
                                    expiration=cardExpiration,
                                    security_code=securityCode)),
        recurring_data=FilingRecurringData(currency=TERMINAL_CURRENCY,
                                           initiator=initiator),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))
    logger.info(request)

    response = recurrings.create_filing(filing_request=request)
    assert response is not None

    # get redirect url
    redirect_url = response.redirect_url
    assert redirect_url is not None

    # Emulate customer behaviour performing GET request to redirect url
    do_get(response.redirect_url)
コード例 #5
0
def test_create_payment_page_mode():
    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    amount = generateAmount()
    currency = TERMINAL_CURRENCY
    note = fake.sentence()

    # customer data
    customerId = randomString(15)
    customerFullname = fake.name()
    customerBirthdate = formatBirthDate(fake.profile()['birthdate'])
    customerEmail = generateEmail(customerId)
    customerPhoneNumber = generatePhoneNumber()

    # prepare request data
    request = PaymentRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PaymentRequestMerchantOrder(
            id=merchantOrderId, description=merchantDescription),
        payment_method=PAYMENT_METHOD_BANKCARD,
        card_account=PaymentRequestCardAccount(),
        payment_data=PaymentRequestPaymentData(currency=currency,
                                               amount=amount,
                                               note=note),
        customer=PaymentRequestCustomer(id=customerId,
                                        full_name=customerFullname,
                                        email=customerEmail,
                                        birth_date=customerBirthdate,
                                        phone=customerPhoneNumber),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))

    logger.info(request)

    # perform api call
    response = payments.create_payment(request)

    assert response.redirect_url is not None
コード例 #6
0
def create_recurring_request(plan_id=None,
                             pan=CARD_NON3DS_CONFIRMED,
                             currency=None,
                             amount=None,
                             preauth=None):
    customer_id = randomString(15)
    result = RecurringCreationRequest(
        request=ApiClient.uuid_request(),
        customer=RecurringCustomer(id=customer_id,
                                   email=generateEmail(customer_id)),
        merchant_order=PaymentRequestMerchantOrder(
            id=generateMerchantOrderId(), description=fake.sentence()),
        payment_method=PAYMENT_METHOD_BANKCARD,
        card_account=PaymentRequestCardAccount(card=PaymentRequestCard(
            pan=pan,
            holder=fake.name().upper(),
            expiration=formatExpirationDate(generateCardExpiration()),
            security_code="123")),
        recurring_data=RecurringRequestRecurringData(initiator="cit"),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))

    if plan_id is not None:
        result.recurring_data.plan = Plan(plan_id)

    if currency is not None:
        result.recurring_data.currency = currency

    if amount is not None:
        result.recurring_data.amount = amount

    if preauth is not None:
        result.recurring_data.preauth = preauth

    return result
コード例 #7
0
def test_create_payment_gateway_mode():
    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    amount = generateAmount()
    currency = TERMINAL_CURRENCY
    initiator = "cit"

    # customer data
    customerId = randomString(15)
    customerEmail = generateEmail(customerId)

    # prepare request data
    request = RecurringCreationRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PaymentRequestMerchantOrder(
            id=merchantOrderId, description=merchantDescription),
        payment_method=PAYMENT_METHOD_BANKCARD,
        card_account=PaymentRequestCardAccount(),
        customer=PaymentRequestCustomer(id=customerId, email=customerEmail),
        recurring_data=RecurringRequestRecurringData(initiator=initiator,
                                                     currency=currency,
                                                     amount=amount),
        return_urls=ReturnUrls(success_url=SUCCESS_URL,
                               decline_url=DECLINE_URL,
                               cancel_url=CANCEL_URL,
                               inprocess_url=INPROCESS_URL))

    logger.info(request)

    response = recurrings.create_recurring(request)
    logger.info(response)

    # get redirect url
    redirect_url = response.redirect_url
    assert redirect_url is not None