> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/checkout/alternative-payment-methods/process-gpay-payment-callback.md).

# Process GPay Payment Callback

Processes the callback returned by the Garanti Pay gateway after the customer completes the payment on the provider's hosted form.

The gateway posts its result to this endpoint. Query parameters present on the incoming callback URL are automatically merged with the POST body before validation, so fields returned via redirect query string are handled transparently alongside form-encoded fields.

The submitted payload is verified server-side using a gateway-specific HMAC hash. The `gpinstallment` value is resolved against the card's active instalment records and stored on the pre-order before order finalisation.

**Preconditions**:

* A payment option with `payment_type: gpay` must be selected on the pre-order
* A transaction identifier must be present on the pre-order

**Processing Flow**:

1. Merges GET query parameters from the callback URL into the submitted data
2. Validates `gpay: true` and `success: true` flags from the gateway
3. Resolves `gpinstallment` against the active instalment options for the pre-order's card and stores the resolved instalment on the pre-order
4. Verifies the full payload against the gateway's HMAC hash to confirm authenticity
5. Creates a return transaction record (`transaction_type: return_back`) with the payment outcome; the transaction identifier follows the format `GPAY_{order_number}_{suffix}`
6. On success: finalises the order, submits the basket, sends order confirmation email and SMS notifications, then advances to `ThankYouPage`
7. On failure: performs a full rollback — clears `transaction_id` and the redirect state, resets the order number, and sets `card_info` to `null`, returning the pre-order to the state it held at `GPaySelectionPage`

**No dynamic settings** apply to this page. All behaviour is determined by the static configuration of the Garanti Pay gateway.

