Skip to content

Latest commit

 

History

History
573 lines (449 loc) · 308 KB

File metadata and controls

573 lines (449 loc) · 308 KB

Transactions

Overview

Available Operations

  • list - List transactions
  • create - Create transaction
  • get - Get transaction
  • update - Manually update a transaction
  • capture - Capture transaction
  • void - Void transaction
  • cancel - Cancel transaction
  • sync - Sync transaction

list

Returns a paginated list of transactions for the merchant account, sorted by most recently updated. You can filter, sort, and search transactions using query parameters.

Example Usage

from gr4vy import Gr4vy
from gr4vy.utils import parse_datetime
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.list(cursor="ZXhhbXBsZTE", limit=20, created_at_lte=parse_datetime("2022-01-01T12:00:00+08:00"), created_at_gte=parse_datetime("2022-01-01T12:00:00+08:00"), updated_at_lte=parse_datetime("2022-01-01T12:00:00+08:00"), updated_at_gte=parse_datetime("2022-01-01T12:00:00+08:00"), search="transaction-12345", buyer_external_identifier="buyer-12345", buyer_id="fe26475d-ec3e-4884-9553-f7356683f7f9", buyer_email_address="john@example.com", ip_address="8.214.133.47", status=[
        "authorization_succeeded",
    ], id="7099948d-7286-47e4-aad8-b68f7eb44591", payment_service_transaction_id="tx-12345", external_identifier="transaction-12345", metadata=[
        "{\"first_key\":\"first_value\",\"second_key\":\"second_value\"}",
    ], amount_eq=1299, amount_lte=1299, amount_gte=1299, currency=[
        "USD",
    ], country=[
        "US",
    ], payment_service_id=[
        "fffd152a-9532-4087-9a4f-de58754210f0",
    ], payment_method_id="ef9496d8-53a5-4aad-8ca2-00eb68334389", payment_method_label="1234", payment_method_scheme=[
        "[",
        "\"",
        "v",
        "i",
        "s",
        "a",
        "\"",
        "]",
    ], payment_method_country="[\"US\"]", payment_method_fingerprint="a50b85c200ee0795d6fd33a5c66f37a4564f554355c5b46a756aac485dd168a4", method=[
        "card",
    ], error_code=[
        "insufficient_funds",
    ], has_refunds=True, pending_review=True, checkout_session_id="4137b1cf-39ac-42a8-bad6-1c680d5dab6b", reconciliation_id="7jZXl4gBUNl0CnaLEnfXbt", has_gift_card_redemptions=True, gift_card_id="356d56e5-fe16-42ae-97ee-8d55d846ae2e", gift_card_last4="7890", has_settlements=True, payment_method_bin="411111", payment_source=[
        "recurring",
    ], is_subsequent_payment=True, merchant_initiated=True, used_3ds=True, buyer_search=[
        "J",
        "o",
        "h",
        "n",
    ])

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description Example
cursor OptionalNullable[str] A pointer to the page of results to return. ZXhhbXBsZTE
limit Optional[int] The maximum number of items that are at returned. 20
created_at_lte date Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. 2022-01-01T12:00:00+08:00 must be encoded as 2022-01-01T12%3A00%3A00%2B08%3A00. 2022-01-01T12:00:00+08:00
created_at_gte date Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. 2022-01-01T12:00:00+08:00 must be encoded as 2022-01-01T12%3A00%3A00%2B08%3A00. 2022-01-01T12:00:00+08:00
updated_at_lte date Filters the results to only transactions updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. 2022-01-01T12:00:00+08:00 must be encoded as 2022-01-01T12%3A00%3A00%2B08%3A00. 2022-01-01T12:00:00+08:00
updated_at_gte date Filters the results to only transactions updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. 2022-01-01T12:00:00+08:00 must be encoded as 2022-01-01T12%3A00%3A00%2B08%3A00. 2022-01-01T12:00:00+08:00
search OptionalNullable[str] N/A transaction-12345
buyer_external_identifier OptionalNullable[str] N/A buyer-12345
buyer_id OptionalNullable[str] N/A fe26475d-ec3e-4884-9553-f7356683f7f9
buyer_email_address OptionalNullable[str] N/A john@example.com
ip_address OptionalNullable[str] N/A 8.214.133.47
status List[models.TransactionStatus] Filters the results to only the transactions that have a status that matches with any of the provided status values.
id OptionalNullable[str] N/A 7099948d-7286-47e4-aad8-b68f7eb44591
payment_service_transaction_id OptionalNullable[str] N/A tx-12345
external_identifier OptionalNullable[str] N/A transaction-12345
metadata List[str] Filters for transactions where their metadata values contain all of the provided metadata keys. The value sent for metadata must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. [
{
"first_key": "first_value",
"second_key": "second_value"
}
]
amount_eq OptionalNullable[int] Filters for transactions that have an amount that is equal to the provided amount_eq value. 1299
amount_lte OptionalNullable[int] Filters for transactions that have an amount that is less than or equal to the amount_lte value. 1299
amount_gte OptionalNullable[int] Filters for transactions that have an amount that is greater than or equal to the amount_gte value. 1299
currency List[str] Filters for transactions that have matching currency values. The currency values provided must be formatted as 3-letter ISO currency code. [
"USD"
]
country List[str] Filters for transactions that have matching country values. [
"US"
]
payment_service_id List[str] Filters for transactions that were processed by the provided payment_service_id values. [
"fffd152a-9532-4087-9a4f-de58754210f0"
]
payment_method_id OptionalNullable[str] N/A ef9496d8-53a5-4aad-8ca2-00eb68334389
payment_method_label OptionalNullable[str] N/A 1234
payment_method_scheme List[str] Filters for transactions where the payment_method_scheme matches one of the provided values. [
"visa"
]
payment_method_country OptionalNullable[str] Filters for transactions that have a payment method with a country that matches with the provided value.
payment_method_fingerprint OptionalNullable[str] N/A a50b85c200ee0795d6fd33a5c66f37a4564f554355c5b46a756aac485dd168a4
method List[models.Method] Filters for transactions that have matching method values.
error_code List[str] Filters for transactions where the error_code matches one for the provided values. [
"insufficient_funds"
]
has_refunds OptionalNullable[bool] Filters for transactions with refunds. true
pending_review OptionalNullable[bool] Filters for transactions with a pending manual anti-fraud review. true
checkout_session_id OptionalNullable[str] Filters for transactions where the checkout_session_id matches the provided value. 4137b1cf-39ac-42a8-bad6-1c680d5dab6b
reconciliation_id OptionalNullable[str] Filters for transactions where the reconciliation_id matches the provided value. 7jZXl4gBUNl0CnaLEnfXbt
has_gift_card_redemptions OptionalNullable[bool] Filters for transactions with gift card redemptions. true
gift_card_id OptionalNullable[str] Filters for transactions where a gift card used has an id that matches the provided value. 356d56e5-fe16-42ae-97ee-8d55d846ae2e
gift_card_last4 OptionalNullable[str] Filters for transactions that have at least one gift card redemption where the last 4 digits of its gift card number matches exactly with the provided value. 7890
has_settlements OptionalNullable[bool] Filters for transactions that have at least one associated settlement record. true
payment_method_bin OptionalNullable[str] Filter for transactions that have a card with a BIN that matches exactly with the provided value. 411111
payment_source List[models.TransactionPaymentSource] Filters the results to only the transactions that have a payment source that matches with any of the provided values.
is_subsequent_payment OptionalNullable[bool] Filters for transactions where the is_subsequent_payment matches the provided value. true
merchant_initiated OptionalNullable[bool] Filters for transactions where the merchant_initiated matches the provided value. true
used_3ds OptionalNullable[bool] Filters for transactions that attempted 3DS authentication or not. true
disputed OptionalNullable[bool] Filters for transactions that have been disputed. true
buyer_search List[str] Filters the results to only get the items for which some of the buyer data contains exactly the provided buyer_search values. [
"John",
"London"
]
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListTransactionsResponse

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

