feat(order): add AP dataclasses, docs and example for automatic payments (IXE-679)#115
Merged
Conversation
…change and refresh Enables marketplace and platform integrations to operate on behalf of other sellers via the OAuth 2.0 authorization code flow. Operations: - get_authorization_url(): builds https://auth.mercadopago.com/authorization?... - create(): POST /oauth/token (exchange authorization code for access token) - refresh(): POST /oauth/token (refresh expired token) Ref: sdk-php/src/MercadoPago/Client/OAuth/OAuthClient.php
- test_oauth: validates URL builder output and ValueError on non-dict input - test_point: validates HTTP response range and ValueError on non-dict input - test_invoice: validates HTTP response range for search operation
- examples/oauth/create_token.py: authorization URL + token exchange flow - examples/point/create_payment_intent.py: list devices, create and get payment intent - examples/invoice/get_invoice.py: search invoices by preapproval_id and get by ID
- resources/__init__.py: add Invoice, OAuth, Point imports and __all__ entries - sdk.py: add Invoice, OAuth, Point imports and factory methods (sdk.invoice(), sdk.oauth(), sdk.point())
New features in this release: - OAuth: authorization URL, token exchange and refresh (POST /oauth/token) - Point: payment intents and device management (/point/integration-api/...) - Invoice: get and search subscription invoices (GET /authorized_payments) Note: version bump in pyproject.toml and config.py requires approval before merge.
New features in this release: - OAuth: authorization URL, token exchange and refresh (POST /oauth/token) - Point: payment intents and device management (/point/integration-api/...) - Invoice: get and search subscription invoices (GET /authorized_payments)
…nts (IXE-679) Add typed helpers and documentation for the Automatic Payments flow in the Orders API. The SDK remains dict-based; these additions are optional conveniences for developers who prefer typed objects. New dataclasses (mercadopago/resources/): - order_stored_credential.py: OrderStoredCredential — includes the new prev_transaction_ref field, required from the second recurring charge onwards to link the payment to the original card-network authorization. - order_automatic_payments.py: OrderAutomaticPayments — payment_profile_id, retries, schedule_date, due_date. - order_subscription_data.py: OrderSubscriptionData, OrderSubscriptionSequence, OrderInvoicePeriod — full subscription billing cycle support. - order_integration_data.py: OrderIntegrationData, OrderSponsor — integration metadata for marketplace and platform identification. Updated: - order.py: added class-level docstring documenting all AP-supported dict keys with types (stored_credential, automatic_payments, subscription_data, integration_data). New example: - examples/order/create_order_automatic_payment.py: full AP flow showing first payment (first_payment=True) and recurring charge (prev_transaction_ref=prev_tx_id) using dataclasses.asdict(). No break changes: existing dict-based API is unmodified. Developers use dataclasses.asdict() to convert typed objects to the dict the SDK expects. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Remove the unused 'field' import from dataclasses in order_stored_credential.py and order_subscription_data.py to resolve pylint W0611 warnings. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New dataclasses for the Automatic Payments flow — optional typed helpers; the existing dict-based API is unchanged.
New files (
mercadopago/resources/):order_stored_credential.py→OrderStoredCredential— includesprev_transaction_ref, required from the second recurring charge onwards.order_automatic_payments.py→OrderAutomaticPaymentsorder_subscription_data.py→OrderSubscriptionData+OrderSubscriptionSequence+OrderInvoicePeriodorder_integration_data.py→OrderIntegrationData+OrderSponsorUpdated:
order.py→ class-level docstring documenting all AP dict keys with types.New example:
examples/order/create_order_automatic_payment.py→ full AP flow: first payment (first_payment=True) and recurring charge (prev_transaction_ref=prev_tx_id).How to use
Both approaches (plain dict and dataclass) produce identical JSON. The dataclass is optional.
Context
Part of IXE-679: fields required for the Automatic Payments flow in the Orders API were missing from the public SDKs. Companion PRs exist for Java, Go, .NET, Node.js, PHP and Ruby.
Test plan
python -m py_compileon all new files — OKGenerated with Claude Code