### HTTP Basic Authentication Request Example Source: https://developer.briqpay.com/docs/3.0.0/api/get-token Demonstrates how to make an authenticated GET request using HTTP Basic Authentication. This example shows the setup of an HttpClient, constructing the request with necessary headers, and sending it to the BriqPay API. It requires a tokenId for the path and includes Accept and Authorization headers. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://playground-api.briqpay.com/v3/token/:tokenId"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### HTTP Basic Authentication Example (C#) Source: https://developer.briqpay.com/docs/3.0.0/api/update-metadata Demonstrates how to perform an HTTP PATCH request with Basic Authentication using C#'s HttpClient. This example includes setting headers, request content, and handling the response. It requires the .NET framework. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Patch, "https://playground-api.briqpay.com/v3/session/:sessionId/metadata"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+ "); var content = new StringContent("{ \"urls\": { \"terms\": \"https://example.com/terms\", \"redirect\": \"https://example.com/redirect\" }, \"references\": { \"reference1\": \"000\", \"orderId\": \"12345\", \"customerId\": \"54321\" } }", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Update Token Request - C# Example Source: https://developer.briqpay.com/docs/3.0.0/api/patch-token Demonstrates how to update a token using an HttpClient in C#. This example shows how to set up the request, including headers and content, and send it to the BriqPay API. It requires the System.Net.Http namespace. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Patch, "https://playground-api.briqpay.com/v3/token/:tokenId"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+ উৎকর্ষ"); var content = new StringContent("{\n \"data\": {\n \"billing\": {\n \"streetAddress\": \"string\",\n \"streetAddress2\": \"string\",\n \"zip\": \"string\",\n \"city\": \"string\",\n \"region\": \"string\",\n \"firstName\": \"string\",\n \"lastName\": \"string\",\n \"email\": \"string\",\n \"phoneNumber\": \"string\",\n \"country\": \"SE\"\n },\n \"shipping\": {\n \"streetAddress\": \"string\",\n \"streetAddress2\": \"string\",\n \"zip\": \"string\",\n \"city\": \"string\",\n \"region\": \"string\",\n \"firstName\": \"string\",\n \"lastName\": \"string\",\n \"email\": \"string\",\n \"phoneNumber\": \"string\",\n \"country\": \"SE\"\n }\n }\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### API Request Example Source: https://developer.briqpay.com/docs/3.0.0/api/charge-a-token Example of a JSON payload for sending an API request to Briqpay. This structure includes payment details, product information, and tokenization data. ```json { "payment": { "amount": { "totalAmount": 3000, "totalVatAmount": 600, "imageUrl": "https://example.com/logo.png" }, "products": [ { "productType": "sales_tax", "name": "Sales tax", "reference": "sales_tax", "totalTaxAmount": 1200 }, { "productType": "gift_card", "name": "Gift card", "reference": "gift_card", "giftCardAmount": 1200 } ] }, "tokenization": { "tokenId": "string" } } ``` -------------------------------- ### Capture Status Response Example Source: https://developer.briqpay.com/docs/3.0.0/api/capture-status An example JSON response from the BriqPay API indicating the status of a capture operation. It includes details about the event, status, session, capture, and associated cart items, including sales tax and gift card information. ```json { "event": "capture_status", "status": "pending", "sessionId": "61c16f84-b42e-4e1c-a114-a117a6e1e27d", "captureId": "a3811397-a1fc-44f0-99fd-d134063c9c47", "autoCaptured": true, "isPreExistingCapture": true, "capture": { "createdAt": "2023-04-12T13:16:08.647Z", "captureId": "string", "parentTransactionId": "string", "reservationId": "string", "autoCaptured": true, "pspId": "string", "pspDisplayName": "string", "pspIntegrationName": "string", "email": "string", "phoneNumber": "string", "reference": "string", "amountIncVat": 3000, "amountExVat": 2400, "currency": "SEK", "status": "pending", "sessionId": "string", "cart": [ { "productType": "physical", "name": "Test product", "reference": "testproduct1", "quantity": 2, "quantityUnit": "pc", "taxRate": 2500, "unitPrice": 1200, "unitPriceIncVat": 1500, "discountPercentage": 0, "unitDiscountAmountIncVat": 0, "totalAmount": 3000, "totalVatAmount": 600, "imageUrl": "https://example.com/logo.png" }, { "productType": "sales_tax", "name": "Sales tax", "reference": "sales_tax", "totalTaxAmount": 1200 }, { "productType": "gift_card", "name": "Gift card", "reference": "gift_card", "giftCardAmount": 1200 } ], "pspOrderManagementIds": { "refund": { "apiTransactionId": "string" } } } } ``` -------------------------------- ### Example Cart with Sales Tax Source: https://developer.briqpay.com/docs/3.0.0/guides/guides/additional_guides/orderLines A complete cart example demonstrating the integration of a physical product alongside a separate sales_tax line item. ```JSON "cart": [ { "productType": "physical", "reference": "shirt123", "name": "T-shirt", "quantity": 1, "unitPrice": 2000, "taxRate": 0, "discountPercentage": 0, "unitDiscountAmountIncVat": 0 }, { "productType": "sales_tax", "name": "Sales tax", "reference": "sales_tax", "totalTaxAmount": 160 } ] ``` -------------------------------- ### Order Status Event Example (JSON) Source: https://developer.briqpay.com/docs/3.0.0/api/order-status This JSON object represents an example of an order status event received from BriqPay. It includes details about the transaction, cart items (physical products, sales tax, gift cards), and PSP order management IDs. This is useful for integrating with BriqPay's webhook system to track order updates. ```json { "event": "order_status", "status": "order_pending", "sessionId": "61c16f84-b42e-4e1c-a114-a117a6e1e27d", "transaction": { "createdAt": "2023-04-12T13:16:08.647Z", "expiresAt": "2023-04-12T13:16:08.647Z", "transactionId": "string", "reservationId": "string", "secondaryReservationId": "string", "pspId": "string", "pspDisplayName": "string", "pspIntegrationName": "string", "email": "string", "phoneNumber": "string", "reference": "string", "amountIncVat": 3000, "amountExVat": 2400, "currency": "SEK", "status": "pending", "captureStatus": "not_captured", "refundStatus": "not_refunded", "sessionId": "string", "cart": [ { "productType": "physical", "name": "Test product", "reference": "testproduct1", "quantity": 2, "quantityUnit": "pc", "taxRate": 2500, "unitPrice": 1200, "unitPriceIncVat": 1500, "discountPercentage": 0, "unitDiscountAmountIncVat": 0, "totalAmount": 3000, "totalVatAmount": 600, "imageUrl": "https://example.com/logo.png" }, { "productType": "sales_tax", "name": "Sales tax", "reference": "sales_tax", "totalTaxAmount": 1200 }, { "productType": "gift_card", "name": "Gift card", "reference": "gift_card", "giftCardAmount": 1200 } ], "pspOrderManagementIds": { "cancel": { "apiTransactionId": "string" }, "capture": { "apiTransactionId": "string" }, "refund": { "apiTransactionId": "string" } } } } ``` -------------------------------- ### Order Data Structure Example Source: https://developer.briqpay.com/docs/3.0.0/api/create-session Illustrates the structure of an order object, including product details, company, consumer, billing, and shipping information. It also shows tokenization and address lists. ```json { "order": { "orderId": "string", "orderReference": "string", "currency": "SEK", "totalAmount": 1000, "taxAmount": 200, "items": [ { "productType": "product", "name": "Product Name", "reference": "product_ref", "quantity": 1, "unitPrice": 500, "totalAmount": 500, "totalVatAmount": 100, "imageUrl": "https://example.com/logo.png" }, { "productType": "sales_tax", "name": "Sales tax", "reference": "sales_tax", "totalTaxAmount": 1200 }, { "productType": "gift_card", "name": "Gift card", "reference": "gift_card", "giftCardAmount": 1200 } ] }, "company": { "cin": "0123456789", "name": "string" }, "consumer": { "identificationNumber": "197001011234", "dateOfBirth": "1970-01-01", "name": "John Smith" }, "billing": { "streetAddress": "string", "streetAddress2": "string", "zip": "string", "city": "string", "region": "string", "firstName": "string", "lastName": "string", "email": "string", "phoneNumber": "string", "country": "SE" }, "shipping": { "streetAddress": "string", "streetAddress2": "string", "zip": "string", "city": "string", "region": "string", "firstName": "string", "lastName": "string", "email": "string", "phoneNumber": "string", "country": "SE" }, "tokenization": { "tokenId": "string" }, "billingAddresses": [ { "companyName": "Test company", "streetAddress": "Test street 1", "streetAddress2": "Test street 2", "zip": "12312", "city": "Test city", "region": "", "firstName": "Tester", "lastName": "Testsson", "email": "test@test.com", "phoneNumber": "0123456789", "country": "SE" } ], "shippingAddresses": [ { "companyName": "Test company", "streetAddress": "Test street 1", "streetAddress2": "Test street 2", "zip": "12312", "city": "Test city", "region": "", "firstName": "Tester", "lastName": "Testsson", "email": "test@test.com", "phoneNumber": "0123456789", "country": "SE" } ] } ``` -------------------------------- ### Delete Token API Request Example (C#) Source: https://developer.briqpay.com/docs/3.0.0/api/deactivate-token Demonstrates how to delete a token using the BriqPay API v3.0.0 with C#. This example utilizes HttpClient to send a DELETE request to the specified endpoint, including necessary headers for authentication and content type. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Delete, "https://playground-api.briqpay.com/v3/token/:tokenId"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+ অশ"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Briqpay API Response Schema and Example (JSON) Source: https://developer.briqpay.com/docs/3.0.0/api/patch-token This snippet illustrates the structure of a typical successful response from the Briqpay API. It includes fields for session details, product information, customer data, payment methods, and charge session details. The schema defines data types and possible values for each field, with an example demonstrating a populated response. ```json { "tokenId": "string", "initialSessionId": "string", "state": "active", "country": "SE", "locale": "sv-se", "product": { "type": "payment", "variantId": "a8a7acb2-4c65-4a91-a8e5-d8125bf64fd4" }, "customerType": "business", "expiryDate": "string", "createdAt": "string", "paymentMethod": { "pspId": "string", "name": "string", "category": "string", "pspDisplayName": "string" }, "chargeSessions": [ { "sessionId": "string", "completedAt": "string", "order": { "amountIncVat": 0, "amountExVat": 0, "currency": "string" } } ], "data": { "company": { "cin": "0123456789", "name": "Example Company" }, "consumer": { "dateOfBirth": "1970-01-01", "name": "John Smith" }, "billing": { "companyName": "string", "cin": "0123456789", "streetAddress": "string", "streetAddress2": "string", "zip": "string", "city": "string", "region": "string", "firstName": "string", "lastName": "string", "email": "string", "phoneNumber": "string", "country": "SE" }, "shipping": { "companyName": "string", "cin": "0123456789", "streetAddress": "string", "streetAddress2": "string", "zip": "string", "city": "string", "region": "string", "firstName": "string", "lastName": "string", "email": "string", "phoneNumber": "string", "country": "SE" } } } ``` -------------------------------- ### Initialize Payment Session JSON Structure Source: https://developer.briqpay.com/docs/3.0.0/api/charge-a-token Example of a JSON object representing a Briqpay payment session initialization. It includes session metadata, product details, customer type, and webhook configurations. ```json { "createdAt": "2023-04-12T13:16:08.647Z", "sessionId": "c5674f4f-7e84-405c-a44b-c83736bb7209", "status": "started", "product": { "type": "payment", "intent": "payment_one_time", "variantId": "a8a7acb2-4c65-4a91-a8e5-d8125bf64fd4" }, "customerType": "business", "country": "SE", "locale": "sv-se", "urls": { "terms": "https://example.com/terms", "redirect": "https://example.com/redirect" }, "references": { "reference1": "000", "orderId": "12345", "customerId": "54321" }, "hooks": [ { "eventType": "session_status", "statuses": ["completed"], "method": "POST", "url": "https://example.com/notifications" } ], "clientToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Create Payment Session with C# HttpClient Source: https://developer.briqpay.com/docs/3.0.0/api/create-session Demonstrates how to initialize a new payment session by sending a POST request to the Briqpay API. It includes setting the necessary headers for JSON content and Basic Authentication, alongside a comprehensive payload defining product details, customer information, and webhooks. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://playground-api.briqpay.com/v3/session"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+"); var content = new StringContent("{\n \"product\": {\n \"type\": \"payment\",\n \"intent\": \"payment_one_time\",\n \"variantId\": \"a8a7acb2-4c65-4a91-a8e5-d8125bf64fd4\"\n },\n \"customerType\": \"business\",\n \"country\": \"SE\",\n \"locale\": \"sv-se\",\n \"urls\": {\n \"terms\": \"https://example.com/terms\",\n \"redirect\": \"https://example.com/redirect\"\n },\n \"references\": {\n \"reference1\": \"000\",\n \"orderId\": \"12345\",\n \"customerId\": \"54321\"\n },\n \"hooks\": [\n {\n \"eventType\": \"session_status\",\n \"statuses\": [\n \"completed\"\n ],\n \"method\": \"POST\",\n \"url\": \"https://example.com/notifications\"\n }\n ]\n}"); request.Content = content; ``` -------------------------------- ### POST /v3/session Source: https://developer.briqpay.com/docs/3.0.0/guides/guides/quick_guides/signup_steps/create_signup_session Creates a signup session by making a POST request to the Create session endpoint. This requires relevant information such as country and locale. ```APIDOC ## POST /v3/session ### Description Creates a signup session by making a POST request to the Create session endpoint. This requires relevant information such as country and locale. ### Method POST ### Endpoint `https://playground-api.briqpay.com/v3/session` ### Headers / Authentication - **Content-Type** (string) - `application/json` - **Accept** (string) - `application/json` - **Authorization** (string) - `Basic ` (Username/secret retrieved from backoffice keys page) ### Request Body - **product** (object) - Required - Specifies the product details. - **type** (string) - Required - The type of product, e.g., "signup". - **intent** (string) - Required - The intent of the product, e.g., "signup". - **customerType** (string) - Required - The type of customer, e.g., "business". - **country** (string) - Required - The country code (e.g., "SE"). - **locale** (string) - Required - The locale for the session (e.g., "sv-se"). - **urls** (object) - Required - Contains redirect URLs. - **redirect** (string) - Required - The URL to redirect to after session completion. - **hooks** (array) - Optional - A list of webhooks to be configured for the session. - **eventType** (string) - Required - The type of event to trigger the hook (e.g., "session_status"). - **statuses** (array) - Required - A list of statuses that trigger the hook (e.g., ["completed"]). - **method** (string) - Required - The HTTP method for the webhook (e.g., "POST"). - **url** (string) - Required - The URL for the webhook. ### Request Example ```json { "product": { "type": "signup", "intent": "signup" }, "customerType": "business", "country": "SE", "locale": "sv-se", "urls": { "redirect": "https://example.com/redirect" }, "hooks": [ { "eventType": "session_status", "statuses": ["completed"], "method": "POST", "url": "https://example.com/notifications" } ] } ``` ### Response #### Success Response (200) - **sessionId** (string) - The unique identifier for the created session. - **status** (string) - The current status of the session. - **createdAt** (string) - The timestamp when the session was created. #### Response Example ```json { "sessionId": "sess_abc123xyz789", "status": "pending", "createdAt": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### POST /checkout Source: https://developer.briqpay.com/docs/3.0.0/api/create-session Initializes a new checkout session with specific product details, customer information, and webhook configurations. ```APIDOC ## POST /checkout ### Description Creates a new payment session. This endpoint requires product details, customer type, and configuration for modules and hooks. ### Method POST ### Endpoint https://playground-api.briqpay.com/checkout ### Request Body - **product** (object) - Required - Details about the product, intent, and variant. - **customerType** (string) - Required - Type of customer (e.g., "business"). - **country** (string) - Required - ISO country code. - **locale** (string) - Required - Language locale (e.g., "sv-se"). - **urls** (object) - Required - Redirect and terms URLs. - **references** (object) - Optional - External order and customer references. - **hooks** (array) - Optional - Webhook configurations for event notifications. - **config** (object) - Optional - Session behavior settings. ### Request Example { "product": { "type": "payment", "intent": "payment_one_time", "variantId": "a8a7acb2-4c65-4a91-a8e5-d8125bf64fd4" }, "customerType": "business", "country": "SE", "locale": "sv-se", "urls": { "terms": "https://example.com/terms", "redirect": "https://example.com/redirect" } } ### Response #### Success Response (200) - **sessionId** (string) - Unique identifier for the created session. #### Response Example { "sessionId": "session_123456789" } ``` -------------------------------- ### Refund Status Webhook Payload Example - JSON Source: https://developer.briqpay.com/docs/3.0.0/guides/guides/quick_guides/payment_steps/refunding_orders An example JSON payload for a `refund_status` webhook. This payload indicates the final outcome of a refund operation, including the event type, status, session ID, and refund ID. ```json { "event": "refund_status", "status": "approved", "sessionId": "61c16f84-b42e-4e1c-a114-a117a6e1e27d", "refundId": "a3811397-a1fc-44f0-99fd-d134063c9c47" } ``` -------------------------------- ### POST /sessions Source: https://developer.briqpay.com/docs/3.0.0/api/update-session Create a new Briqpay session to initiate a payment or signup flow. This endpoint returns the necessary tokens and snippets to render the checkout interface. ```APIDOC ## POST /sessions ### Description Initializes a new checkout session. Returns a clientToken and htmlSnippet for rendering the checkout iframe. ### Method POST ### Endpoint /sessions ### Request Body - **product** (object) - Required - Configuration for the Briqpay product (type: 'payment' or 'signup'). - **intent** (string) - Required - The purpose of the session (e.g., 'payment_one_time', 'signup'). - **customerType** (string) - Optional - 'business' or 'consumer'. - **country** (string) - Optional - ISO 3166-1 alpha-2 country code. - **locale** (string) - Optional - Locale string (e.g., 'sv-se'). - **urls** (object) - Required - Contains 'redirect' URL and 'terms' URL. - **references** (object) - Optional - Custom merchant references. ### Response #### Success Response (200) - **sessionId** (string) - Unique identifier for the session. - **clientToken** (string) - Token for client-side SDK integration. - **htmlSnippet** (string) - HTML string to render the checkout iframe. - **status** (string) - Current status of the session. ### Response Example { "sessionId": "c5674f4f-7e84-405c-a44b-c83736bb7209", "status": "started", "clientToken": "eyJhbGciOiJIUzI1Ni...", "htmlSnippet": "