create

Create a new transaction using a supported payment method. If additional buyer authorization is required, an approval URL will be returned. Duplicated gift card numbers are not supported.

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.create(amount=1299, currency="EUR", idempotency_key="request-12345", store=True, is_subsequent_payment=True, merchant_initiated=True, async_capture=True, account_funding_transaction=True, allow_partial_authorization=False)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
amount int ✔️ The monetary amount for this transaction, in the smallest currency unit for the given currency, for example 1299 cents to create an authorization for $12.99. If the intent is set to capture, an amount greater than zero must be supplied. All gift card amounts are subtracted from this amount before the remainder is charged to the provided payment_method. 1299
currency str ✔️ A supported ISO 4217 currency code. For redirect requests, this value must match the one specified for currency in payment_method. Example 1: EUR
Example 2: GBP
Example 3: USD
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
idempotency_key OptionalNullable[str] A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. request-12345
x_forwarded_for Optional[str] The IP address to forward from the customer. Use this when calling
our API from the server side to ensure the customer's address is
passed to downstream services, rather than your server IP.
192.168.0.2
country OptionalNullable[str] The 2-letter ISO code of the country where the transaction is processed. This is also used to filter the payment services that can process the transaction. If this value is provided for redirect requests and it's not null, it must match the one specified for country in payment_method. Otherwise, the value specified for country in payment_method will be assumed implicitly. US
payment_method OptionalNullable[models.TransactionCreatePaymentMethod] The optional payment method to use for this transaction. This field is required if no gift_cards have been added.
buyer OptionalNullable[models.GuestBuyer] Guest buyer details provided inline rather than creating a buyer resource beforehand and using the buyer_id or buyer_external_identifier keys. No buyer resource will be created on Gr4vy when used.
buyer_id OptionalNullable[str] The ID of the buyer to associate this payment method to. If this field is provided then the buyer_external_identifier field needs to be unset. If a stored payment method or gift card is provided, then the buyer for that payment method needs to match the buyer for this field. fe26475d-ec3e-4884-9553-f7356683f7f9
buyer_external_identifier OptionalNullable[str] The external_identifier of the buyer to associate this payment method to. If this field is provided then the buyer_id field needs to be unset. If a stored payment method or gift card is provided, then the buyer for that payment method needs to match the buyer for this field. buyer-12345
gift_cards List[models.GiftCardUnion] The optional gift card(s) to use for this transaction. At least one gift card is required if no other payment_method has been added. By default, only a maximum limit of 10 gift cards may be used in a single transaction. Please contact our team to change this limit.
external_identifier OptionalNullable[str] An external identifier that can be used to match the transaction against your own records. transaction-12345
intent Optional[models.TransactionIntent] N/A
store Optional[bool] Whether or not to also try and store the payment method with us so that it can be used again for future use. This is only supported for payment methods that support this feature. There are also a few restrictions on how the flag may be set:

