示例#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))
def test_create_payout():
    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    amount = generateAmount()
    currency = TERMINAL_CURRENCY
    note = fake.sentence()

    # card data
    cardPan = CARD_NON3DS_CONFIRMED
    cardHolder = fake.name()
    cardExpiration = formatExpirationDate(generateCardExpiration())

    # prepare request data
    request = PayoutRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PayoutRequestMerchantOrder(
            id=merchantOrderId, description=merchantDescription),
        payment_method=PAYMENT_METHOD_BANKCARD,
        payout_data=PayoutRequestPayoutData(currency=currency,
                                            amount=amount,
                                            note=note),
        card_account=PayoutRequestCardAccount(recipient_info=cardHolder,
                                              card=PayoutRequestCard(
                                                  pan=cardPan,
                                                  expiration=cardExpiration)))

    logger.info(request)

    # perform create payment
    response = payouts.create_payout(request)

    # explore response result
    assert response is not None
    assert response.payout_data.Status.COMPLETED == response.payout_data.status
示例#3
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
示例#4
0
def create_payout_request(pan):
    return PayoutRequest(
        request=ApiClient.uuid_request(),
        merchant_order=PayoutRequestMerchantOrder(id=randomString(20),
                                                  description=fake.sentence()),
        payment_method=PAYMENT_METHOD_BANKCARD,
        payout_data=PayoutRequestPayoutData(currency=TERMINAL_CURRENCY,
                                            amount=generateAmount(),
                                            note=fake.sentence()),
        card_account=PayoutRequestCardAccount(
            recipient_info=fake.name(),
            card=PayoutRequestCard(pan=pan,
                                   expiration=formatExpirationDate(
                                       generateCardExpiration()))))
示例#5
0
def test_create_refund():
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Phase 1: create payment
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    payment_id = do_payment(payments, CARD_NON3DS_CONFIRMED, amount=300)

    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Phase 2: create refund
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # merchant order data
    merchantOrderId = randomString(20)
    merchantDescription = fake.sentence()
    amount = generateAmount(max=100)
    currency = TERMINAL_CURRENCY

    # prepare refund request data
    request = RefundRequest(request=ApiClient.uuid_request(),
                            merchant_order=RefundRequestMerchantOrder(
                                id=merchantOrderId,
                                description=merchantDescription),
                            payment_data=RefundRequestPaymentData(payment_id),
                            refund_data=RefundRequestRefundData(
                                amount=amount, currency=currency))
    logger.info(request)

    # perform create refund
    response = refunds.create_refund(request)
    assert response is not None

    data = response.refund_data
    assert data is not None
    assert data.Status.COMPLETED == data.status
示例#6
0
def create_refund_request(payment_id, amount):
    return RefundRequest(
        request=ApiClient.uuid_request(),
        merchant_order=RefundRequestMerchantOrder(id=randomString(20),
                                                  description=fake.sentence()),
        payment_data=RefundRequestPaymentData(payment_id),
        refund_data=RefundRequestRefundData(amount=amount,
                                            currency=TERMINAL_CURRENCY))
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
示例#8
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)
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
示例#10
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
示例#11
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
def test_link_a_card_to_an_existing_subscription():
    global subscription_id

    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Phase 1: prepare a new plan
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    plan_id = do_create_plan(recurrings)

    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Phase 2: create scheduled subscription
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    subscription_id = do_create_subscription(recurrings, plan_id=plan_id)

    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # 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"

    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Phase 3: link a card to an existing subscription
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    #  prepare filing request data
    request = FilingRequest(
        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)),
        subscription_data=FilingRequestSubscriptionData(id=subscription_id),
        recurring_data=FilingRecurringData(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)