Skip to content

Commit fcc9226

Browse files
feat: support redirect URL in payment link after the purchase is complete
1 parent 35f07c7 commit fcc9226

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

python/tests/test_functions.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,19 +343,36 @@ def test_create_payment_link(self):
343343

344344
self.assertEqual(result, mock_payment_link)
345345

346-
def test_create_payment_link_with_context(self):
346+
def test_create_payment_link_with_redirect_url(self):
347347
with mock.patch("stripe.PaymentLink.create") as mock_function:
348348
mock_payment_link = {"id": "pl_123", "url": "https://example.com"}
349349
mock_function.return_value = stripe.PaymentLink.construct_from(
350350
mock_payment_link, "sk_test_123"
351351
)
352352

353353
result = create_payment_link(
354-
context={"account": "acct_123"}, price="price_123", quantity=1, redirect_url="https://example.com"
354+
context={}, price="price_123", quantity=1, redirect_url="https://example.com"
355355
)
356356

357357
mock_function.assert_called_with(
358358
line_items=[{"price": "price_123", "quantity": 1, "after_completion": {"type": "redirect", "redirect": {"url": "https://example.com"}}}],
359+
)
360+
361+
self.assertEqual(result, mock_payment_link)
362+
363+
def test_create_payment_link_with_context(self):
364+
with mock.patch("stripe.PaymentLink.create") as mock_function:
365+
mock_payment_link = {"id": "pl_123", "url": "https://example.com"}
366+
mock_function.return_value = stripe.PaymentLink.construct_from(
367+
mock_payment_link, "sk_test_123"
368+
)
369+
370+
result = create_payment_link(
371+
context={"account": "acct_123"}, price="price_123", quantity=1
372+
)
373+
374+
mock_function.assert_called_with(
375+
line_items=[{"price": "price_123", "quantity": 1}],
359376
stripe_account="acct_123",
360377
)
361378

0 commit comments

Comments
 (0)