### Complete API Request Example Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md A full example demonstrating how to obtain an integration token and make a GET request to retrieve shipping options. ```bash # 1. Obtain integration token (one-time setup in Admin) # System → Extensions → Integrations → Create new integration # Save and activate, copy the access token # 2. Make API request curl -X GET \ "https://example.com/rest/V1/getDeliveryDataByKlarnaSessionId/abc123def456" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json" # 3. Handle response # Success: Parse shipping_options array and display to user # Error: Check message field and handle appropriately ``` -------------------------------- ### Install Kustom Module Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Commands for initial installation of a Kustom module, including setup upgrades, compilation, and cache flushing. ```bash # Initial installation composer require kustom/module-checkout php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:flush ``` -------------------------------- ### Install Kustom Checkout Module and Run Magento Setup Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Installs the main Kustom Checkout module via Composer and then runs the necessary Magento setup and cache commands. Ensure you have Composer installed and are in your Magento root directory. ```bash composer require kustom/module-checkout php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento cache:flush ``` -------------------------------- ### Example API Request with Basic Auth Source: https://docs.kustom.co/contents/checkout/hosted-payment-page.md Demonstrates how to make a GET request to retrieve a session, including the necessary Authorization and Content-Type headers. ```bash curl -X GET https://api.kustom.co/payments/v1/sessions/ --header "Authorization: Basic RGVtb01lcmNoYW50OkRlbW9QYXNzd29yZA==" --header "Content-Type: application/json" ``` -------------------------------- ### Install Pods Source: https://docs.kustom.co/contents/checkout/integrate-kco-in-your-mobile/ios-integration.md After adding the dependency to your Podfile, run this command to install the SDK. ```bash pod install ``` -------------------------------- ### Get Kustom Module Versions (Simple Output) Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md A simpler command to list installed Kustom module versions. Use this for a quick overview. ```bash # Or simpler output composer show kustom/* ``` -------------------------------- ### Get Authorization Token - Example Credentials Source: https://docs.kustom.co/contents/api/shipping-service-callback Example merchant identifier and API key provided by the TMS. ```plaintext Identifier: "sweMerch123" Key: "smOOOth" ``` -------------------------------- ### Complete Checkout Flow Example Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Demonstrates a complete checkout flow using the previously defined `executeGraphQLMutation` function, starting with cart creation. ```javascript // Complete checkout flow with error handling async function completeCheckout() { try { // 1. Create cart const cartData = await executeGraphQLMutation( 'mutation { createEmptyCart }', {} ); ``` -------------------------------- ### Order Configuration with Locale (GB Example) Source: https://docs.kustom.co/contents/checkout/additional-resources/available-languages.md This JSON example shows how to configure an order, specifying the locale for language localization. It includes details for purchase country, currency, order lines, and merchant URLs. ```json { "purchase_country": "GB", "purchase_currency": "GBP", "locale": "en-GB", "order_amount": 50000, "order_tax_amount": 4545, "order_lines": [ { "type": "physical", "reference": "19-402-USA", "name": "Red T-Shirt", "quantity": 5, "quantity_unit": "pcs", "unit_price": 10000, "tax_rate": 1000, "total_amount": 50000, "total_discount_amount": 0, "total_tax_amount": 4545 } ], "merchant_urls": { "terms": "https://www.example.com/terms.html", "checkout": "https://www.example.com/checkout.html?order_id={checkout.order.id}", "confirmation": "https://www.example.com/confirmation.html?order_id={checkout.order.id}", "push": "https://www.example.com/api/push?order_id={checkout.order.id}" } } ``` -------------------------------- ### Get Authorization Token - Example Nonce, Nonce+Key, and Digest Calculation Source: https://docs.kustom.co/contents/api/shipping-service-callback Illustrates the process of generating a digest for authorization requests, including the nonce, the combined nonce and key, and the resulting SHA256 digest. ```plaintext Nonce: "lRFUpqW7Xd" Nonce+Key: "lRFUpqW7XdsmOOOth" Digest: "8C3891B3162DB3AB61A9B2DA74E6A479553ABA897894E5236ED290C11A0B832B" ``` -------------------------------- ### Happy Flow Example: Consumer Arrives on HPP Source: https://docs.kustom.co/contents/checkout/hosted-payment-page/api-documentation/status-callbacks.md Example JSON payload for a callback when the consumer first arrives on the HPP, indicating the session is in progress. ```APIDOC ### Happy Flow Examples #### Consumer Arrives on HPP ```json { "event_id": "270b2adc-35a4-4524-800a-a5d2b8a96a2c", "session": { "session_id": "35bde117-ce5f-774f-9bcb-ec514a0963ad", "status": "IN_PROGRESS", "updated_at": "2019-05-13T14:51:46.288Z", "expires_at": "2019-05-15T13:51:43.507Z" } } ``` ``` -------------------------------- ### Kustom Elements Installation Script Source: https://docs.kustom.co/contents/checkout/kustom-elements/integration-guide/installation.md This HTML snippet shows how to include the Kustom Elements installation script in the of your page. Ensure this script loads before any Kustom element tags. Replace '{{Your public API key}}' with your actual public API key. ```html ``` -------------------------------- ### HPP Session Response Example Source: https://docs.kustom.co/contents/api/hosted-payment-page/v3/hosted-payment-page/api-documentation/disable-session Example JSON response when a session is found, including authorization token, customer details, and session status. ```json { "authorization_token": "70850a20-a2a0-5c70-810c-096fa6f850bb", "customer": { "date_of_birth": "1987-08-15", "family_name": "string", "given_name": "string", "national_identification_number": "19870815-84932", "title": "Mr" }, "expires_at": "2038-01-19T03:14:07.000Z", "klarna_reference": "ffc25786", "manual_identification": { "challenge": "A78", "customer": { … }, "customer_obfuscated": { … }, "expires_at": "2038-01-19T03:14:07.000Z" }, "order_id": "93d644a2-43f3-11e9-b210-d663bd873d93", "session_id": "a15b228c-02ad-11e9-8eb2-f2801f1b9fd1", "status": "COMPLETED", "updated_at": "2038-01-19T03:14:07.000Z" } ``` -------------------------------- ### Shipping Options API Response Example Source: https://docs.kustom.co/contents/checkout/shipping-assistant/api-integration.md This is an example response from an Integrator providing available shipping options. It includes details like ID, type, carrier, price, and delivery time. ```json { "shipping_options": [{ "id": "id-1070", "type": "postal", "carrier": "postnord", "name": "Postal delivery", "price": 0, "tax_rate": 0, "delivery_time": { "interval": { "earliest": 4, "latest": 6 } }, "class": "standard" }, { "id": "id-1000", "type": "pickup-box", "carrier": "instabox", "name": "Pickup Box", "price": 100, "tax_rate": 0, "delivery_time": { "latest": "2019-10-15T19:00:00Z" }, "locations": [{ "id": "loc-2", "name": "Coop Loet", "price": 500, "address": { "street_address": "Storgatan 59", "postal_code": "97232", "city": "Luleå", "country": "SE" }, "coordinates": { "lat": 65.5850107, "lng": 22.1558937 }, "operational_hours": { "default": [{ "always_open": true }] } }, { "id": "loc-4", "name": "BURMANS BUTIK I BERGVIKEN", "price": 0, "address": { "street_address": "BLOMGATAN 17", "postal_code": "97331", "city": "Luleå", "country": "SE" }, "coordinates": { "lat": 65.5992109, "lng": 22.1487749 }, "operational_hours": { "overrides": { "weekday": { "mon": [{ "always_open": true }], "tue": [{ "open": "09:00", "close": "18:00" }], "thu": [{ "open": "09:00", "close": "19:00" }] } }, "default": [{ "open": "08:00", "close": "18:30" }] } }], "class": "economy" }, { "id": "id-1050", "type": "delivery-address", ``` -------------------------------- ### Example Order Response Source: https://docs.kustom.co/contents/checkout/use-cases/update-ongoing-order.md This is an example of the JSON response received when retrieving an order. It includes details like order ID, status, purchase country, currency, locale, and billing address. ```json { "order_id": "8cf27b55-53e8-6aba-9fb4-7c692e56ddee", "status": "checkout_complete", "purchase_country": "gb", "purchase_currency": "GBP", "locale": "en-GB", "billing_address": { "given_name": "Testperson-se", "family_name": "Approved", "email": "Testperson-se@kustom.co", "// ... more address details" }, "// ... more order details" } ``` -------------------------------- ### Frontend Klarna Payments Integration Example Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md JavaScript code demonstrating how to fetch a client token, load the Klarna SDK, initialize the widget, and authorize a payment. ```javascript // 1. Call GraphQL mutation to get client_token const response = await fetch('/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: `mutation { createKlarnaPaymentsSession(input: { cart_id: "${cartId}" }) { client_token } }` }) }); const { data } = await response.json(); const clientToken = data.createKlarnaPaymentsSession.client_token; // 2. Load Klarna SDK const script = document.createElement('script'); script.src = 'https://x.klarna.com/kp/lib/v1/api.js'; script.onload = () => initKlarna(clientToken); document.head.appendChild(script); // 3. Initialize Klarna widget function initKlarna(clientToken) { Klarna.Payments.init({ client_token: clientToken }); Klarna.Payments.load({ container: '#klarna-payments-container', payment_method_category: 'pay_later' }, (res) => { if (res.show_form) { // Widget loaded successfully } }); } // 4. Authorize payment when customer clicks "Place Order" Klarna.Payments.authorize({ payment_method_category: 'pay_later' }, (res) => { if (res.approved) { // Use res.authorization_token in setPaymentMethodOnCart mutation setPaymentMethod(res.authorization_token); } }); ``` -------------------------------- ### Install Kustom Checkout via Composer Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento.md Use Composer to install the Kustom Checkout module for Adobe Commerce or Magento Open Source. After installation, upgrade the Magento setup and clear the cache. ```bash composer require kustom/module-checkout bin/magento setup:upgrade bin/magento cache:flush ``` -------------------------------- ### Get Magento Version Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Use this command to retrieve the installed Magento version. Ensure you are in the Magento root directory. ```bash # Magento version php bin/magento --version ``` -------------------------------- ### Example URL for Live Environment Source: https://docs.kustom.co/contents/api/api-basics/api-urls.md Constructs the URL for creating an order in the live environment by combining the base URL with the specific endpoint. ```text https://api.kustom.co/payments/v1/authorizations/ ``` -------------------------------- ### Get Kustom Module Versions (JSON Output) Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Retrieve versions of all installed Kustom modules in JSON format. This is useful for programmatic parsing. ```bash # Module versions composer show kustom/* --format=json | jq '.installed[] | {name, version}' ``` -------------------------------- ### Fixed Amount Multiple Goods Subscription Example Source: https://docs.kustom.co/contents/checkout/additional-resources/subscription-object-details.md Shows how to include subscription objects for multiple physical goods with different subscription cadences. One item is monthly, and the other is bi-monthly. ```json "order_lines": [ { "type": "physical", "subscription": { "name": "Savings Subscription {{1234834}}", "interval": "MONTH", "interval_count": 1 }, "reference": "19-402", "name": "Prater Ink Cartridges", "quantity": 1, "unit_price": 360, "tax_rate": 0, "total_amount": 360, "total_discount_amount": 0, "total_tax_amount": 0 }, { "type": "physical", "subscription": { "name": "Savings Subscription {{1822731}}", "interval": "MONTH", "interval_count": 2 }, "reference": "19-402", "name": "Greenstore Deo Cream", "quantity": 1, "unit_price": 790, "tax_rate": 0, "total_amount": 790, "total_discount_amount": 0, "total_tax_amount": 0 } ] ``` -------------------------------- ### Kustom Push Notification Request Example Source: https://docs.kustom.co/contents/checkout/guides/vipps-checkout-to-kustom-checkout.md Kustom GETs your merchant_urls.push URL when an order is completed, appending the order_id as a query parameter. This is a trigger to fetch order state. ```http GET https://example.com/api/kustom/push?kustom_order_id=8cf27b55-53e8-6aba-9fb4-7c692e56ddee ``` -------------------------------- ### Example Response from Integrator Tool (Ghostship) Source: https://docs.kustom.co/contents/checkout/shipping-assistant/api-integration.md A sample response from the Ghostship integration tool, illustrating the structure of a response that includes shipment ID, selected shipping option details, and shipment tracking information. ```json { "header": "Location: https://foo.bar/c2059e35-58b1-4482-ad55-5e7ef541eae4", "body": { "shipment_id": "100", "selected_shipping_option": { "carrier": "budbee", "carrier_product": { "name": "MyPack", "identifier": "10", "addon_identifiers": ["1", "2"] } }, "shipments": [{ "carrier": "Global carrier company", "tracking_id": "12345-6" }] } } ``` -------------------------------- ### Initialize and Load Klarna Widget Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Initializes the Klarna SDK with a client token and loads the payment widget into a specified container. The widget is then ready to be authorized. ```javascript // Initialize Klarna SDK with client_token from Step 5 Klarna.Payments.init({ client_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' }); // Load payment widget Klarna.Payments.load({ container: '#klarna-payments-container', payment_method_category: 'pay_later' }, (res) => { console.log('Widget loaded:', res.show_form); }); // Authorize when customer clicks "Place Order" document.getElementById('place-order-btn').addEventListener('click', () => { Klarna.Payments.authorize({ payment_method_category: 'pay_later' }, (res) => { if (res.approved) { // Proceed to Step 7 with res.authorization_token setPaymentMethodAndPlaceOrder(res.authorization_token); } else { alert('Payment not approved. Please try again.'); } }); }); ``` -------------------------------- ### Verify Kustom Module Installation in Magento Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Checks if all Kustom-related modules are enabled in your Magento installation. This command helps confirm that the installation process was successful and dependencies are recognized. ```bash php bin/magento module:status | grep Klarna ``` -------------------------------- ### List Kustom Modules and Versions Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Command to list all installed Kustom modules along with their version information. ```bash # List all Kustom modules with versions composer show kustom/* | grep -E '^name|^versions' ``` -------------------------------- ### Install Magento Cron Entries Source: https://docs.kustom.co/contents/partners/e-commerce-platforms/magento-comprehensive-guide.md Command to install crontab entries for Magento, ensuring scheduled tasks are registered. ```bash # Install crontab entries php bin/magento cron:install ``` -------------------------------- ### Monthly Streaming Subscription Example Source: https://docs.kustom.co/contents/checkout/additional-resources/subscription-object-details.md Includes the subscription object for a monthly streaming service with a free trial. This demonstrates the 'name', 'interval', and 'interval_count' fields for a monthly cadence. ```json "order_lines": [{ "type": "digital", "subscription": { "name": "Premium Monthly {{1234834}}", "interval": "MONTH", "interval_count": 1 }, "reference": "19-402", "name": "Streaming Service Monthly - Free Trial", "quantity": 1, "unit_price": 0, "tax_rate": 0, "total_amount": 0, "total_discount_amount": 0, "total_tax_amount": 0 }] ``` -------------------------------- ### Example Kustom Element Tag Source: https://docs.kustom.co/contents/checkout/kustom-elements.md This is an example of a Kustom element tag that can be embedded in HTML to display available payment methods. ```html ``` -------------------------------- ### Authentication Payload Example Source: https://docs.kustom.co/contents/checkout/shipping-assistant/api-integration.md The Kustom Shipping Assistant calls POST /auth with merchant-provided credentials. This JSON shows an example payload structure. ```json { "identifier": < username > "secret": { "nonce": < random string > "digest": < encoded nonce + key > } } ``` -------------------------------- ### Example Shipping Method Configuration Source: https://docs.kustom.co/contents/checkout/shipping-assistant/api-integration.md This JSON object represents a single shipping method configuration, including carrier, name, price, tax rate, delivery time, and available addons. ```json { "carrier": "budbee", "name": "To door delivery", "price": 2500, "tax_rate": 2500, "delivery_time": { "earliest": "2019-10-16T16:00:00Z", "latest": "2019-10-16T20:00:00Z" }, "addons": [{ "category": "notifications", "type": "sms" }, { "category": "delivery", "type": "additional-instructions", "max_length": 100 }], "class": "standard" } } ``` -------------------------------- ### HPP Session Status Callback: Completed (Duplicate Example) Source: https://docs.kustom.co/contents/checkout/hosted-payment-page/api-documentation/status-callbacks.md This JSON payload is a duplicate example of a successful payment completion, including an `order_id` and `klarna_reference`. ```json { "event_id": "cd7e1171-25b1-41ff-97d3-b0dd5e6f9a82", "session": { "session_id": "39a1c773-bafd-754d-af1f-b30c592f1267", "status": "COMPLETED", "order_id": "a1a8f727-2756-6058-bd3c-40069be0994b", "klarna_reference": "X438HG0Q", "updated_at": "2019-05-13T14:54:04.675Z", "expires_at": "2019-05-15T13:51:43.507Z" } } ``` -------------------------------- ### Currency Example Source: https://docs.kustom.co/contents/api/api-basics/data-types.md Demonstrates the use of ISO 4217 for currency codes in API requests. ```json { "purchase_currency": "USD" } ``` -------------------------------- ### Initialize KustomCheckoutView in Swift Source: https://docs.kustom.co/contents/checkout/integrate-kco-in-your-mobile/ios-integration.md Create an instance of KustomCheckoutView in your view controller, providing the return URL and an event handler. ```swift var checkoutView: KustomCheckoutView? override func viewDidLoad() { super.viewDidLoad() checkoutView = KustomCheckoutView(returnURL: URL(string: `app-schema://` ), eventHandler: KustomEventHandler) } ``` -------------------------------- ### Disable HPP Session cURL Example Source: https://docs.kustom.co/contents/checkout/hosted-payment-page/api-documentation/disable-session.md Example cURL command to disable an HPP session. Ensure you replace `` and `` with your actual values. ```curl curl -X "DELETE" https://api.kustom.co/hpp/v1/sessions/ --header "Authorization: Basic " ```