Пример #1
0
def stripe_refund_success_response(stripe_charge_success_response):
    response = stripe_charge_success_response.copy()
    response.pop("amount_refunded")
    response["amount"] = get_amount_for_stripe(
        TRANSACTION_REFUND_AMOUNT, TRANSACTION_CURRENCY
    )
    return response
Пример #2
0
def stripe_charge_success_response():
    return {
        'id': TRANSACTION_TOKEN,
        'amount': get_amount_for_stripe(
            TRANSACTION_AMOUNT, TRANSACTION_CURRENCY),
        'amount_refunded': 0,
        'currency': get_currency_for_stripe(TRANSACTION_CURRENCY),
        'status': 'succeeded'}
Пример #3
0
def stripe_charge_success_response():
    return {
        'id': TRANSACTION_TOKEN,
        'amount': get_amount_for_stripe(
            TRANSACTION_AMOUNT, TRANSACTION_CURRENCY),
        'amount_refunded': 0,
        'currency': get_currency_for_stripe(TRANSACTION_CURRENCY),
        'status': 'succeeded'}
Пример #4
0
def stripe_charge_success_response():
    return {
        "id": TRANSACTION_TOKEN,
        "amount": get_amount_for_stripe(TRANSACTION_AMOUNT, TRANSACTION_CURRENCY),
        "amount_refunded": 0,
        "currency": get_currency_for_stripe(TRANSACTION_CURRENCY),
        "status": "succeeded",
    }
Пример #5
0
def stripe_charge_success_response():
    return {
        "id": TRANSACTION_TOKEN,
        "amount": get_amount_for_stripe(TRANSACTION_AMOUNT,
                                        TRANSACTION_CURRENCY),
        "amount_refunded": 0,
        "currency": get_currency_for_stripe(TRANSACTION_CURRENCY),
        "status": "succeeded",
    }
Пример #6
0
def test_get_amount_for_stripe():
    assert get_amount_for_stripe(Decimal(1), "USD") == 100
    assert get_amount_for_stripe(Decimal(1), "usd") == 100

    assert get_amount_for_stripe(Decimal(0.01), "USD") == 1
    assert get_amount_for_stripe(Decimal(24.24), "USD") == 2424
    assert get_amount_for_stripe(Decimal(42.42), "USD") == 4242

    assert get_amount_for_stripe(Decimal(1), "JPY") == 1
    assert get_amount_for_stripe(Decimal(1), "jpy") == 1
Пример #7
0
def test_get_amount_for_stripe():
    assert get_amount_for_stripe(Decimal(1), 'USD') == 100
    assert get_amount_for_stripe(Decimal(1), 'usd') == 100

    assert get_amount_for_stripe(Decimal(0.01), 'USD') == 1
    assert get_amount_for_stripe(Decimal(24.24), 'USD') == 2424
    assert get_amount_for_stripe(Decimal(42.42), 'USD') == 4242

    assert get_amount_for_stripe(Decimal(1), 'JPY') == 1
    assert get_amount_for_stripe(Decimal(1), 'jpy') == 1
Пример #8
0
def test_get_amount_for_stripe():
    assert get_amount_for_stripe(Decimal(1), "USD") == 100
    assert get_amount_for_stripe(Decimal(1), "usd") == 100

    assert get_amount_for_stripe(Decimal(0.01), "USD") == 1
    assert get_amount_for_stripe(Decimal(24.24), "USD") == 2424
    assert get_amount_for_stripe(Decimal(42.42), "USD") == 4242

    assert get_amount_for_stripe(Decimal(1), "JPY") == 1
    assert get_amount_for_stripe(Decimal(1), "jpy") == 1
Пример #9
0
def test_get_amount_for_stripe():
    assert get_amount_for_stripe(Decimal(1), 'USD') == 100
    assert get_amount_for_stripe(Decimal(1), 'usd') == 100

    assert get_amount_for_stripe(Decimal(0.01), 'USD') == 1
    assert get_amount_for_stripe(Decimal(24.24), 'USD') == 2424
    assert get_amount_for_stripe(Decimal(42.42), 'USD') == 4242

    assert get_amount_for_stripe(Decimal(1), 'JPY') == 1
    assert get_amount_for_stripe(Decimal(1), 'jpy') == 1