* The flag has to be set to true when the payment_source is set to recurring or installment, and merchant_initiated is set to false.
* The flag has to be set to false (or not set) when using a previously vaulted payment method.
true
three_d_secure_data OptionalNullable[models.ThreeDSecureData] Pass through 3-D Secure data to support external 3-D Secure authorisation. If using an external 3-D Secure provider, you should not pass a redirect_url in the payment_method object for a transaction.
three_d_secure OptionalNullable[models.ThreeDSecure] Optional 3-D Secure values to use during the authentication flow.
metadata Dict[str, str] Any additional information about the transaction that you would like to store as key-value pairs. This data is passed to payment service providers that support it. {
"cohort": "cohort-12345",
"order": "order-12345"
}
is_subsequent_payment Optional[bool] Indicates whether the transaction represents a subsequent payment coming from a setup recurring payment. Please note there are some restrictions on how this flag may be used.

The flag can only be false (or not set) when the transaction meets one of the following criteria:

* It is not merchant_initiated.
* payment_source is set to card_on_file.

The flag can only be set to true when the transaction meets one of the following criteria:
* It is not merchant_initiated.
* payment_source is set to recurring or installment and merchant_initiated is set to true.
* payment_source is set to card_on_file.
true
merchant_initiated Optional[bool] Indicates whether the transaction was initiated by the merchant (true) or customer (false). true
payment_source Optional[models.TransactionPaymentSource] The way payment method information made it to this transaction.
airline OptionalNullable[models.Airline] The airline addendum data which describes the airline booking associated with this transaction.
cart_items List[models.CartItem] An array of cart items that represents the line items of a transaction.
statement_descriptor OptionalNullable[models.StatementDescriptor] Details about the payment and the merchant which may end up on the (bank) statement for the payment.
previous_scheme_transaction_id OptionalNullable[str] A scheme's transaction identifier to use in connecting a merchant initiated transaction to a previous customer initiated transaction. If not provided, and a qualifying customer initiated transaction has been previously made with the stored payment method, then Gr4vy will populate this value with the identifier returned for that transaction. This field is also know as the Visa Transaction Identifier, or Mastercard Trace ID. 123456789012345
browser_info OptionalNullable[models.BrowserInfo] Information about the browser used by the buyer. This can be used by anti-fraud services.
shipping_details_id OptionalNullable[str] The unique identifier of a set of shipping details stored for the buyer. If provided, the created transaction will include a copy of the details at the point of transaction creation; i.e. it will not be affected by later changes to the detail in the database. bf8c36ad-02d9-4904-b0f9-a230b149e341
connection_options OptionalNullable[models.TransactionConnectionOptions] Allows for passing optional configuration per connection to take advantage of connection specific features. When provided, the data is only passed to the target connection type to prevent sharing configuration across connections. Please note that each of the keys this object are in kebab-case, for example cybersource-anti-fraud as they represent the ID of the connector. All the other keys will be snake case, for example merchant_defined_data or camel case to match an external API that the connector uses.
async_capture Optional[bool] Whether to capture the transaction asynchronously when an authorization-capture split occurs.

