コード例 #1
0
ファイル: test_payment.py プロジェクト: shabeeb-aot/sbc-pay
def test_create_account_payments_for_multiple_failed_payments(session):
    """Assert that the create account payments is working."""
    inv_number_1 = 'REG00001'
    payment_account = factory_payment_account().save()
    invoice_1 = factory_invoice(payment_account, total=100)
    invoice_1.save()
    factory_payment_line_item(invoice_id=invoice_1.id,
                              fee_schedule_id=1).save()
    factory_invoice_reference(invoice_1.id, invoice_number=inv_number_1).save()
    payment_1 = factory_payment(payment_status_code='FAILED',
                                payment_account_id=payment_account.id,
                                invoice_number=inv_number_1,
                                invoice_amount=100,
                                payment_method_code=PaymentMethod.PAD.value)
    payment_1.save()

    # Create one more payment with failed status.
    inv_number_2 = 'REG00002'
    invoice_2 = factory_invoice(payment_account, total=100)
    invoice_2.save()
    factory_payment_line_item(invoice_id=invoice_2.id,
                              fee_schedule_id=1).save()
    factory_invoice_reference(invoice_2.id, invoice_number=inv_number_2).save()

    payment_2 = factory_payment(payment_status_code='FAILED',
                                payment_account_id=payment_account.id,
                                invoice_number=inv_number_2,
                                invoice_amount=100,
                                payment_method_code=PaymentMethod.PAD.value)
    payment_2.save()

    auth_account_id = PaymentAccount.find_by_id(
        payment_account.id).auth_account_id

    results = Payment_service.search_account_payments(
        auth_account_id=auth_account_id, status='FAILED', limit=10, page=1)
    assert results.get('total') == 2

    new_payment = Payment_service.create_account_payment(
        auth_account_id=auth_account_id, is_retry_payment=True)
    payment_1 = Payment_service.find_by_id(payment_1.id)
    payment_2 = Payment_service.find_by_id(payment_2.id)
    # Assert new payment invoice number is different from old payment as there are more than one failed payments.
    assert new_payment.invoice_number != payment_1.invoice_number
    assert new_payment.invoice_number != payment_2.invoice_number
    assert payment_1.cons_inv_number == new_payment.invoice_number
    assert payment_2.cons_inv_number == new_payment.invoice_number
    assert new_payment.invoice_amount == payment_1.invoice_amount + payment_2.invoice_amount
コード例 #2
0
ファイル: test_payment.py プロジェクト: shabeeb-aot/sbc-pay
def test_create_account_payments_for_one_failed_payment(session):
    """Assert that the create account payments is working."""
    inv_number_1 = 'REG00001'
    payment_account = factory_payment_account().save()
    invoice_1 = factory_invoice(payment_account)
    invoice_1.save()
    factory_invoice_reference(invoice_1.id, invoice_number=inv_number_1).save()
    payment_1 = factory_payment(payment_status_code='FAILED',
                                payment_account_id=payment_account.id,
                                invoice_number=inv_number_1,
                                payment_method_code=PaymentMethod.PAD.value)
    payment_1.save()

    auth_account_id = PaymentAccount.find_by_id(
        payment_account.id).auth_account_id

    results = Payment_service.search_account_payments(
        auth_account_id=auth_account_id, status='FAILED', limit=1, page=1)
    assert results.get('total') == 1

    new_payment = Payment_service.create_account_payment(
        auth_account_id=auth_account_id, is_retry_payment=True)
    old_payment = Payment_service.find_by_id(payment_1.id)
    # Assert new payment invoice number is same as old payment as there is only one failed payment.
    assert new_payment.invoice_number == old_payment.invoice_number
コード例 #3
0
ファイル: test_payment.py プロジェクト: LJTrent/sbc-pay
def test_payment_with_no_active_invoice(session):
    """Assert that the payment is saved to the table."""
    payment_account = factory_payment_account()
    payment = factory_payment()
    payment_account.save()
    payment.save()
    invoice = factory_invoice(payment, payment_account, Status.DELETED.value)
    invoice.save()
    factory_invoice_reference(invoice.id).save()
    p = Payment_service.find_by_id(payment.id, skip_auth_check=True)

    assert p is not None
    assert p.id is not None
コード例 #4
0
def test_payment_with_no_active_invoice(session):
    """Assert that the payment is saved to the table."""
    payment_account = factory_payment_account()
    payment = factory_payment()
    payment_account.save()
    payment.save()
    invoice = factory_invoice(payment.id, payment_account.id,
                              Status.CANCELLED.value)
    invoice.save()
    p = Payment_service.find_by_id(payment.id)

    assert p is not None
    assert p.id is not None

    json = p.asdict()
    assert json.get('invoices', None) is None
コード例 #5
0
ファイル: test_payment.py プロジェクト: shabeeb-aot/sbc-pay
def test_payment_saved_from_new(session):
    """Assert that the payment is saved to the table."""
    payment_account = factory_payment_account()
    payment = factory_payment()
    payment_account.save()
    payment.save()
    invoice = factory_invoice(payment_account)
    invoice.save()
    factory_invoice_reference(invoice.id).save()
    p = Payment_service.find_by_id(payment.id)

    assert p is not None
    assert p.id is not None
    assert p.payment_system_code is not None
    assert p.payment_method_code is not None
    assert p.payment_status_code is not None
コード例 #6
0
ファイル: test_payment.py プロジェクト: mengdong19/sbc-pay
def test_payment_saved_from_new(session):
    """Assert that the payment is saved to the table."""
    payment_account = factory_payment_account()
    payment = factory_payment()
    payment_account.save()
    payment.save()

    p = Payment_service.find_by_id(payment.id)

    assert p is not None
    assert p.id is not None
    assert p.payment_system_code is not None
    assert p.payment_method_code is not None
    assert p.payment_status_code is not None
    assert p.created_by is not None
    assert p.created_on is not None
    assert p.updated_on is None
    assert p.updated_by is None
コード例 #7
0
def test_payment_invalid_lookup(session):
    """Test invalid lookup."""
    p = Payment_service.find_by_id(999)

    assert p is not None
    assert p.id is None