Developer Docs
  • 👋Get Started
  • Add Payment Methods in Optty
  • Custom API | Headless
    • 🖥️Direct API Integration
      • Environments
      • Order Flow
      • 1️⃣Create Access Token
      • 2️⃣Get APM Options
      • 3️⃣Create Order
      • 4️⃣Handle Payment Response
      • 5️⃣Refund Order
      • 🔥Handling Exceptions
  • Platforms
    • ◾BigCommerce
      • 🚀Activate Optty
      • ⚡Add Optty Widgets
        • 1️⃣Install the App
        • 2️⃣Create Widget Token
        • 3️⃣Edit Your Template
        • 4️⃣Widget Configuration
      • 💳Refunds
    • Magento 2
      • Install Optty Module
      • Configure the Optty Extension
      • One Step Checkout
    • Salesforce Commerce Cloud
      • Component Overview
      • Implementation Guide
      • Operation and Management
      • User Guide
    • 🟪WooCommerce
      • 🚀Install Optty
      • ⚡Setup Widgets
      • 💳Refunds
  • Widget
    • Widget Setup and Integration
    • Create Order Widget Integration
    • Handle Order Payment Widget Integration
  • API References
    • Create Order
      • Create Order Response
    • Refund Order
    • Void Order
    • Capture Order
    • Transaction Details
    • Create Customer Session
    • Best Practice
  • Go Live
  • Universal Payment Platform
    • Support Articles
Powered by GitBook
On this page
  • Testing the Optty Handle Order Payment Widget in Sandbox Mode
  • Handle Order Payment Widget Setup and Integration
  • Step 1 - Widget Setup & Initialization
  • 1.1 Initiate Widget
  • 1.2 Load configuration
  • Step 2 - Setup Optty Handle Order Payment Widget
  1. Widget

Handle Order Payment Widget Integration

PreviousCreate Order Widget IntegrationNextCreate Order

Last updated 1 month ago

Testing the Optty Handle Order Payment Widget in Sandbox Mode

To test the functionality of the optty-handle-order-payment-widget, follow these steps:

  • Access the Sandbox: Go to the Optty Widgets Sandbox at

  • Set Mode to Live: In the Mode dropdown, select Live.

  • Choose Currency: Select your desired currency.

  • Provide Your Sandbox Token: Enter your sandbox widgetToken into the Insert JSON Web Token Here input field.

  • Apply Configuration: Click the Apply Config button to update the settings.

  • Process Payment: Navigate to the #13 Optty Handle Order Payment Widget section, provide the payment payload in the JSON editor, and click Pay to see the in-context payment flow in action

Handle Order Payment Widget Setup and Integration

Prerequisites

  • Include the Optty JS Widget loader in your page

  • Ensure you have the necessary merchant credentials

Parameters

When using the optty-handle-order-payment-widget, note the following about dynamicCallbackUrl:

  • For In-Context implementation: dynamicCallbackUrl is required in the create order payload

  • For standard implementation: dynamicCallbackUrl is optional in the create order payload

When provided, dynamicCallbackUrl should be a valid HTTPS URL that can receive requests for webhook notifications about order status changes.

paymentStatusFetchEnabled : Determines whether to retrieve the payment status after the payment is completed. If set to true, a payment object is included in the onFinalized callback response.

Step 1 - Widget Setup & Initialization

1.1 Initiate Widget

<script>
  (function (w, d, s, o, f, js, fjs) {
    w['JS-Widget'] = o;
    w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
    js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
    js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs);
  }(window, document, 'script', 'mw', 'https://widgets.qa.optty.com/widget-loader.js'));
</script>

1.2 Load configuration

<script>
    // … widget initiation script …
    mw('init', {
        token: {{CUSTOMER_WIDGET_TOKEN}},
        currency: "string",
        initialAmount: number
        mode: “live”
    });
</script>

Step 2 - Setup Optty Handle Order Payment Widget

Call the widget with required payload structure:

<script>
    mw('optty-handle-order-payment-widget', {
        payload: {
          "redirectUrl": {{RETURNED AS RESPONSE FROM /orders endpoint}},
          "orderReference": {{RETURNED AS RESPONSE FROM /orders endpoint}},
          "transactionReference": {{RETURNED AS RESPONSE FROM /orders endpoint}},
          "paymentStatusFetchEnabled": true
        },
      onError: function(err) {
         // Handle error 
        console.error({ err });
      },
      onCancel: function(cancel) {
        // Handle cancel
        console.log({ cancel });
      },
      onFinalize: function(data) {
         // Handle completion
        console.log('Payment completed:', data);
      }
    });
</script>

Working React Code Example for Optty Payment Integration

https://widgets.qa.optty.com/