Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.gr4vy.com/llms.txt

Use this file to discover all available pages before exploring further.

After the buyer selects their method of payment in the previous step, the transaction is ready to be created.

Create a transaction

The transaction should be populated with the selected method, your redirect_url, and any other relevant transaction information.
  • payment_method.method - This is the method selected by the customer at checkout. This is one of the values retrieved from the payment options endpoint in the previous step.
  • payment_method.redirect_url - This should be provided to redirect the buyer back to the app after they have authenticated the payment. This is also required for card to support 3-D Secure.
See the POST /transactions API endpoint for more details.
var transaction = await client.Transactions.CreateAsync(
    transactionCreate: new TransactionCreate()
    {
        Amount = 1299,
        Currency = "USD",
        Country = "US",
        PaymentMethod =
            TransactionCreatePaymentMethod.CreateCheckoutSessionWithUrlPaymentMethodCreate(
                new RedirectPaymentMethodCreate()
                {
                    Method = "clearpay",
                    RedirectUrl = "https://example.com/callback",
                }
            ),
    }
);
The response of this transaction includes a status, which tells you how to handle the next step.
Requests that require a redirect return a status of buyer_approval_pending with a payment_method.approval_url. The next step shows you how to handle this situation.
{
    "type": "transaction",
    "id": "0c41c8df-27f4-480e-97f0-9401558ae25e",
    "merchant_account_id": "default",
    "created_at": "2023-04-28T08:33:06.979938+00:00",
    "updated_at": "2023-04-28T08:33:14.791510+00:00",
    "amount": 1299,
    "captured_amount": 0,
    "refunded_amount": 0,
    "currency": "AUD",
    "country": "AU",
    "external_identifier": null,
    "status": "buyer_approval_pending",
    "intent": "authorize",
    "payment_method": {
        "type": "payment-method",
        "method": "paypal",
        "mode": "redirect",
        "label": null,
        "scheme": null,
        "expiration_date": null,
        "approval_url": "https://www.sandbox.paypal.com/checkoutnow?token=7NP38594266148058",
        "country": "AU",
        "currency": "AUD",
        "details": null,
        "id": null,
        "approval_target": "any",
        "external_identifier": null
    },
    "method": "paypal",
    "error_code": null,
    "payment_service": {
        "id": "e9bd6ec4-03eb-410c-b655-45b458f185f2",
        "type": "payment-service",
        "payment_service_definition_id": "paypal-paypal",
        "method": "paypal",
        "display_name": "PayPal"
    },
    "buyer": null,
    "raw_response_code": "CREATED",
    "raw_response_description": "",
    "shipping_details": null,
    "avs_response_code": null,
    "cvv_response_code": null,
    "payment_source": "ecommerce",
    "merchant_initiated": false,
    "is_subsequent_payment": false,
    "cart_items": [],
    "statement_descriptor": null,
    "scheme_transaction_id": null,
    "three_d_secure": null,
    "payment_service_transaction_id": "7NP38594266148058",
    "metadata": null,
    "authorized_at": null,
    "captured_at": null,
    "voided_at": null,
    "buyer_approval_timedout_at": null
}

Summary

In this step you:
  • Called the transactions endpoint
  • Handled the transaction response