```json
{"openapi":"3.1.0","info":{"title":"Overview","version":"1.0.0"},"tags":[{"name":"Alternative Payment Methods","description":"# Checkout Alternative Payment Methods\n\nIntegrate Bex (BKM Express), Garanti Pay (GPay), Cash Register, and Confirmation Payment into your checkout. Each method follows a distinct step sequence—use the one that matches your storefront configuration.\n\n**Bex** is a bank consortium payment method. The flow covers BIN lookup, nonce generation, installment selection, and payment completion.\n\n**Garanti Pay (GPay)** redirects customers to an external page for QR-code or link-based payment and returns them upon completion.\n\n**Cash Register** is a point-of-sale method for store staff. It supports installment selection and in-store payment completion.\n\n**Confirmation Payment** lets the customer place an order first and confirm payment later through a separate channel. The flow includes agreement review and a confirmation step.\n\n## Authentication\n\nThese endpoints support both authenticated and anonymous sessions.\n\n- **Authenticated users**: Session cookie (`sessionid`) tracks checkout progress.\n- **Anonymous users**: Guest checkout is available when the `CAN_GUEST_PURCHASE` setting is enabled.\n## Request Format\n\nInclude the following header in all checkout requests:\n\n- **x-requested-with**: `XMLHttpRequest`\n\n## Dynamic Settings\n\nThe following settings are managed at runtime through the admin interface and do not require a server restart.\n\n### CASH_REGISTER_AUTH_CONF\nAuthentication credentials for the cash register payment service. Includes the service username and password.\n\n### INSTALLMENT_FILTERS\nFilters applied during Bex and Cash Register installment selection to restrict the available options.\n\n## Static Settings\n\nThe following settings are configured in the server environment and require a restart to take effect.\n\n### DEFAULT_CARD_SLUG\nFallback card identifier used when a Bex BIN number lookup returns no match. Defaults to `other`.\n\n### GPAY_BIN_NUMBER\nThe identifier used to look up the virtual card for Garanti Pay transactions. Must match a record in the database. Defaults to `GPAY00`.\n\n### CASH_REGISTER_DEFAULTS\nFallback store staff information (staff ID, email address, and store ID) used when the corresponding request headers are absent."}],"servers":[{"description":"Akinon Checkout API","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com"}}}],"paths":{"/orders/checkout/?page=GPayCompletePage":{"post":{"tags":["Alternative Payment Methods"],"operationId":"submitGPayCompletePage","summary":"Process GPay Payment Callback","description":"Processes the callback returned by the Garanti Pay gateway after the\ncustomer completes the payment on the provider's hosted form.\n\nThe gateway posts its result to this endpoint. Query parameters present\non the incoming callback URL are automatically merged with the POST body\nbefore validation, so fields returned via redirect query string are\nhandled transparently alongside form-encoded fields.\n\nThe submitted payload is verified server-side using a gateway-specific\nHMAC hash. The `gpinstallment` value is resolved against the card's\nactive instalment records and stored on the pre-order before order\nfinalisation.\n\n**Preconditions**:\n- A payment option with `payment_type: gpay` must be selected on the\n  pre-order\n- A transaction identifier must be present on the pre-order\n\n**Processing Flow**:\n1. Merges GET query parameters from the callback URL into the submitted\n   data\n2. Validates `gpay: true` and `success: true` flags from the gateway\n3. Resolves `gpinstallment` against the active instalment options for\n   the pre-order's card and stores the resolved instalment on the\n   pre-order\n4. Verifies the full payload against the gateway's HMAC hash to confirm\n   authenticity\n5. Creates a return transaction record (`transaction_type: return_back`)\n   with the payment outcome; the transaction identifier follows the\n   format `GPAY_{order_number}_{suffix}`\n6. On success: finalises the order, submits the basket, sends order\n   confirmation email and SMS notifications, then advances to\n   `ThankYouPage`\n7. On failure: performs a full rollback — clears `transaction_id` and\n   the redirect state, resets the order number, and sets `card_info`\n   to `null`, returning the pre-order to the state it held at\n   `GPaySelectionPage`\n\n**No dynamic settings** apply to this page. All behaviour is determined\nby the static configuration of the Garanti Pay gateway.","parameters":[{"$ref":"#/components/parameters/AjaxRequestHeader"},{"$ref":"#/components/parameters/SessionCookieHeader"}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/GPayCompletePageInput"}}}},"responses":{"200":{"description":"GPay callback processed. On success the order is finalised and the flow advances to `ThankYouPage`. On failure a full rollback is performed and a validation error is returned so the customer may retry from the payment selection step.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutResponse"}}}},"302":{"description":"Redirect to basket (empty basket) or login (guest purchase not allowed)"}}}}},"components":{"parameters":{"AjaxRequestHeader":{"name":"x-requested-with","in":"header","required":true,"description":"Required header for AJAX requests. Must be set to `XMLHttpRequest` for all checkout requests.","schema":{"type":"string","enum":["XMLHttpRequest"],"default":"XMLHttpRequest"}},"SessionCookieHeader":{"name":"Cookie","in":"header","required":false,"description":"Session cookie header (e.g. `sessionid=abc123` or `osessionid=<session_id>`)","schema":{"type":"string"}}},"schemas":{"GPayCompletePageInput":{"type":"object","description":"Callback payload posted by the Garanti Pay gateway after the customer\ncompletes the payment on the provider's hosted form.\nAll three fields are required. `gpay` and `success` must both be `true`\nfor the payment to be accepted. `gpinstallment` carries the instalment\ncount selected by the customer on the Garanti Pay form and is resolved\nagainst the active instalment options for the pre-order's card.\nThe full payload (including any additional fields returned by the gateway)\nis also verified against a gateway-specific HMAC hash. Payloads that fail\nhash verification are rejected regardless of the `gpay` and `success`\nvalues.","required":["gpay","success","gpinstallment"],"properties":{"gpay":{"type":"boolean","enum":[true],"description":"Garanti Pay authorisation flag returned by the gateway. Must be `true`; any other value is treated as a failed transaction."},"success":{"type":"boolean","enum":[true],"description":"Payment success flag returned by the gateway. Must be `true`; any other value is treated as a failed transaction."},"gpinstallment":{"type":"string","description":"Instalment count selected by the customer on the Garanti Pay hosted form (e.g. `\"1\"` for a single payment, `\"3\"` for three instalments). The value is resolved against the active instalment records for the pre-order's card. If no matching active instalment is found the resolved instalment on the pre-order is set to `null`."}}},"CheckoutResponse":{"type":"object","properties":{"context_list":{"type":"array","items":{"$ref":"#/components/schemas/PageContext"}},"pre_order":{"$ref":"#/components/schemas/PreOrder"},"errors":{"oneOf":[{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}},{"type":"null"},{"type":"array","items":{"type":"string"}}]},"template_name":{"type":"string"}}},"PageContext":{"type":"object","properties":{"page_name":{"type":"string","description":"Class name of the page (e.g., \"IndexPage\", \"AddressSelectionPage\")"},"page_slug":{"type":"string","description":"URL-friendly slug for the page"},"page_context":{"type":"object","description":"Page-specific context data","additionalProperties":true}}},"PreOrder":{"type":"object","description":"Pre-order state containing basket, addresses, shipping, payment information","properties":{"basket":{"$ref":"#/components/schemas/Basket"},"shipping_address":{"oneOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}]},"billing_address":{"oneOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}]},"shipping_option":{"oneOf":[{"$ref":"#/components/schemas/ShippingOptionDetail"},{"type":"null"}]},"billing_and_shipping_same":{"oneOf":[{"type":"boolean"},{"type":"null"}]},"payment_option":{"oneOf":[{"$ref":"#/components/schemas/PaymentOptionDetail"},{"type":"null"}]},"notifications":{"type":"array","items":{"type":"object"}},"shipping_amount":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"total_amount":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"unpaid_amount":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"loyalty_money":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"currency_type_label":{"type":"string"},"installment":{"oneOf":[{"$ref":"#/components/schemas/Installment"},{"type":"null"}]},"card_info":{"oneOf":[{"type":"object","description":"Card information from BIN lookup","properties":{"bin_number":{"type":"string","description":"Card BIN (first 6-8 digits)"},"card":{"type":"object","description":"Card details from BIN database","properties":{"pk":{"type":"integer"},"name":{"type":"string","description":"Card type name (e.g., \"Visa\", \"Mastercard\")"}}}}},{"type":"null"}]},"redirect_to_three_d":{"oneOf":[{"type":"boolean"},{"type":"null"}]},"delivery_option":{"oneOf":[{"$ref":"#/components/schemas/DeliveryOption"},{"type":"null"}]},"retail_store":{"oneOf":[{"$ref":"#/components/schemas/RetailStore"},{"type":"null"}]},"funds_transfer_bank":{"oneOf":[{"$ref":"#/components/schemas/BankAccount"},{"type":"null"}]},"number":{"oneOf":[{"type":"string","description":"Pre-order/order number"},{"type":"null"}]},"order":{"oneOf":[{"type":"object","description":"Created order (after checkout completion)","properties":{"pk":{"type":"integer"},"number":{"type":"string"},"status":{"type":"string"}}},{"type":"null"}]},"payment_choice":{"oneOf":[{"$ref":"#/components/schemas/PaymentChoice"},{"type":"null"}]},"user_email":{"oneOf":[{"type":"string"},{"type":"null"}]},"phone_number":{"oneOf":[{"type":"string"},{"type":"null"}]},"user_phone_number":{"oneOf":[{"type":"string"},{"type":"null"}]},"gift_box":{"oneOf":[{"type":"object","properties":{"note":{"type":"string"},"gift_video":{"type":"boolean"},"gift_video_notification_sent":{"type":"boolean"},"price":{"type":"string"}}},{"type":"null"}]},"delivery_range":{"oneOf":[{"type":"object","properties":{"lower":{"type":"string","format":"date-time"},"upper":{"type":"string","format":"date-time"}}},{"type":"null"}]},"total_amount_with_interest":{"oneOf":[{"type":"string","pattern":"^\\d+\\.\\d{2}$"},{"type":"null"}]},"is_guest":{"type":"boolean"},"is_post_order":{"type":"boolean"},"data_source_shipping_options":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/DataSourceShippingOptionDetail"}},{"type":"null"}]},"attribute_based_shipping_options":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/PreOrderAttributeBasedShippingOption"}},{"type":"null"}]}}},"Basket":{"type":"object","properties":{"pk":{"type":"integer"},"total_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"}}},"Address":{"type":"object","properties":{"pk":{"type":"integer"},"email":{"type":"string"},"phone_number":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"country":{"$ref":"#/components/schemas/Country"},"city":{"$ref":"#/components/schemas/City"},"line":{"type":"string"},"title":{"type":"string"},"township":{"$ref":"#/components/schemas/Township"},"district":{"oneOf":[{"$ref":"#/components/schemas/District"},{"type":"null"}]},"postcode":{"type":"string"},"notes":{"type":"string"},"company_name":{"type":"string"},"tax_office":{"type":"string"},"tax_no":{"type":"string"},"e_bill_taxpayer":{"type":"boolean"},"is_corporate":{"type":"boolean"},"primary":{"type":"boolean"},"identity_number":{"type":"string"}}},"Country":{"type":"object","properties":{"pk":{"type":"integer"},"code":{"type":"string"},"name":{"type":"string"}}},"City":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"}}},"Township":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"}}},"District":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"}}},"ShippingOptionDetail":{"type":"object","description":"Detailed shipping option with calculated amount","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"oneOf":[{"type":"string","format":"uri"},{"type":"null"}]},"shipping_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"description":{"oneOf":[{"type":"string"},{"type":"null"}]},"kwargs":{"type":"object","additionalProperties":true}}},"PaymentOptionDetail":{"type":"object","description":"Detailed payment option with type information","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"payment_type":{"type":"string","enum":["credit_card","funds_transfer","bkm_express","loyalty_money","cash_register","gpay","redirection","stored_card","masterpass","masterpass_rest","credit_payment","pay_later","saved_card","confirmation","b2b","wallet","pay_on_delivery"]},"payment_type_label":{"type":"string"}}},"Installment":{"type":"object","properties":{"pk":{"type":"integer"},"installment_count":{"type":"integer"},"label":{"type":"string"},"price_with_accrued_interest":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"monthly_price_with_accrued_interest":{"type":"string","pattern":"^\\d+\\.\\d{2}$"}}},"DeliveryOption":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"delivery_option_type":{"type":"string","enum":["customer","retail_store","pickup_location"]},"is_active":{"type":"boolean"}}},"RetailStore":{"type":"object","properties":{"pk":{"type":"integer"},"name":{"type":"string"},"erp_code":{"type":"string"},"township":{"$ref":"#/components/schemas/Township"},"click_and_collect":{"type":"boolean"},"is_active":{"type":"boolean"}}},"BankAccount":{"type":"object","description":"Bank account for funds transfer payments","properties":{"pk":{"type":"integer"},"bank_name":{"type":"string","description":"Name of the bank"},"account_holder":{"type":"string","description":"Account holder name"},"iban":{"type":"string","description":"International Bank Account Number"},"currency":{"type":"string","description":"Currency code (e.g., \"USD\", \"EUR\", \"TRY\")"},"is_active":{"type":"boolean"}}},"PaymentChoice":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"},"price":{"type":"string","pattern":"^\\d+\\.\\d{2}$"}}},"DataSourceShippingOptionDetail":{"type":"object","description":"Data source shipping option for multi-vendor shipping","properties":{"pk":{"type":"integer"},"shipping_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"shipping_option_name":{"type":"string"},"shipping_option_logo":{"oneOf":[{"type":"string","format":"uri"},{"type":"null"}]},"data_source":{"type":"object","properties":{"pk":{"type":"integer"},"title":{"type":"string"}}},"description":{"oneOf":[{"type":"string"},{"type":"null"}]}}},"PreOrderAttributeBasedShippingOption":{"type":"object","description":"Attribute-based shipping option selected for a product group","properties":{"pk":{"type":"integer"},"shipping_option_name":{"type":"string"},"shipping_option_logo":{"oneOf":[{"type":"string","format":"uri"},{"type":"null"}]},"shipping_amount":{"type":"string","pattern":"^\\d+\\.\\d{2}$"},"product_ids":{"type":"array","items":{"type":"integer"}},"attribute_value":{"type":"string"},"attribute_key":{"oneOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://apidocs.akinon.com/commerce-openapis/checkout/alternative-payment-methods/process-gpay-payment-callback.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