Пример #10
0
def test_get_stripe_charge_payload_without_shipping(stripe_payment):
    stripe_payment.order.shipping_address = None
    payment_info = create_payment_information(stripe_payment, FAKE_TOKEN)
    billing_name = get_payment_billing_fullname(payment_info)
    expected_payload = {
        'capture': True,
        'amount': get_amount_for_stripe(
            TRANSACTION_AMOUNT, TRANSACTION_CURRENCY),
        'currency': get_currency_for_stripe(TRANSACTION_CURRENCY),
        'source': FAKE_TOKEN,
        'description': billing_name}

    charge_payload = _get_stripe_charge_payload(payment_info, True)

    assert charge_payload == expected_payload
Пример #11
0
def test_get_stripe_charge_payload_without_shipping(stripe_payment):
    stripe_payment.order.shipping_address = None
    billing_name = get_payment_billing_fullname(stripe_payment)
    expected_payload = {
        'capture': True,
        'amount': get_amount_for_stripe(
            TRANSACTION_AMOUNT, TRANSACTION_CURRENCY),
        'currency': get_currency_for_stripe(TRANSACTION_CURRENCY),
        'source': FAKE_TOKEN,
        'description': billing_name}

    charge_payload = _get_stripe_charge_payload(
        stripe_payment, TRANSACTION_AMOUNT, FAKE_TOKEN, True)

    assert charge_payload == expected_payload
Пример #12
0
def test_get_stripe_charge_payload_without_shipping(stripe_payment):
    stripe_payment.order.shipping_address = None
    payment_info = create_payment_information(stripe_payment, FAKE_TOKEN)
    billing_name = get_payment_billing_fullname(payment_info)
    expected_payload = {
        "capture": True,
        "amount": get_amount_for_stripe(TRANSACTION_AMOUNT,
                                        TRANSACTION_CURRENCY),
        "currency": get_currency_for_stripe(TRANSACTION_CURRENCY),
        "source": FAKE_TOKEN,
        "description": billing_name,
    }

    charge_payload = _get_stripe_charge_payload(payment_info, True)

    assert charge_payload == expected_payload
Пример #13
0
def test_get_stripe_charge_payload_with_shipping(stripe_payment):
    payment_info = create_payment_information(stripe_payment, FAKE_TOKEN)
    billing_name = get_payment_billing_fullname(payment_info)
    expected_payload = {
        "capture": True,
        "amount": get_amount_for_stripe(TRANSACTION_AMOUNT, TRANSACTION_CURRENCY),
        "currency": get_currency_for_stripe(TRANSACTION_CURRENCY),
        "source": FAKE_TOKEN,
        "description": billing_name,
        "shipping": {
            "name": billing_name,
            "address": shipping_to_stripe_dict(payment_info.shipping),
        },
    }

    charge_payload = _get_stripe_charge_payload(payment_info, True)

    assert charge_payload == expected_payload
Пример #14
0
def test_get_stripe_charge_payload_with_shipping(stripe_payment):
    payment_info = create_payment_information(stripe_payment, FAKE_TOKEN)
    billing_name = get_payment_billing_fullname(payment_info)
    expected_payload = {
        'capture': True,
        'amount': get_amount_for_stripe(TRANSACTION_AMOUNT,
                                        TRANSACTION_CURRENCY),
        'currency': get_currency_for_stripe(TRANSACTION_CURRENCY),
        'source': FAKE_TOKEN,
        'description': billing_name,
        'shipping': {
            'name': billing_name,
            'address': shipping_to_stripe_dict(payment_info.shipping)
        }
    }

    charge_payload = _get_stripe_charge_payload(payment_info, True)

    assert charge_payload == expected_payload
Пример #15
0
def stripe_refund_success_response(stripe_charge_success_response):
    response = stripe_charge_success_response.copy()
    response.pop('amount_refunded')
    response['amount'] = get_amount_for_stripe(TRANSACTION_REFUND_AMOUNT,
                                               TRANSACTION_CURRENCY)
    return response
Пример #16
0
def stripe_partial_charge_success_response(stripe_charge_success_response):
    response = stripe_charge_success_response.copy()
    response['amount_refunded'] = get_amount_for_stripe(
        TRANSACTION_REFUND_AMOUNT, TRANSACTION_CURRENCY)
    return response
Пример #17
0
def stripe_partial_charge_success_response(stripe_charge_success_response):
    response = stripe_charge_success_response.copy()
    response["amount_refunded"] = get_amount_for_stripe(
        TRANSACTION_REFUND_AMOUNT, TRANSACTION_CURRENCY)
    return response