This flag is only used if the transaction flow is split between authorization and capture.
The split itself is not controlled by this flag and depends on other conditions, including delayed capture support, direct capture support, card scheme, gift cards, and anti-fraud decision.

- When async_capture is false (default) and applicable, the capture is attempted in the same request.
- When async_capture is true and applicable, the capture is performed outside the context of this request.

Redirect transactions are not affected by this flag. This flag can only be set to true when intent is set to capture. Please check the public documentation for full authorization-capture split behavior details.
true
anti_fraud_fingerprint OptionalNullable[str] This field represents the fingerprint data to be passed to the active anti-fraud service. yGeBAFYgFmM=
payment_service_id OptionalNullable[str] The unique identifier of an existing payment service. When provided, the created transaction will be processed by the given payment service and any routing rules will be skipped. fffd152a-9532-4087-9a4f-de58754210f0
account_funding_transaction Optional[bool] Marks the transaction as an AFT. Requires the payment service to support this feature, and might recipient and buyer data true
allow_partial_authorization Optional[bool] Defines if the transaction will allow for a partial authorization.
recipient OptionalNullable[models.Recipient] The recipient of any account to account funding. For use with AFTs.
installment_count OptionalNullable[int] The number of installments a buyer is required to make.
tax_amount OptionalNullable[int] The sales tax amount for this transaction, represented as a monetary amount in the smallest currency unit for the given currency, for example 1299 cents to create an authorization for $12.99 1299
merchant_tax_id OptionalNullable[str] Merchant tax ID (for example, EIN or VAT number).
purchase_order_number OptionalNullable[str] Invoice number or Purchase Order number.
customer_reference_number OptionalNullable[str] Customer code or reference.
amount_includes_tax OptionalNullable[bool] Whether the tax is included in the amount. false
supplier_order_number OptionalNullable[str] The merchant's unique identifier for the sales order or invoice.
duty_amount OptionalNullable[int] Total charges for import/export duties. 1299
shipping_amount OptionalNullable[int] Total shipping amount. 1299
integration_client OptionalNullable[models.IntegrationClient] Defines the client where the session for this transaction is going to be used. Please refer to the connections documentation for more guidance. web
approval_expires_at date The date and time when the buyer's approval window for this transaction expires. If not provided, this is automatically computed from the connector's default expiration time. The value cannot exceed the connector's maximum approval window. 2026-04-01T12:00:00+00:00
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Transaction

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

