Skip to content

Commit

Permalink
Add support for PaymentIntent.increment_authorization mehtod
Browse files Browse the repository at this point in the history
  • Loading branch information
bhch committed Apr 19, 2022
1 parent dc055c4 commit 71a8dca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions async_stripe/api_resources/payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ async def apply_customer_balance_patch(self, idempotency_key=None, **params):
return self


async def increment_authorization_patch(self, idempotency_key=None, **params):
url = self.instance_url() + "/increment_authorization"
headers = util.populate_headers(idempotency_key)
self.refresh_from(await self.request("post", url, params, headers))
return self


stripe.PaymentIntent.cancel = cancel_patch
stripe.PaymentIntent.capture = capture_patch
stripe.PaymentIntent.confirm = confirm_patch
stripe.PaymentIntent.verify_microdeposits = verify_microdeposits_patch
stripe.PaymentIntent.apply_customer_balance = apply_customer_balance_patch
stripe.PaymentIntent.increment_authorization = increment_authorization_patch


custom_resources = [
Expand All @@ -51,5 +59,6 @@ async def apply_customer_balance_patch(self, idempotency_key=None, **params):
{"name": "confirm", "http_verb": "post"},
{"name": "verify_microdeposits", "http_verb": "post"},
{"name": "apply_customer_balance", "http_verb": "post"},
{"name": "increment_authorization", "http_verb": "post"},
]
patch_custom_methods(stripe.PaymentIntent, custom_resources)
7 changes: 7 additions & 0 deletions tests/api_resources/test_payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,10 @@ async def test_paymentintent_apply_customer_balance(self, request_mock):
"post",
"/v1/payment_intents/pi_xxxxxxxxxxxxx/apply_customer_balance"
)

async def test_paymentintent_increment_authorization(self, request_mock):
await stripe.PaymentIntent.increment_authorization("pi_xxxxxxxxxxxxx", amount=100)
request_mock.assert_requested(
"post",
"/v1/payment_intents/pi_xxxxxxxxxxxxx/increment_authorization"
)

0 comments on commit 71a8dca

Please sign in to comment.