get

Retrieve the details of a transaction by its unique identifier.

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.get(transaction_id="7099948d-7286-47e4-aad8-b68f7eb44591")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
transaction_id str ✔️ The ID of the transaction 7099948d-7286-47e4-aad8-b68f7eb44591
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Transaction

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

update

Manually updates a transaction.

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.update(transaction_id="7099948d-7286-47e4-aad8-b68f7eb44591")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
transaction_id str ✔️ The ID of the transaction 7099948d-7286-47e4-aad8-b68f7eb44591
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
external_identifier OptionalNullable[str] An external identifier that can be used to match the transaction against your own records. transaction-12345
metadata Dict[str, str] Additional information about the transaction stored as key-value pairs. If provided, the whole value will be overridden. {
"cohort": "cohort-12345",
"order": "order-12345"
}
connection_options OptionalNullable[models.TransactionConnectionOptions] Allows for passing optional configuration per connection to take advantage of connection specific features. When provided, the data is only passed to the target connection type to prevent sharing configuration across connections. Please note that each of the keys this object are in kebab-case, for example cybersource-anti-fraud as they represent the ID of the connector. All the other keys will be snake case, for example merchant_defined_data or camel case to match an external API that the connector uses. If provided, the whole value will be overridden.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Transaction

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

capture

Captures a previously authorized transaction. You can capture the full or a partial amount, as long as it does not exceed the authorized amount (unless over-capture is enabled).

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.capture(transaction_id="7099948d-7286-47e4-aad8-b68f7eb44591")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
transaction_id str ✔️ The ID of the transaction 7099948d-7286-47e4-aad8-b68f7eb44591
prefer List[str] The preferred resource type in the response.
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
idempotency_key OptionalNullable[str] A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. request-12345
amount OptionalNullable[int] The amount to capture, in the smallest currency unit (e.g., cents). This must be less than or equal to the authorized amount, unless over-capture is available. 1299
airline OptionalNullable[models.Airline] The airline data to submit to the payment service during the capture call.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Response200CaptureTransaction

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

void

Voids a previously authorized transaction. If the transaction was not yet successfully authorized, or was already captured, the void will not be processed. This operation releases the hold on the buyer's funds. Captured transactions can be refunded instead.

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.void(transaction_id="7099948d-7286-47e4-aad8-b68f7eb44591")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
transaction_id str ✔️ The ID of the transaction 7099948d-7286-47e4-aad8-b68f7eb44591
prefer List[str] The preferred resource type in the response.
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
idempotency_key OptionalNullable[str] A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. request-12345
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Response200VoidTransaction

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

cancel

Cancels a pending transaction. If the transaction was successfully authorized, or was already captured, the cancel will not be processed.

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.cancel(transaction_id="7099948d-7286-47e4-aad8-b68f7eb44591")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
transaction_id str ✔️ The ID of the transaction 7099948d-7286-47e4-aad8-b68f7eb44591
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TransactionCancel

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*

sync

Synchronizes the status of a transaction with the underlying payment service provider. This is useful for transactions in a pending state to check if they've been completed or failed. Only available for some payment service providers.

Example Usage

from gr4vy import Gr4vy
import os


with Gr4vy(
    merchant_account_id="default",
    bearer_auth=os.getenv("GR4VY_BEARER_AUTH", ""),
) as g_client:

    res = g_client.transactions.sync(transaction_id="2ee546e0-3b11-478e-afec-fdb362611e22")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
transaction_id str ✔️ N/A
merchant_account_id Optional[str] The ID of the merchant account to use for this request. default
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Transaction

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.APIError 4XX, 5XX */*