fluentcart-developer 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (609) hide show
  1. package/LICENSE.md +26 -26
  2. package/README.md +59 -59
  3. package/dist/cards/fluentcart/templates-native.js +1087 -1087
  4. package/dist/cards/fluentcart/tools.js +2309 -2309
  5. package/dist/skills/fluentcart-developer/SKILL.md +108 -108
  6. package/dist/skills/fluentcart-developer/examples/README.md +30 -30
  7. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
  8. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
  9. package/dist/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +113 -113
  10. package/dist/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +148 -148
  11. package/dist/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
  12. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/README.md +22 -22
  13. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/sample-plugin-with-licensing-sdk.php +79 -79
  14. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/FluentLicensing.php +303 -303
  15. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/LicenseSettings.php +566 -566
  16. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/PluginUpdater.php +304 -304
  17. package/dist/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +61 -61
  18. package/dist/skills/fluentcart-developer/references/api/authentication.md +452 -452
  19. package/dist/skills/fluentcart-developer/references/api/coupons.md +786 -786
  20. package/dist/skills/fluentcart-developer/references/api/customers.md +889 -889
  21. package/dist/skills/fluentcart-developer/references/api/files.md +609 -609
  22. package/dist/skills/fluentcart-developer/references/api/index.md +432 -432
  23. package/dist/skills/fluentcart-developer/references/api/licensing.md +633 -633
  24. package/dist/skills/fluentcart-developer/references/api/order-bump.md +384 -384
  25. package/dist/skills/fluentcart-developer/references/api/orders.md +814 -814
  26. package/dist/skills/fluentcart-developer/references/api/products.md +866 -866
  27. package/dist/skills/fluentcart-developer/references/api/roles-permissions.md +536 -536
  28. package/dist/skills/fluentcart-developer/references/api/subscriptions.md +827 -827
  29. package/dist/skills/fluentcart-developer/references/database/index.md +44 -44
  30. package/dist/skills/fluentcart-developer/references/database/models/activity.md +178 -178
  31. package/dist/skills/fluentcart-developer/references/database/models/applied-coupon.md +291 -291
  32. package/dist/skills/fluentcart-developer/references/database/models/attribute-group.md +239 -239
  33. package/dist/skills/fluentcart-developer/references/database/models/attribute-relation.md +181 -181
  34. package/dist/skills/fluentcart-developer/references/database/models/attribute-term.md +219 -219
  35. package/dist/skills/fluentcart-developer/references/database/models/cart.md +645 -645
  36. package/dist/skills/fluentcart-developer/references/database/models/coupon.md +427 -427
  37. package/dist/skills/fluentcart-developer/references/database/models/customer-addresses.md +348 -348
  38. package/dist/skills/fluentcart-developer/references/database/models/customer-meta.md +156 -156
  39. package/dist/skills/fluentcart-developer/references/database/models/customer.md +584 -584
  40. package/dist/skills/fluentcart-developer/references/database/models/dynamic-model.md +163 -163
  41. package/dist/skills/fluentcart-developer/references/database/models/label-relationship.md +155 -155
  42. package/dist/skills/fluentcart-developer/references/database/models/label.md +153 -153
  43. package/dist/skills/fluentcart-developer/references/database/models/license-activation.md +182 -182
  44. package/dist/skills/fluentcart-developer/references/database/models/license-meta.md +163 -163
  45. package/dist/skills/fluentcart-developer/references/database/models/license-site.md +208 -208
  46. package/dist/skills/fluentcart-developer/references/database/models/license.md +640 -640
  47. package/dist/skills/fluentcart-developer/references/database/models/meta.md +233 -233
  48. package/dist/skills/fluentcart-developer/references/database/models/order-address.md +391 -391
  49. package/dist/skills/fluentcart-developer/references/database/models/order-download-permission.md +144 -144
  50. package/dist/skills/fluentcart-developer/references/database/models/order-item.md +383 -383
  51. package/dist/skills/fluentcart-developer/references/database/models/order-meta.md +303 -303
  52. package/dist/skills/fluentcart-developer/references/database/models/order-operation.md +158 -158
  53. package/dist/skills/fluentcart-developer/references/database/models/order-promotion-stat.md +175 -175
  54. package/dist/skills/fluentcart-developer/references/database/models/order-promotion.md +250 -250
  55. package/dist/skills/fluentcart-developer/references/database/models/order-tax-rate.md +172 -172
  56. package/dist/skills/fluentcart-developer/references/database/models/order-transaction.md +440 -440
  57. package/dist/skills/fluentcart-developer/references/database/models/order.md +727 -727
  58. package/dist/skills/fluentcart-developer/references/database/models/product-detail.md +397 -397
  59. package/dist/skills/fluentcart-developer/references/database/models/product-download.md +258 -258
  60. package/dist/skills/fluentcart-developer/references/database/models/product-meta.md +153 -153
  61. package/dist/skills/fluentcart-developer/references/database/models/product-variation.md +556 -556
  62. package/dist/skills/fluentcart-developer/references/database/models/product.md +580 -580
  63. package/dist/skills/fluentcart-developer/references/database/models/relationships.md +427 -427
  64. package/dist/skills/fluentcart-developer/references/database/models/scheduled-action.md +175 -175
  65. package/dist/skills/fluentcart-developer/references/database/models/shipping-class.md +148 -148
  66. package/dist/skills/fluentcart-developer/references/database/models/shipping-method.md +280 -280
  67. package/dist/skills/fluentcart-developer/references/database/models/shipping-zone.md +205 -205
  68. package/dist/skills/fluentcart-developer/references/database/models/subscription-meta.md +173 -173
  69. package/dist/skills/fluentcart-developer/references/database/models/subscription.md +528 -528
  70. package/dist/skills/fluentcart-developer/references/database/models/tax-class.md +195 -195
  71. package/dist/skills/fluentcart-developer/references/database/models/tax-rate.md +225 -225
  72. package/dist/skills/fluentcart-developer/references/database/models/user-meta.md +166 -166
  73. package/dist/skills/fluentcart-developer/references/database/models/user.md +220 -220
  74. package/dist/skills/fluentcart-developer/references/database/models.md +404 -404
  75. package/dist/skills/fluentcart-developer/references/database/query-builder.md +860 -860
  76. package/dist/skills/fluentcart-developer/references/database/readme.md +276 -276
  77. package/dist/skills/fluentcart-developer/references/database/schema.md +1002 -1002
  78. package/dist/skills/fluentcart-developer/references/engineering/adding-custom-pages-to-the-customer-dashboard.md +395 -395
  79. package/dist/skills/fluentcart-developer/references/engineering/index.md +4 -4
  80. package/dist/skills/fluentcart-developer/references/engineering.md +4 -4
  81. package/dist/skills/fluentcart-developer/references/getting-started.md +249 -249
  82. package/dist/skills/fluentcart-developer/references/guides/frontend.md +519 -519
  83. package/dist/skills/fluentcart-developer/references/guides/index.md +107 -107
  84. package/dist/skills/fluentcart-developer/references/guides/integrations.md +600 -600
  85. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/index.md +237 -237
  86. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/labels-and-tracking.md +481 -481
  87. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/live-rates.md +269 -269
  88. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/reference.md +223 -223
  89. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/settings.md +370 -370
  90. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier.md +237 -237
  91. package/dist/skills/fluentcart-developer/references/guides/subscriptions.md +217 -217
  92. package/dist/skills/fluentcart-developer/references/hooks/actions/admin-and-templates.md +1079 -1079
  93. package/dist/skills/fluentcart-developer/references/hooks/actions/cart-and-checkout.md +1795 -1795
  94. package/dist/skills/fluentcart-developer/references/hooks/actions/customers-and-users.md +327 -327
  95. package/dist/skills/fluentcart-developer/references/hooks/actions/licenses.md +829 -829
  96. package/dist/skills/fluentcart-developer/references/hooks/actions/modules.md +81 -81
  97. package/dist/skills/fluentcart-developer/references/hooks/actions/orders.md +757 -757
  98. package/dist/skills/fluentcart-developer/references/hooks/actions/payments-and-integrations.md +1163 -1163
  99. package/dist/skills/fluentcart-developer/references/hooks/actions/pro-modules.md +219 -219
  100. package/dist/skills/fluentcart-developer/references/hooks/actions/products-and-coupons.md +1019 -1019
  101. package/dist/skills/fluentcart-developer/references/hooks/actions/subscriptions.md +1290 -1290
  102. package/dist/skills/fluentcart-developer/references/hooks/actions.md +16 -16
  103. package/dist/skills/fluentcart-developer/references/hooks/deprecated.md +60 -60
  104. package/dist/skills/fluentcart-developer/references/hooks/filters/cart-and-checkout.md +2032 -2032
  105. package/dist/skills/fluentcart-developer/references/hooks/filters/customers-and-subscriptions.md +1746 -1746
  106. package/dist/skills/fluentcart-developer/references/hooks/filters/integrations-and-advanced.md +2439 -2439
  107. package/dist/skills/fluentcart-developer/references/hooks/filters/modules.md +464 -464
  108. package/dist/skills/fluentcart-developer/references/hooks/filters/orders-and-payments.md +2658 -2658
  109. package/dist/skills/fluentcart-developer/references/hooks/filters/pro-modules.md +502 -502
  110. package/dist/skills/fluentcart-developer/references/hooks/filters/products-and-pricing.md +1785 -1785
  111. package/dist/skills/fluentcart-developer/references/hooks/filters/settings-and-configuration.md +2966 -2966
  112. package/dist/skills/fluentcart-developer/references/hooks/filters.md +14 -14
  113. package/dist/skills/fluentcart-developer/references/hooks/index.md +35 -35
  114. package/dist/skills/fluentcart-developer/references/index.md +625 -625
  115. package/dist/skills/fluentcart-developer/references/modules/fee-system.md +427 -427
  116. package/dist/skills/fluentcart-developer/references/modules/ghost-product-selling.md +440 -440
  117. package/dist/skills/fluentcart-developer/references/modules/index.md +484 -484
  118. package/dist/skills/fluentcart-developer/references/modules/licensing.md +342 -342
  119. package/dist/skills/fluentcart-developer/references/modules/order-bump.md +433 -433
  120. package/dist/skills/fluentcart-developer/references/modules/payment-methods.md +129 -129
  121. package/dist/skills/fluentcart-developer/references/modules/refunds.md +170 -170
  122. package/dist/skills/fluentcart-developer/references/modules/shipping.md +846 -846
  123. package/dist/skills/fluentcart-developer/references/modules/storage.md +986 -986
  124. package/dist/skills/fluentcart-developer/references/modules/subscription-vendor-ids.md +186 -186
  125. package/dist/skills/fluentcart-developer/references/modules/subscriptions.md +678 -678
  126. package/dist/skills/fluentcart-developer/references/payment-methods-integration/index.md +164 -164
  127. package/dist/skills/fluentcart-developer/references/payment-methods-integration/paddle-example.md +1648 -1648
  128. package/dist/skills/fluentcart-developer/references/payment-methods-integration/payment/setting/fields.md +353 -353
  129. package/dist/skills/fluentcart-developer/references/payment-methods-integration/quick-implementation.md +1079 -1079
  130. package/dist/skills/fluentcart-developer/references/payment-methods-integration.md +164 -164
  131. package/dist/skills/fluentcart-developer/references/restapi/checkout.md +573 -573
  132. package/dist/skills/fluentcart-developer/references/restapi/coupons.md +958 -958
  133. package/dist/skills/fluentcart-developer/references/restapi/customer-profile.md +1423 -1423
  134. package/dist/skills/fluentcart-developer/references/restapi/customers.md +1103 -1103
  135. package/dist/skills/fluentcart-developer/references/restapi/dashboard.md +1083 -1083
  136. package/dist/skills/fluentcart-developer/references/restapi/data-export.md +132 -132
  137. package/dist/skills/fluentcart-developer/references/restapi/email-notifications.md +846 -846
  138. package/dist/skills/fluentcart-developer/references/restapi/files.md +313 -313
  139. package/dist/skills/fluentcart-developer/references/restapi/index.md +127 -127
  140. package/dist/skills/fluentcart-developer/references/restapi/integrations.md +1000 -1000
  141. package/dist/skills/fluentcart-developer/references/restapi/inventory.md +192 -192
  142. package/dist/skills/fluentcart-developer/references/restapi/labels-and-attributes.md +797 -797
  143. package/dist/skills/fluentcart-developer/references/restapi/licensing.md +1733 -1733
  144. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-available-shipping-methods.md +30 -30
  145. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-checkout-summary.md +28 -28
  146. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-country-info.md +29 -29
  147. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-order-info.md +28 -28
  148. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-shipping-methods-list-view.md +30 -30
  149. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/login.md +66 -66
  150. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/place-order.md +179 -179
  151. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/apply-coupon.md +83 -83
  152. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/cancel-coupon.md +87 -87
  153. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/check-product-eligibility.md +59 -59
  154. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/create-coupon.md +230 -230
  155. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/delete-coupon.md +29 -29
  156. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon-settings.md +20 -20
  157. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon.md +27 -27
  158. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupon-codes.md +20 -20
  159. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupons.md +37 -37
  160. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/re-apply-coupons.md +75 -75
  161. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/store-coupon-settings.md +40 -40
  162. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/update-coupon.md +133 -133
  163. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-address-checkout.md +138 -138
  164. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-profile-address.md +119 -119
  165. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/dashboard-overview.md +22 -22
  166. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/delete-profile-address.md +46 -46
  167. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-order-details.md +30 -30
  168. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-portal-sections.md +29 -29
  169. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-profile-details.md +22 -22
  170. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-transaction-billing-address.md +30 -30
  171. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-upgrade-paths.md +31 -31
  172. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-downloads.md +29 -29
  173. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-orders.md +28 -28
  174. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/make-profile-address-primary.md +55 -55
  175. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/pause-subscription.md +29 -29
  176. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/resume-subscription.md +29 -29
  177. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/save-transaction-billing-address.md +92 -92
  178. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/select-address-for-checkout.md +32 -32
  179. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-address.md +115 -115
  180. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-details.md +69 -69
  181. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/attach-user.md +50 -50
  182. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/bulk-actions.md +65 -65
  183. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-address.md +135 -135
  184. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-customer.md +108 -108
  185. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/delete-address.md +62 -62
  186. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/detach-user.md +28 -28
  187. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/find-customer-order.md +27 -27
  188. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-attachable-users.md +20 -20
  189. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-addresses.md +28 -28
  190. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-orders.md +37 -37
  191. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-stats.md +27 -27
  192. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer.md +32 -32
  193. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/list-customers.md +37 -37
  194. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/recalculate-ltv.md +28 -28
  195. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/set-primary-address.md +72 -72
  196. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-additional-info.md +55 -55
  197. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-address.md +144 -144
  198. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-customer.md +123 -123
  199. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/attach-note-to-order.md +49 -49
  200. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-all-pages.md +21 -21
  201. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-single-page.md +55 -55
  202. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/delete-activity.md +28 -28
  203. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-country-info.md +29 -29
  204. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-dashboard-stats.md +22 -22
  205. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-filter-options.md +31 -31
  206. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-data.md +20 -20
  207. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-settings.md +20 -20
  208. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-print-templates.md +20 -20
  209. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-search-options.md +27 -27
  210. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-widgets.md +28 -28
  211. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/initialize-app.md +20 -20
  212. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-activities.md +33 -33
  213. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-attachments.md +21 -21
  214. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-countries.md +20 -20
  215. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/mark-activity-read.md +53 -53
  216. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/run-data-backfills.md +21 -21
  217. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-settings.md +54 -54
  218. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-tax-settings.md +73 -73
  219. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-print-templates.md +64 -64
  220. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/upload-attachment.md +42 -42
  221. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-customers-batch.md +129 -129
  222. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-licenses-batch.md +133 -133
  223. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-orders-batch.md +129 -129
  224. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-subscriptions-batch.md +129 -129
  225. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-customers-export-schema.md +21 -21
  226. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-licenses-export-schema.md +26 -26
  227. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-orders-export-schema.md +21 -21
  228. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-subscriptions-export-schema.md +21 -21
  229. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/enable-notification.md +57 -57
  230. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-digest-settings.md +22 -22
  231. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-notification.md +30 -30
  232. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-reminders.md +22 -22
  233. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-settings.md +22 -22
  234. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-shortcodes.md +22 -22
  235. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/list-notifications.md +20 -20
  236. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-default-template.md +66 -66
  237. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-notification.md +50 -50
  238. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-digest-settings.md +101 -101
  239. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-reminders.md +162 -162
  240. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-settings.md +99 -99
  241. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-digest-test.md +47 -47
  242. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-manual-reminder.md +51 -51
  243. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/update-notification.md +93 -93
  244. package/dist/skills/fluentcart-developer/references/restapi/operations/files/delete-file.md +31 -31
  245. package/dist/skills/fluentcart-developer/references/restapi/operations/files/get-bucket-list.md +28 -28
  246. package/dist/skills/fluentcart-developer/references/restapi/operations/files/list-files.md +30 -30
  247. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-editor-file.md +32 -32
  248. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-file.md +34 -34
  249. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/chained-data-request.md +46 -46
  250. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/change-feed-status.md +51 -51
  251. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/delete-feed.md +27 -27
  252. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-dynamic-options.md +29 -29
  253. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-lists.md +27 -27
  254. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-settings.md +27 -27
  255. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-feeds.md +20 -20
  256. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-settings.md +26 -26
  257. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/install-addon-plugin.md +49 -49
  258. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/list-addons.md +20 -20
  259. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/save-feed-settings.md +52 -52
  260. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/set-global-settings.md +50 -50
  261. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/bulk-update-stock.md +94 -94
  262. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/export-inventory.md +81 -81
  263. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-adjustment-history.md +26 -26
  264. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-inventory-stats.md +21 -21
  265. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/list-inventory.md +33 -33
  266. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/update-stock.md +75 -75
  267. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-attribute-group.md +31 -31
  268. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-label.md +31 -31
  269. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-terms.md +90 -90
  270. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-group.md +28 -28
  271. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-term.md +29 -29
  272. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-group.md +28 -28
  273. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-library.md +20 -20
  274. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-groups.md +32 -32
  275. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-terms.md +33 -33
  276. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-labels.md +20 -20
  277. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-groups.md +51 -51
  278. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-terms.md +56 -56
  279. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-group.md +37 -37
  280. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-term.md +39 -39
  281. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-label-selections.md +32 -32
  282. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-plugin-license.md +41 -41
  283. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-site-admin.md +60 -60
  284. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-plugin-license.md +18 -18
  285. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-admin.md +67 -67
  286. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-customer.md +47 -47
  287. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/delete-license.md +24 -24
  288. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/extend-license-validity.md +47 -47
  289. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-license-details.md +25 -25
  290. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-licenses-admin.md +26 -26
  291. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-activations.md +25 -25
  292. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-details.md +25 -25
  293. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-site.md +30 -30
  294. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-plugin-license-status.md +18 -18
  295. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-product-license-settings.md +24 -24
  296. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-customer-licenses.md +25 -25
  297. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-license-sites.md +33 -33
  298. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-licenses.md +38 -38
  299. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-activate-license.md +54 -54
  300. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-check-license.md +26 -26
  301. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-deactivate-license.md +46 -46
  302. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-download-license-package.md +23 -23
  303. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-get-license-version.md +26 -26
  304. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/regenerate-license-key.md +24 -24
  305. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/save-product-license-settings.md +193 -193
  306. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-activation-limit.md +53 -53
  307. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-status.md +52 -52
  308. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/create-order-bump.md +47 -47
  309. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/delete-order-bump.md +25 -25
  310. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/get-order-bump.md +25 -25
  311. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/list-order-bumps.md +29 -29
  312. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/update-order-bump.md +141 -141
  313. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/accept-dispute.md +47 -47
  314. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/bulk-actions.md +72 -72
  315. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-shipping.md +67 -67
  316. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-tax.md +98 -98
  317. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/change-customer.md +50 -50
  318. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/charge-now.md +29 -29
  319. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-and-change-customer.md +92 -92
  320. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-custom-order-item.md +68 -68
  321. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-order.md +351 -351
  322. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-renewal-now.md +29 -29
  323. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/delete-order.md +28 -28
  324. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/generate-missing-licenses.md +29 -29
  325. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order-transactions.md +27 -27
  326. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order.md +27 -27
  327. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-renewal.md +28 -28
  328. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-shipping-methods.md +28 -28
  329. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-single-transaction.md +28 -28
  330. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-order-currencies.md +22 -22
  331. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-orders.md +42 -42
  332. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-renewals.md +28 -28
  333. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/mark-as-paid.md +61 -61
  334. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/price-order.md +135 -135
  335. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/refund-order.md +72 -72
  336. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/resend-renewal-invoice.md +29 -29
  337. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/skip-renewal.md +48 -48
  338. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-order-statuses.md +28 -28
  339. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-pending-transaction.md +29 -29
  340. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address-id.md +60 -60
  341. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address.md +98 -98
  342. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order.md +172 -172
  343. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-statuses.md +77 -77
  344. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-subscription-details.md +84 -84
  345. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-transaction-status.md +51 -51
  346. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/void-renewal.md +30 -30
  347. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/create-pdf-template.md +42 -42
  348. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/delete-pdf-template.md +26 -26
  349. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/download-pdf-preview.md +44 -44
  350. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-factory-default-templates.md +19 -19
  351. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-status.md +21 -21
  352. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-template.md +26 -26
  353. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-saved-templates.md +21 -21
  354. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-seller-details.md +19 -19
  355. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/list-pdf-templates.md +19 -19
  356. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-pdf-template.md +53 -53
  357. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-seller-details.md +97 -97
  358. package/dist/skills/fluentcart-developer/references/restapi/operations/products/add-product-terms.md +64 -64
  359. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-edit-fetch.md +30 -30
  360. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-insert-products.md +62 -62
  361. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-products.md +59 -59
  362. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-variants.md +83 -83
  363. package/dist/skills/fluentcart-developer/references/restapi/operations/products/change-integration-status.md +64 -64
  364. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-dummy-products.md +45 -45
  365. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-product.md +81 -81
  366. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-variation.md +181 -181
  367. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-downloadable-file.md +27 -27
  368. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product-integration.md +30 -30
  369. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product.md +27 -27
  370. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-taxonomy-term.md +55 -55
  371. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-upgrade-path.md +27 -27
  372. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-variation.md +27 -27
  373. package/dist/skills/fluentcart-developer/references/restapi/operations/products/do-bulk-action.md +56 -56
  374. package/dist/skills/fluentcart-developer/references/restapi/operations/products/duplicate-product.md +56 -56
  375. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-products-by-ids.md +26 -26
  376. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-taxonomy-terms.md +20 -20
  377. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-terms-by-parent.md +60 -60
  378. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-variations-by-ids.md +26 -26
  379. package/dist/skills/fluentcart-developer/references/restapi/operations/products/find-subscription-variants.md +26 -26
  380. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-bundle-info.md +27 -27
  381. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-downloadable-url.md +27 -27
  382. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-max-excerpt-word-count.md +20 -20
  383. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-pricing-widgets.md +27 -27
  384. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-feeds.md +29 -29
  385. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-settings.md +31 -31
  386. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-pricing.md +28 -28
  387. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product.md +28 -28
  388. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-related-products.md +31 -31
  389. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-upgrade-settings.md +27 -27
  390. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-variation-upgrade-paths.md +28 -28
  391. package/dist/skills/fluentcart-developer/references/restapi/operations/products/group-bulk-update-variants.md +103 -103
  392. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-all-variants.md +26 -26
  393. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-product-variations.md +26 -26
  394. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-products.md +34 -34
  395. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-shipping-class.md +27 -27
  396. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-tax-class.md +27 -27
  397. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-bundle-info.md +56 -56
  398. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-product-integration.md +62 -62
  399. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-upgrade-path.md +78 -78
  400. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-product-variant-options.md +29 -29
  401. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-products-by-name.md +28 -28
  402. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-variants-by-name.md +28 -28
  403. package/dist/skills/fluentcart-developer/references/restapi/operations/products/set-variation-media.md +74 -74
  404. package/dist/skills/fluentcart-developer/references/restapi/operations/products/suggest-sku.md +28 -28
  405. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-downloadable-files.md +134 -134
  406. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-taxonomy-terms.md +61 -61
  407. package/dist/skills/fluentcart-developer/references/restapi/operations/products/toggle-product-tax-exemption.md +56 -56
  408. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-downloadable-file.md +98 -98
  409. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-inventory.md +56 -56
  410. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-long-desc-editor-mode.md +49 -49
  411. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-manage-stock.md +53 -53
  412. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-detail.md +58 -58
  413. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-pricing.md +225 -225
  414. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-shipping-class.md +49 -49
  415. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-tax-class.md +49 -49
  416. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-upgrade-path.md +78 -78
  417. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-option.md +79 -79
  418. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-tax-exemption.md +56 -56
  419. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation-pricing-table.md +49 -49
  420. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation.md +105 -105
  421. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/get-product-views.md +34 -34
  422. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/list-products.md +42 -42
  423. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/search-products.md +30 -30
  424. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/channel-rules.md +24 -24
  425. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/country-heat-map.md +22 -22
  426. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupon-overview.md +37 -37
  427. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupons.md +36 -36
  428. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-insights.md +31 -31
  429. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-overview.md +36 -36
  430. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-repeat.md +35 -35
  431. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segment-customers.md +36 -36
  432. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segments.md +30 -30
  433. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-value.md +34 -34
  434. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/dashboard-stats.md +30 -30
  435. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/failed-orders.md +34 -34
  436. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-new-vs-returning-customer.md +34 -34
  437. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-by-day-and-hour.md +34 -34
  438. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-meta.md +29 -29
  439. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-top-sold-products.md +34 -34
  440. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/future-renewals.md +31 -31
  441. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/generate-retention-snapshots.md +24 -24
  442. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-overview.md +30 -30
  443. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-activities.md +26 -26
  444. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-orders.md +20 -20
  445. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-revenue.md +37 -37
  446. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-at-risk.md +35 -35
  447. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-variations.md +33 -33
  448. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments.md +33 -33
  449. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/item-count-distribution.md +34 -34
  450. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-chart.md +30 -30
  451. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-pie-chart.md +22 -22
  452. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-summary.md +22 -22
  453. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/locations.md +43 -43
  454. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-chart.md +37 -37
  455. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-completion-time.md +34 -34
  456. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-mix.md +34 -34
  457. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-value-distribution.md +34 -34
  458. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-disputes.md +38 -38
  459. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-methods.md +36 -36
  460. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods.md +37 -37
  461. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison-launch.md +33 -33
  462. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison.md +40 -40
  463. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-detail.md +37 -37
  464. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-sales.md +37 -37
  465. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/refunds-overview.md +37 -37
  466. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/retention-snapshots-step.md +45 -45
  467. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sales-growth-chart.md +35 -35
  468. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/save-channel-rules.md +73 -73
  469. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/source-channels.md +37 -37
  470. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sources.md +49 -49
  471. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-cohorts.md +33 -33
  472. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-health.md +30 -30
  473. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-rebuys.md +37 -37
  474. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-retention.md +34 -34
  475. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-variations.md +22 -22
  476. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscriptions-overview.md +37 -37
  477. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/weeks-between-refund.md +34 -34
  478. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/assign-role.md +48 -48
  479. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/delete-role-assignment.md +47 -47
  480. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/get-role.md +25 -25
  481. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-managers.md +18 -18
  482. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-roles.md +18 -18
  483. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/search-users.md +25 -25
  484. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/update-role.md +43 -43
  485. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/create-saved-view.md +106 -106
  486. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/delete-saved-view.md +26 -26
  487. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/list-saved-views.md +25 -25
  488. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/update-saved-view.md +83 -83
  489. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-payment-addon.md +44 -44
  490. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-plugin-addon.md +44 -44
  491. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/change-storage-driver-status.md +56 -56
  492. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/check-paypal-webhook.md +26 -26
  493. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/create-storage-bucket.md +63 -63
  494. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/disconnect-payment-method.md +55 -55
  495. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/exchange-paypal-seller-auth-token.md +62 -62
  496. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-active-storage-drivers.md +20 -20
  497. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-checkout-fields.md +22 -22
  498. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-email-shortcodes.md +20 -20
  499. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-config-snippets.md +26 -26
  500. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-status.md +20 -20
  501. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-module-settings.md +20 -20
  502. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-connection-info.md +26 -26
  503. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-settings.md +26 -26
  504. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-permissions.md +22 -22
  505. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-plugin-addons.md +20 -20
  506. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-storage-driver-settings.md +27 -27
  507. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-store-settings.md +26 -26
  508. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-mcp-adapter.md +21 -21
  509. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-payment-addon.md +60 -60
  510. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-plugin-addon.md +64 -64
  511. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-payment-methods.md +20 -20
  512. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-storage-drivers.md +20 -20
  513. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-storage-buckets.md +67 -67
  514. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reorder-payment-methods.md +55 -55
  515. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reset-storage-driver-settings.md +45 -45
  516. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-checkout-fields.md +133 -133
  517. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-confirmation-settings.md +68 -68
  518. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-module-settings.md +68 -68
  519. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-design.md +67 -67
  520. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-settings.md +58 -58
  521. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-permissions.md +68 -68
  522. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-storage-driver-settings.md +62 -62
  523. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-store-settings.md +239 -239
  524. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/setup-paypal-webhook.md +48 -48
  525. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/toggle-mcp.md +40 -40
  526. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-storage-driver-connection.md +62 -62
  527. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-turnstile-keys.md +55 -55
  528. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-class.md +73 -73
  529. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-method.md +110 -110
  530. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-zone.md +56 -56
  531. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-class.md +29 -29
  532. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-method.md +29 -29
  533. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-zone.md +29 -29
  534. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class-profile.md +30 -30
  535. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class.md +29 -29
  536. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-packages.md +22 -22
  537. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-zone.md +27 -27
  538. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-countries.md +22 -22
  539. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-states.md +28 -28
  540. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-classes.md +31 -31
  541. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-zones.md +31 -31
  542. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/save-shipping-packages.md +112 -112
  543. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-class.md +79 -79
  544. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-method.md +113 -113
  545. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-zone.md +62 -62
  546. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-zone-order.md +52 -52
  547. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-auto-renew.md +30 -30
  548. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-subscription.md +52 -52
  549. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/confirm-subscription-switch.md +70 -70
  550. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/fetch-subscription-remote.md +28 -28
  551. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/generate-early-payment-link.md +29 -29
  552. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-customer-subscription.md +27 -27
  553. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-or-create-plan.md +69 -69
  554. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-setup-intent-attempts.md +30 -30
  555. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-subscription.md +28 -28
  556. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/initiate-early-payment.md +31 -31
  557. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-customer-subscriptions.md +27 -27
  558. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-subscriptions.md +39 -39
  559. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/pause-subscription.md +28 -28
  560. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/reactivate-subscription.md +28 -28
  561. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/resume-subscription.md +28 -28
  562. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/switch-payment-method.md +70 -70
  563. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-payment-method.md +69 -69
  564. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-vendor-ids.md +56 -56
  565. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/verify-vendor-ids.md +56 -56
  566. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-class.md +51 -51
  567. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-rate.md +117 -117
  568. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-product-override.md +27 -27
  569. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-shipping-tax-override.md +27 -27
  570. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-class.md +28 -28
  571. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-rate.md +27 -27
  572. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-id.md +27 -27
  573. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-rates.md +28 -28
  574. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-eu-vat-product-overrides.md +20 -20
  575. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-oss-country-rates.md +20 -20
  576. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-preconfigured-tax-rates.md +20 -20
  577. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-product-overrides.md +27 -27
  578. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-tax-settings.md +20 -20
  579. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-all-tax-rates.md +20 -20
  580. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-classes.md +20 -20
  581. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-records.md +37 -37
  582. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/mark-taxes-as-filed.md +58 -58
  583. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/reset-eu-vat-rates.md +21 -21
  584. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-configured-countries.md +57 -57
  585. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-country-tax-id.md +50 -50
  586. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-eu-vat-cross-border-settings.md +127 -127
  587. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-oss-country-rates.md +100 -100
  588. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-product-override.md +110 -110
  589. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-shipping-tax-override.md +52 -52
  590. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-tax-settings.md +166 -166
  591. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-country-status.md +54 -54
  592. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-tax-rate.md +116 -116
  593. package/dist/skills/fluentcart-developer/references/restapi/order-bumps.md +433 -433
  594. package/dist/skills/fluentcart-developer/references/restapi/orders.md +1212 -1212
  595. package/dist/skills/fluentcart-developer/references/restapi/pdf-templates.md +212 -212
  596. package/dist/skills/fluentcart-developer/references/restapi/products.md +2485 -2485
  597. package/dist/skills/fluentcart-developer/references/restapi/public-shop.md +191 -191
  598. package/dist/skills/fluentcart-developer/references/restapi/reports.md +3773 -3773
  599. package/dist/skills/fluentcart-developer/references/restapi/roles.md +403 -403
  600. package/dist/skills/fluentcart-developer/references/restapi/saved-views.md +136 -136
  601. package/dist/skills/fluentcart-developer/references/restapi/settings.md +1423 -1423
  602. package/dist/skills/fluentcart-developer/references/restapi/shipping.md +905 -905
  603. package/dist/skills/fluentcart-developer/references/restapi/subscriptions.md +1169 -1169
  604. package/dist/skills/fluentcart-developer/references/restapi/tax.md +1551 -1551
  605. package/dist/skills/fluentcart-developer/references/restapi.md +127 -127
  606. package/dist/skills/fluentcart-developer/scripts/cli.js +1 -1
  607. package/dist/version.d.ts +1 -1
  608. package/dist/version.js +1 -1
  609. package/package.json +66 -65
@@ -1,1079 +1,1079 @@
1
- # Payment Gateway Integration Guide
2
-
3
- This guide provides a step-by-step approach to integrate your payment gateway with FluentCart. Follow these steps to create a fully functional payment gateway with support for one-time payments, subscriptions, and web hooks.
4
-
5
- ## Implementation Steps
6
-
7
- ### Step 1: Register Your Gateway
8
-
9
- In your plugin's main file, register your gateway with FluentCart using the hook approach (recommended):
10
-
11
- ```
12
- // In your-plugin.php
13
- add_action('fluent_cart/register_payment_methods', function() {
14
- if (!function_exists('fluent_cart_api')) {
15
- return; // FluentCart not active
16
- }
17
-
18
- // Register your custom gateway
19
- fluent_cart_api()->registerCustomPaymentMethod(
20
- 'your_gateway',
21
- new \YourPlugin\PaymentMethods\YourGateway\YourGateway()
22
- );
23
- });
24
- ```
25
-
26
- Don't eagerly `require` your gateway class file
27
-
28
- `fluent_cart/register_payment_methods` fires on WordPress `init` (after FluentCart's own `plugins_loaded` → `fluentcart_loaded` → `init` chain), so calling `registerCustomPaymentMethod` inside it — as shown above — is already safe timing-wise. The pitfall is elsewhere: if your plugin's bootstrap `require`s the file that *defines* `class YourGateway extends AbstractPaymentGateway` too early (top-level in your main plugin file, or tied to `fluentcart_loaded`), PHP fatals on class-not-found at include time — `AbstractPaymentGateway`/`BaseGatewaySettings` may not exist yet at that point. Only `require`/autoload the gateway class file from inside the `fluent_cart/register_payment_methods` callback itself (or via lazy PSR-4 autoloading triggered by `new YourGateway()` there), same as the example above.
29
-
30
- Alternatively, you can register on the `init` hook (not recommended):
31
-
32
- ```
33
- add_action('init', function() {
34
- if (!function_exists('fluent_cart_api')) {
35
- return;
36
- }
37
- fluent_cart_api()->registerCustomPaymentMethod('your_gateway', new \YourPlugin\PaymentMethods\YourGateway\YourGateway());
38
- });
39
- ```
40
-
41
- ### Step 2: Create the Settings Class
42
-
43
- Create a settings class that extends `BaseGatewaySettings`:
44
-
45
- ```
46
- <?php
47
- namespace YourPlugin\PaymentMethods\YourGateway;
48
-
49
- use FluentCart\App\Helpers\Helper;
50
- use FluentCart\App\Modules\PaymentMethods\Core\BaseGatewaySettings;
51
- use FluentCart\Framework\Support\Arr;
52
-
53
- class YourGatewaySettings extends BaseGatewaySettings
54
- {
55
- public $methodHandler = 'fluent_cart_payment_settings_your_gateway';
56
-
57
- public static function getDefaults()
58
- {
59
- return [
60
- 'is_active' => 'no',
61
- 'payment_mode' => 'test', // test or live
62
- 'test_api_key' => '',
63
- 'test_secret_key' => '',
64
- 'test_webhook_secret' => '',
65
- 'live_api_key' => '',
66
- 'live_secret_key' => '',
67
- 'live_webhook_secret' => '',
68
- ];
69
- }
70
-
71
- // Required by BaseGatewaySettings.
72
- public function get($key = '')
73
- {
74
- if ($key) {
75
- return Arr::get($this->settings, $key);
76
- }
77
-
78
- return $this->settings;
79
- }
80
-
81
- // Required by BaseGatewaySettings.
82
- public function getMode()
83
- {
84
- return $this->get('payment_mode');
85
- }
86
-
87
- // Required by BaseGatewaySettings.
88
- public function isActive()
89
- {
90
- return $this->get('is_active') === 'yes';
91
- }
92
-
93
- public function isTestMode()
94
- {
95
- return $this->getMode() === 'test';
96
- }
97
-
98
- public function getApiKey($mode = '')
99
- {
100
- $mode = $mode ?: $this->getMode();
101
-
102
- return $this->get($mode . '_api_key');
103
- }
104
-
105
- public function getSecretKey($mode = '')
106
- {
107
- $mode = $mode ?: $this->getMode();
108
-
109
- return (string) Helper::decryptKey($this->get($mode . '_secret_key'));
110
- }
111
-
112
- public function getWebhookSecret($mode = '')
113
- {
114
- $mode = $mode ?: $this->getMode();
115
-
116
- return (string) Helper::decryptKey($this->get($mode . '_webhook_secret'));
117
- }
118
- }
119
- ```
120
-
121
- Encrypt the secret fields when the settings are saved. Add this to your gateway class (Step 3):
122
-
123
- ```
124
- public static function beforeSettingsUpdate($data, $oldSettings): array
125
- {
126
- $secretFields = ['test_secret_key', 'live_secret_key', 'test_webhook_secret', 'live_webhook_secret'];
127
-
128
- foreach ($secretFields as $field) {
129
- $value = Arr::get($data, $field, '');
130
-
131
- // Encrypt only a value that changed. The stored one is already encrypted.
132
- if ($value && $value !== Arr::get($oldSettings, $field, '')) {
133
- $data[$field] = Helper::encryptKey($value);
134
- }
135
- }
136
-
137
- return $data;
138
- }
139
- ```
140
-
141
- Call `Helper::decryptKey()` only on a field you encrypted here. It returns `false` for a plain value that is valid base64, and most API keys are.
142
-
143
- ### Step 3: Create your Gateway Class
144
-
145
- Create base class that implements all required methods:
146
-
147
- ```
148
- <?php
149
- namespace YourPlugin\PaymentMethods\YourGateway;
150
-
151
- use FluentCart\App\Helpers\Helper;
152
- use FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway;
153
- use FluentCart\App\Services\Payments\PaymentInstance;
154
- use FluentCart\Framework\Support\Arr;
155
-
156
- class YourGateway extends AbstractPaymentGateway
157
- {
158
- // Define supported features
159
- // 'payment' and 'refund' are queried through has(). 'webhook' is
160
- // declarative, and every built-in gateway lists it.
161
- //
162
- // Leave 'subscriptions' out: AbstractPaymentGateway::__construct() appends
163
- // it when you pass a subscription module.
164
- public array $supportedFeatures = [
165
- 'payment',
166
- 'refund',
167
- 'webhook'
168
- ];
169
-
170
- public function __construct()
171
- {
172
- // AbstractPaymentGateway::__construct() is type-enforced: it requires a
173
- // BaseGatewaySettings instance as its first argument. Passing anything else
174
- // (or omitting it) is a fatal TypeError, not a soft failure.
175
- parent::__construct(new YourGatewaySettings());
176
-
177
- }
178
-
179
- public function boot()
180
- {
181
- // initialize any hanldere, webhook/ payment confirmation class if needed
182
- }
183
-
184
- // Required: Return gateway metadata
185
- public function meta(): array
186
- {
187
- return [
188
- 'title' => __('Your Gateway', 'your-plugin'),
189
- 'route' => 'your_gateway',
190
- 'slug' => 'your_gateway',
191
- 'description' => __('Accept payments with Your Gateway', 'your-plugin'),
192
- 'logo' => plugin_dir_url(__FILE__) .
193
- 'assets/images/logo.svg',
194
- 'icon' => plugin_dir_url(__FILE__) .
195
- 'assets/images/icon.svg',
196
- 'status' => $this->settings->get('is_active') === 'yes',
197
- 'supported_features' => $this->supportedFeatures
198
- ];
199
- }
200
-
201
- // Not required: AbstractPaymentGateway already implements has() against
202
- // $supportedFeatures. Override it only if you need custom feature logic.
203
-
204
- // Required: Process payment
205
- public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance)
206
- {
207
- // Your payment processing logic here
208
-
209
- }
210
-
211
- // Required: Handle IPNs/Webhooks
212
- public function handleIPN()
213
- {
214
- // Process the webhook
215
-
216
- }
217
-
218
- #required: Return settings fields configuration
219
- public function fields(): array
220
- {
221
- // For a comprehensive guide on building gateway settings fields,
222
- // see the detailed [Payment Gateway Settings Fields] documentation link given below
223
- return [
224
- ....
225
- ];
226
- }
227
-
228
- // For a comprehensive guide on building gateway settings fields,
229
- // see the detailed documentation: [Payment Gateway Settings Fields](./payment_setting_fields.md)
230
-
231
- // Required: declared on PaymentGatewayInterface, not just a convention —
232
- // omitting it is a fatal "abstract method not implemented" error, even though
233
- // AbstractPaymentGateway doesn't spell it out with a PHP `abstract` keyword.
234
- #required: Get order information for frontend
235
- public function getOrderInfo(array $data)
236
- {
237
- // Prepare frontend data for checkout
238
- $paymentArgs = [];
239
-
240
- // Return data for frontend
241
- wp_send_json([
242
- 'status' => 'success',
243
- 'payment_args' => $paymentArgs,
244
- 'message' => __('Order info retrieved', 'your-plugin')
245
- ], 200);
246
- }
247
-
248
- #required: Register scripts (automatically called by base gateway)
249
- public function getEnqueueScriptSrc($hasSubscription = 'no'): array
250
- {
251
- // External gateway library, custom checkout scripts (if needed), otherwise return empty array
252
- $gatewayLibUrl = 'https://js.yourgateway.com/v1/checkout.js';
253
-
254
- return [
255
- [
256
- 'handle' => 'your-gateway-external-lib',
257
- 'src' => $gatewayLibUrl,
258
- ],
259
- [
260
- 'handle' => 'fluent-cart-your-gateway-checkout',
261
- 'src' => plugin_dir_url(__FILE__) . 'assets/js/your-gateway-checkout.js',
262
- 'deps' => ['your-gateway-external-lib'],
263
- 'version' => FLUENTCART_VERSION
264
- ]
265
- ];
266
- }
267
- }
268
- ```
269
-
270
- #### fields() method setup
271
-
272
- For a comprehensive guide on building gateway settings fields, see the detailed documentation: [Payment Gateway Settings Fields](./payment_setting_fields.md)
273
-
274
- Now your gateway registration is done, you will see your gateway in the payment methods list in FluentCart admin dashboard. And if you follow the [Fields](./payment_setting_fields.md) guide and Configure your gateway settings and save with **Payment activation** on, you will see the gateway in the payment methods list in FluentCart checkout page.
275
-
276
- ### Step 4: Create JavaScript File for Frontend Checkout
277
-
278
- FluentCart uses a custom event system to load payment methods in the checkout page. When a customer selects your payment method, FluentCart triggers a custom event in the format: `fluent_cart_load_payments_[payment_method_slug]`.
279
-
280
- Required — the Place Order button stays disabled without this
281
-
282
- Every gateway **must** register a listener for its `fluent_cart_load_payments_[payment_method_slug]` event and call `e.detail.paymentLoader.enableCheckoutButton()` once the gateway is ready to accept the order. FluentCart keeps the Place Order button greyed out while the selected payment method is loading, and it is your listener's `enableCheckoutButton()` call that re-enables it. If the listener is missing (or never calls `enableCheckoutButton()`), the Place Order button stays greyed out and the customer cannot check out — even a gateway with no frontend UI (offline/COD-style) needs this listener.
283
-
284
- Your JavaScript file must listen for this event and handle the payment process accordingly. Here's a simple example:
285
-
286
- ```
287
- window.addEventListener("fluent_cart_load_payments_your_gateway", function (e) {
288
- const submitButton = window.fluentcart_checkout_vars?.submit_button;
289
- const gatewayContainer = document.querySelector('.fluent-cart-checkout_embed_payment_container_your_gateway');
290
- const translations = window.fct_your_gateway_data?.translations || {};
291
-
292
- function $t(string) {
293
- return translations[string] || string;
294
- }
295
-
296
- // Simple implementation (like COD/offline payments)
297
- if (gatewayContainer) {
298
- gatewayContainer.innerHTML = `<p>${$t('Your payment instructions here.')}</p>`;
299
- }
300
-
301
- // Enable the checkout button
302
- e.detail.paymentLoader.enableCheckoutButton(submitButton.text);
303
-
304
- // OR if you need to integrate with a third-party SDK:
305
- // loadYourGatewaySDK(e.detail.paymentInfoUrl, e.detail.nonce, e.detail.form, e.detail.paymentLoader);
306
- });
307
-
308
- // Example function for loading a more complex gateway SDK
309
- function loadYourGatewaySDK(paymentInfoUrl, nonce, form, paymentLoader) {
310
- // Fetch payment information from server
311
- fetch(paymentInfoUrl, {
312
- method: "POST",
313
- headers: {
314
- "Content-Type": "application/json",
315
- "X-WP-Nonce": nonce,
316
- },
317
- credentials: 'include'
318
- }).then(response => response.json())
319
- .then(data => {
320
- // Initialize your gateway SDK with the data
321
- // When ready, enable the checkout button:
322
- paymentLoader.enableCheckoutButton('Pay Now');
323
- });
324
- }
325
- ```
326
-
327
- #### Payment methods list in FluentCart admin dashboard
328
-
329
- #### Payment method settings configuration page
330
-
331
- #### Active payment methods displayed in checkout page
332
-
333
- ## Start taking payments with your gateway
334
-
335
- ## Step 4: Create an API Handler
336
-
337
- Create a class for API communications with your payment provider:
338
-
339
- ```
340
- <?php
341
- namespace YourPlugin\PaymentMethods\YourGateway;
342
-
343
- use FluentCart\Framework\Support\Arr;
344
-
345
- class API
346
- {
347
- private $settings;
348
- private $mode;
349
- private $baseUrl;
350
-
351
- // $mode: pass the payment's own mode when you read or change an existing payment.
352
- public function __construct(YourGatewaySettings $settings, $mode = '')
353
- {
354
- $this->settings = $settings;
355
- $this->mode = $mode ?: $settings->getMode();
356
- $this->baseUrl = $this->mode === 'test'
357
- ? 'https://api-test.yourgateway.com/v1'
358
- : 'https://api.yourgateway.com/v1';
359
- }
360
-
361
- public function makeRequest($method, $endpoint, $data = [])
362
- {
363
- $args = [
364
- 'method' => $method,
365
- 'headers' => [
366
- 'Authorization' => 'Bearer ' . $this->settings->getApiKey($this->mode),
367
- 'Content-Type' => 'application/json',
368
- ],
369
- 'timeout' => 30
370
- ];
371
-
372
- if (!empty($data) && in_array($method, ['POST', 'PUT'])) {
373
- $args['body'] = json_encode($data);
374
- }
375
-
376
- $response = wp_remote_request($this->baseUrl . $endpoint, $args);
377
-
378
- if (is_wp_error($response)) {
379
- return [
380
- 'success' => false,
381
- 'message' => $response->get_error_message()
382
- ];
383
- }
384
-
385
- $body = wp_remote_retrieve_body($response);
386
- $data = json_decode($body, true);
387
- $code = wp_remote_retrieve_response_code($response);
388
-
389
- if ($code >= 400 || !is_array($data)) {
390
- return [
391
- 'success' => false,
392
- 'message' => is_array($data) ? Arr::get($data, 'error', 'API request failed') : 'Unreadable API response'
393
- ];
394
- }
395
-
396
- return [
397
- 'success' => true,
398
- 'data' => $data
399
- ];
400
- }
401
-
402
- public function createPayment($paymentData)
403
- {
404
- return $this->makeRequest('POST', '/payments', $paymentData);
405
- }
406
-
407
- public function getPayment($paymentId)
408
- {
409
- return $this->makeRequest('GET', '/payments/' . $paymentId);
410
- }
411
-
412
- public function createSubscription($subscriptionData)
413
- {
414
- return $this->makeRequest('POST', '/subscriptions', $subscriptionData);
415
- }
416
-
417
- public function refundPayment($paymentId, $amount, $reason = '')
418
- {
419
- return $this->makeRequest('POST', "/payments/{$paymentId}/refund", [
420
- 'amount' => $amount,
421
- 'reason' => $reason
422
- ]);
423
- }
424
- }
425
- ```
426
-
427
- A payment that already exists is read, captured or refunded in the mode it was created in (`$transaction->payment_mode`), not the store's current mode. Only a new payment uses the current mode.
428
-
429
- ## Step 5: Payment processing
430
-
431
- ```
432
- <?php
433
-
434
- #YourGateway.php
435
-
436
- public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance)
437
- {
438
- $order = $paymentInstance->order;
439
-
440
- // check if this is a subscription payment
441
- if ($paymentInstance->subscription) {
442
- return $this->handleSubscriptionPayment($paymentInstance);
443
- }
444
-
445
- // This is a regular one-time payment
446
- return $this->handleOneTimePayment($paymentInstance);
447
- }
448
-
449
- // Example of one-time payment processing
450
-
451
- // option 1: make payment with hosted(redirect) checkout
452
- private function handleOneTimePayment(PaymentInstance $paymentInstance)
453
- {
454
- $order = $paymentInstance->order;
455
- $transaction = $paymentInstance->transaction;
456
-
457
- $api = new API($this->settings);
458
-
459
- // Prepare payment data for the API
460
- $paymentData = [
461
- 'amount' => (int) $transaction->total, // cents; convert only if your gateway expects decimals
462
- 'currency' => $transaction->currency,
463
- // Stamp our transaction on the payment. Confirm and webhook check it later.
464
- 'metadata' => ['transaction_uuid' => $transaction->uuid],
465
- ];
466
-
467
- // A double click or a retried request must not create a second charge.
468
- $seed = $paymentInstance->getIdempotencySeed();
469
- if ($seed) {
470
- $paymentData['idempotency_key'] = 'fct_' . $seed; // send it the way your gateway expects
471
- }
472
-
473
- // Create payment in your gateway
474
- $result = $api->createPayment($paymentData);
475
-
476
- if ($result['success']) {
477
- // Store payment ID for later reference
478
- $transaction->update([
479
- ...
480
- ]);
481
-
482
- // Return the redirect response (for redirect-based gateways)
483
- return [
484
- 'status' => 'success',
485
- 'nextAction' => 'your_gateway',
486
- 'actionName' => 'redirect',
487
- 'message' => __('Redirecting to payment...', 'fluent-cart'),
488
- 'response' => $result,
489
- 'payment_args' => [
490
- 'checkout_url' => $result['data']['checkout_url'],
491
- ],
492
- ];
493
- }
494
- }
495
-
496
- // option 2: make payment onsite
497
- private function handleOneTimePayment(PaymentInstance $paymentInstance)
498
- {
499
- $order = $paymentInstance->order;
500
- $transaction = $paymentInstance->transaction;
501
-
502
- $api = new API($this->settings);
503
-
504
- // Prepare payment data for the API
505
- $paymentData = [
506
- 'amount' => (int) $transaction->total, // cents; convert only if your gateway expects decimals
507
- 'currency' => $transaction->currency,
508
- // Stamp our transaction on the payment. Confirm and webhook check it later.
509
- 'metadata' => ['transaction_uuid' => $transaction->uuid],
510
- ];
511
-
512
- // A double click or a retried request must not create a second charge.
513
- $seed = $paymentInstance->getIdempotencySeed();
514
- if ($seed) {
515
- $paymentData['idempotency_key'] = 'fct_' . $seed; // send it the way your gateway expects
516
- }
517
-
518
- // Create payment in your gateway
519
- $result = $api->createPayment($paymentData);
520
-
521
- if ($result['success']) {
522
- // Store payment ID for later reference
523
- $transaction->update([
524
- ...
525
- ]);
526
-
527
- // Return success response with custom action to redirect to your own your-gateway-checkout.js
528
- return [
529
- 'nextAction' => 'your_gateway',
530
- 'actionName' => 'custom',
531
- 'status' => 'success',
532
- 'message' => __('Order has been placed successfully', 'fluent-cart'),
533
- 'response' => $result,
534
- ];
535
- }
536
- }
537
-
538
- // ... subscription is similar to one-time payment
539
- ```
540
-
541
- `getIdempotencySeed()` returns the same value for a repeated submit of the same payment and a new value after a failed attempt is retried. It returns an empty string when there is no transaction yet. In that case send no idempotency key. Do not fall back to a fixed key.
542
-
543
- ### Return format of `makePaymentFromPaymentInstance()`
544
-
545
- The array returned from `makePaymentFromPaymentInstance()` tells the checkout frontend what to do next. The supported keys:
546
-
547
- | Key | Required | Description |
548
- | --- | --- | --- |
549
- | `status` | Yes | `'success'` when the payment was initiated successfully. |
550
- | `actionName` | Yes* | What the frontend should do: `'redirect'` (send the browser to `payment_args.checkout_url`) or `'custom'` (dispatch a `fluent_cart_payment_next_action_{nextAction}` event for your own JS to handle). |
551
- | `nextAction` | Yes* | Your payment method slug. For `actionName: 'custom'` it names the event your JS listens to (`fluent_cart_payment_next_action_your_gateway`). |
552
- | `message` | No | Status message shown while processing. |
553
- | `response` | No | The raw gateway API response. For `actionName: 'custom'` your JS receives it in the event's `detail.response`. |
554
- | `payment_args` | For redirect | Array of arguments for the next action. For `actionName: 'redirect'`, `payment_args.checkout_url` is the URL the browser is sent to (works inside the modal/iframe checkout too — the top window is redirected). |
555
-
556
- * Alternatively, returning a top-level `redirect_to` key redirects the browser to that URL directly without `actionName`/`payment_args`. The `actionName: 'redirect'` format above is the canonical one used by FluentCart's own gateways.
557
-
558
- For a redirect-based (hosted checkout) gateway, the full return looks like:
559
-
560
- ```
561
- return [
562
- 'status' => 'success',
563
- 'nextAction' => 'your_gateway',
564
- 'actionName' => 'redirect',
565
- 'message' => __('Redirecting...', 'fluent-cart'),
566
- 'response' => $apiResponse,
567
- 'payment_args' => [
568
- 'checkout_url' => $redirectUrl,
569
- ],
570
- ];
571
- ```
572
-
573
- ## Step 6: Confirm Payment
574
-
575
- A payment is confirmed in one method. The ajax handler, the webhook and a return-page check all call it, so the checks cannot differ between them.
576
-
577
- ```
578
- <?php
579
-
580
- #YourGateway.php
581
-
582
- public function boot()
583
- {
584
- ....
585
- add_action('wp_ajax_fluent_cart_confirm_your_gateway_payment', [$this, 'confirmPayment']);
586
- add_action('wp_ajax_nopriv_fluent_cart_confirm_your_gateway_payment', [$this, 'confirmPayment']);
587
- }
588
-
589
- // Ajax call from your-gateway-checkout.js (onsite payment)
590
- public function confirmPayment()
591
- {
592
- $transactionUuid = sanitize_text_field(wp_unslash(Arr::get($_REQUEST, 'transaction_id', '')));
593
- $paymentId = sanitize_text_field(wp_unslash(Arr::get($_REQUEST, 'payment_id', '')));
594
-
595
- $transaction = OrderTransaction::query()
596
- ->where('uuid', $transactionUuid)
597
- ->where('payment_method', 'your_gateway')
598
- ->first();
599
-
600
- if (!$transaction) {
601
- wp_send_json([
602
- 'message' => __('Transaction not found.', 'your-plugin'),
603
- 'status' => 'failed'
604
- ], 404);
605
- }
606
-
607
- // Prefer the payment ID saved in Step 5 over the one the browser sent.
608
- $paymentId = $transaction->vendor_charge_id ?: $paymentId;
609
-
610
- $confirmed = $this->confirmTransaction($transaction, $paymentId);
611
-
612
- if (is_wp_error($confirmed)) {
613
- wp_send_json([
614
- 'message' => $confirmed->get_error_message(),
615
- 'status' => 'failed'
616
- ], 422);
617
- }
618
-
619
- wp_send_json([
620
- 'redirect_url' => $transaction->getReceiptPageUrl(),
621
- 'order' => [
622
- 'uuid' => $transaction->order->uuid,
623
- ],
624
- 'message' => __('Payment confirmed successfully.', 'your-plugin'),
625
- 'status' => 'success'
626
- ], 200);
627
- }
628
-
629
- /**
630
- * @return true|\WP_Error
631
- */
632
- public function confirmTransaction(OrderTransaction $transaction, $paymentId)
633
- {
634
- // Already confirmed by the other path (webhook or ajax).
635
- if ($transaction->status === Status::TRANSACTION_SUCCEEDED) {
636
- return true;
637
- }
638
-
639
- // The ID can come from a request body. Check its format before it reaches a URL.
640
- // Widen the pattern if your gateway's IDs use other characters.
641
- if (!preg_match('/^[a-zA-Z0-9_-]+$/', (string) $paymentId)) {
642
- return new \WP_Error('invalid_payment_id', __('Invalid payment reference.', 'your-plugin'));
643
- }
644
-
645
- // Ask the gateway, in the mode the payment was created in.
646
- $api = new API($this->settings, $transaction->payment_mode);
647
- $result = $api->getPayment($paymentId);
648
-
649
- if (!Arr::get($result, 'success')) {
650
- return new \WP_Error('payment_lookup_failed', __('Could not verify the payment.', 'your-plugin'));
651
- }
652
-
653
- $payment = Arr::get($result, 'data', []);
654
-
655
- // Only your gateway's final "money captured" status counts as paid.
656
- if (Arr::get($payment, 'status') !== 'paid') {
657
- return new \WP_Error('payment_not_paid', __('The payment is not completed yet.', 'your-plugin'));
658
- }
659
-
660
- // It must be the payment created for this transaction, for this amount and currency.
661
- $sameTransaction = Arr::get($payment, 'metadata.transaction_uuid') === $transaction->uuid;
662
- $sameAmount = (int) Arr::get($payment, 'amount') === (int) $transaction->total;
663
- $sameCurrency = strtoupper((string) Arr::get($payment, 'currency')) === strtoupper((string) $transaction->currency);
664
-
665
- if (!$sameTransaction || !$sameAmount || !$sameCurrency) {
666
- return new \WP_Error('payment_mismatch', __('The payment does not match this order.', 'your-plugin'));
667
- }
668
-
669
- $transaction->fill([
670
- 'status' => Status::TRANSACTION_SUCCEEDED,
671
- 'vendor_charge_id' => $paymentId,
672
- ]);
673
- $transaction->save();
674
-
675
- $order = Order::query()->find($transaction->order_id);
676
- (new StatusHelper($order))->syncOrderStatuses($transaction);
677
-
678
- return true;
679
- }
680
- ```
681
-
682
- - Mark a payment paid only after the gateway reports its final captured status. A status such as "authorized", "pending" or "processing" is not paid.
683
- - Compare the amount in the unit your gateway uses. FluentCart amounts are in cents.
684
-
685
- #### Webhook / IPN
686
-
687
- Set this URL in your gateway's dashboard. In code it is `$this->getListenerUrl()['listener_url']`:
688
-
689
- ```
690
- https://your-site.com/?fluent-cart=fct_payment_listener_ipn&method=your_gateway
691
- ```
692
-
693
- ```
694
- <?php
695
-
696
- #YourGateway.php
697
-
698
- public function handleIPN(): void
699
- {
700
- $rawBody = file_get_contents('php://input');
701
- $event = json_decode($rawBody, true);
702
-
703
- if (!is_array($event)) {
704
- $this->sendWebhookResponse(400, 'Invalid payload');
705
- }
706
-
707
- // 1. Verify the event before acting on it.
708
- $secret = $this->settings->getWebhookSecret();
709
-
710
- if (!$secret) {
711
- // No secret saved for this mode: reject. Never accept an unverified event.
712
- $this->sendWebhookResponse(500, 'Webhook secret not configured');
713
- }
714
-
715
- // Read headers from $_SERVER. getallheaders() is missing on some hosts.
716
- $signature = sanitize_text_field(wp_unslash(Arr::get($_SERVER, 'HTTP_X_YOURGATEWAY_SIGNATURE', '')));
717
-
718
- if (!$signature || !hash_equals(hash_hmac('sha256', $rawBody, $secret), $signature)) {
719
- $this->sendWebhookResponse(401, 'Invalid signature');
720
- }
721
-
722
- // 2. Is it ours? Find the transaction by the uuid stamped in Step 5.
723
- $transactionUuid = sanitize_text_field(Arr::get($event, 'data.metadata.transaction_uuid', ''));
724
-
725
- $transaction = OrderTransaction::query()
726
- ->where('uuid', $transactionUuid)
727
- ->where('payment_method', 'your_gateway')
728
- ->first();
729
-
730
- if (!$transaction) {
731
- // Another site on the same gateway account, or not a FluentCart payment.
732
- $this->sendWebhookResponse(200, 'Not for this store');
733
- }
734
-
735
- // 3. Act on the gateway's live state, through the same method as Step 6.
736
- if (Arr::get($event, 'type') === 'payment.completed') {
737
- $confirmed = $this->confirmTransaction($transaction, Arr::get($event, 'data.id', ''));
738
-
739
- if (is_wp_error($confirmed) && $confirmed->get_error_code() === 'payment_lookup_failed') {
740
- // The gateway could not be reached. A non-2xx makes it deliver the event again.
741
- $this->sendWebhookResponse(503, 'Try again');
742
- }
743
- }
744
-
745
- $this->sendWebhookResponse(200, 'OK');
746
- }
747
-
748
- private function sendWebhookResponse($code, $message)
749
- {
750
- wp_send_json(['message' => $message], $code);
751
- }
752
- ```
753
-
754
- - **Verify first.** Check the signature the way your gateway documents it. If your gateway sends no signature, fetch the object from its API by ID and act only on what the API returns.
755
- - **Act on live state, not on the event body.** `confirmTransaction()` fetches the payment again, so an event that claims "completed" for an unpaid payment changes nothing.
756
- - **A repeated delivery answers 200.** Gateways send the same event more than once. `confirmTransaction()` returns early when the transaction is already succeeded. Answer 200 for work that is already done, or the gateway keeps retrying.
757
- - **Work that is not safe to repeat needs a claim.** If a handler has no such built-in check, claim the event ID first with `add_option($key, '1', '', false)`, answer 200 when the claim is already taken, and delete the claim if the work throws. Do not expire the claim.
758
- - **Look up by an ID of yours.** Match on the uuid you stamped, or on a vendor ID you saved, scoped to your gateway's `payment_method`. One gateway account often serves several sites.
759
-
760
- ### Step 7: (optional) Create your-gateway-checkout.js
761
-
762
- Create custom JavaScript file to handle (onsite) payment checkout, step #3 above is enough for (hosted) payment checkout.
763
-
764
- #### Example of onsite payment checkout with custom checkout button
765
-
766
- ```
767
- // File: assets/js/your-gateway-checkout.js
768
- class YourGatewayCheckout {
769
- constructor(form, orderHandler, response, paymentLoader) {
770
- this.form = form;
771
- this.orderHandler = orderHandler;
772
- this.response = response;
773
- this.paymentLoader = paymentLoader;
774
- this.paymentArgs = response?.payment_args || {};
775
- }
776
-
777
- init() {
778
- // Find the payment container
779
- const paymentContainer = document.querySelector('.fluent-cart-checkout_embed_payment_container_your_gateway');
780
- if (!paymentContainer) {
781
- console.error('Payment container not found');
782
- return;
783
- }
784
-
785
- // Create payment button
786
- this.createPaymentButton(paymentContainer);
787
-
788
- // Initialize gateway SDK (if applicable)
789
- this.initGatewaySDK();
790
- }
791
-
792
- createPaymentButton(container) {
793
- // Clear container
794
- container.innerHTML = '';
795
-
796
- // Create button
797
- const button = document.createElement('button');
798
- button.type = 'button';
799
- button.className = 'your-gateway-checkout-button';
800
- button.textContent = 'Pay with Your Gateway';
801
- button.style.cssText = `
802
- width: 100%;
803
- padding: 12px;
804
- background: #007bff;
805
- color: #fff;
806
- border: none;
807
- border-radius: 4px;
808
- font-size: 16px;
809
- cursor: pointer;
810
- `;
811
-
812
- // Add click event
813
- button.addEventListener('click', () => {
814
- this.handlePaymentButtonClick();
815
- });
816
-
817
- // Add to container
818
- container.appendChild(button);
819
- }
820
-
821
- initGatewaySDK() {
822
- // Initialize your gateway's SDK if required
823
- if (window.YourGatewaySDK) {
824
- window.YourGatewaySDK.initialize({
825
- publicKey: this.paymentArgs.public_key,
826
- environment: this.paymentArgs.mode
827
- });
828
- }
829
- }
830
-
831
- async handlePaymentButtonClick() {
832
- try {
833
- this.paymentLoader?.changeLoaderStatus('processing');
834
-
835
- // Create order in FluentCart first
836
- const orderResponse = await this.orderHandler.createOrder();
837
-
838
- if (!orderResponse?.success) {
839
- throw new Error('Failed to create order');
840
- }
841
-
842
- // For redirect-based gateways
843
- if (orderResponse.redirect_url) {
844
- window.location.href = orderResponse.redirect_url;
845
- return;
846
- }
847
-
848
- // For JS-based gateways, open checkout modal
849
- if (window.YourGatewaySDK) {
850
- const result = await window.YourGatewaySDK.openCheckout({
851
- amount: this.response.amount,
852
- currency: this.response.currency,
853
- orderId: orderResponse.order_id,
854
- onSuccess: (data) => {
855
- // Confirm payment on your server
856
- this.confirmPayment(data, orderResponse);
857
- },
858
- onCancel: () => {
859
- this.paymentLoader?.hideLoader();
860
- }
861
- });
862
- }
863
- } catch (error) {
864
- this.paymentLoader?.changeLoaderStatus('Error: ' + error.message);
865
- this.paymentLoader?.hideLoader();
866
- }
867
- }
868
-
869
- async confirmPayment(gatewayData, orderData) {
870
- try {
871
- // Confirm payment on your server
872
- const confirmResponse = await fetch(fluentCartData.ajax_url, {
873
- method: 'POST',
874
- headers: {"Content-Type": "application/json"},
875
- credentials: 'same-origin',
876
- body: JSON.stringify({
877
- action: 'fluent_cart_confirm_your_gateway_payment',
878
- transaction_id: orderData.transaction_id,
879
- payment_id: gatewayData.paymentId
880
- })
881
- });
882
-
883
- const confirmation = await confirmResponse.json();
884
-
885
- if (confirmation.success && confirmation.redirect_url) {
886
- window.location.href = confirmation.redirect_url;
887
- } else {
888
- throw new Error(confirmation.message || 'Payment confirmation failed');
889
- }
890
- } catch (error) {
891
- this.paymentLoader?.changeLoaderStatus('Error: ' + error.message);
892
- this.paymentLoader?.hideLoader();
893
- }
894
- }
895
- }
896
-
897
- // Initialize when FluentCart triggers the event
898
- window.addEventListener("fluent_cart_load_payments_your_gateway", function (e) {
899
- fetch(e.detail.paymentInfoUrl, {
900
- method: "POST",
901
- headers: {
902
- "Content-Type": "application/json"
903
- },
904
- credentials: 'include'
905
- })
906
- .then(response => response.json())
907
- .then(data => {
908
- new YourGatewayCheckout(
909
- e.detail.form,
910
- e.detail.orderHandler,
911
- data,
912
- e.detail.paymentLoader
913
- ).init();
914
- })
915
- .catch(error => {
916
- console.error('Error initializing gateway:', error);
917
- });
918
- });
919
- ```
920
-
921
- ## Key FluentCart Services to Use
922
-
923
- FluentCart provides these services to make gateway development easier:
924
-
925
- ### StatusHelper for Order Updates
926
-
927
- ```
928
- // Update order status and fire all necessary hooks
929
- (new \FluentCart\App\Helpers\StatusHelper($order))->syncOrderStatuses($transaction);
930
-
931
- // Hooks this call fires:
932
- // - fluent_cart/order_paid, then fluent_cart/order_paid_done
933
- // - fluent_cart/renewal_paid (renewal orders)
934
- // - fluent_cart/cart_completed
935
- // - fluent_cart/subscription_activated (when a subscription starts)
936
- $data = [
937
- 'order' => $this->order,
938
- 'customer' => $this->customer ?? null,
939
- 'transaction' => $this->transaction ?? null
940
- ];
941
- ```
942
-
943
- ### Refunds
944
-
945
- A gateway talks to the provider. FluentCart records the refund. Keep the two apart.
946
-
947
- Declare `'refund'` in `$supportedFeatures`. Without it, FluentCart records the refund without calling your gateway and tells the admin to return the money through the provider.
948
-
949
- #### Admin refund: `processRefund()`
950
-
951
- Call the provider and return the vendor refund ID, or a `WP_Error` when the provider reports `failed` or `canceled`.
952
-
953
- ```
954
- public function processRefund($transaction, $amount, $args)
955
- {
956
- $refund = $this->api->refund($transaction->vendor_charge_id, $amount, [
957
- 'idempotency_key' => 'refund_' . wp_generate_uuid4(),
958
- ]);
959
-
960
- if (is_wp_error($refund) || in_array($refund['status'], ['failed', 'canceled'], true)) {
961
- return new \WP_Error('refund_failed', 'Provider message');
962
- }
963
-
964
- return $refund['id']; // 'pending' is success; return '' if the provider gives no ID yet
965
- }
966
- ```
967
-
968
- - Do not write, update or delete a refund row. FluentCart writes it after you return.
969
- - Do not dispatch `OrderRefund`.
970
- - A thrown exception or `WP_Error` shows the admin the "record locally" prompt, where the admin can choose to record the refund without the gateway.
971
- - `$amount` is in cents. Convert it if your provider expects decimals.
972
- - Generate the idempotency key once per `processRefund()` call and reuse it only to retry that request. A key built only from payment ID and amount makes a second refund of the same amount replay the first.
973
-
974
- #### Webhook refund: `Refund::createOrRecordRefund()`
975
-
976
- Resolve the parent charge, then record through the core helper. Do not match rows yourself.
977
-
978
- ```
979
- \FluentCart\App\Services\Payments\Refund::createOrRecordRefund([
980
- 'vendor_charge_id' => $refundId, // the provider's refund ID
981
- 'payment_method' => 'your_gateway',
982
- 'status' => 'refunded', // refunded | pending | failed
983
- 'total' => $refundAmount, // cents
984
- ], $parentTransaction);
985
- ```
986
-
987
- Check the return value. If another refund holds the order's lock for 10 seconds, the helper records nothing and returns `WP_Error('refund_lock_timeout')`. Answer a non-2xx (503, or 500) for that code only, so the provider redelivers. Redelivery is safe: the refund matches by vendor refund ID. If you dedupe events before the handler runs, clear that mark first, or the redelivery is skipped.
988
-
989
- ```
990
- $recorded = \FluentCart\App\Services\Payments\Refund::createOrRecordRefund($data, $parentTransaction);
991
-
992
- if (is_wp_error($recorded) && $recorded->get_error_code() === 'refund_lock_timeout') {
993
- status_header(503);
994
- exit;
995
- }
996
- ```
997
-
998
- It matches an existing row by vendor refund ID, then a refund recorded without an ID for the same charge and amount, and otherwise creates one. When a refund first becomes `refunded`, it updates the charge's refunded total and fires `OrderRefund` once, so the refund email and order payment status update run once. A `pending` row adds nothing until it becomes `refunded`. A `failed` report never adopts a locally recorded row.
999
-
1000
- #### Recording locally
1001
-
1002
- When the provider cannot be reached or rejects the refund, an admin can record the refund in FluentCart only. It does not cancel the subscription and returns no money. If the provider later reports a refund of the same amount on the same charge, the helper above attaches its refund ID to that row instead of adding a second one. A different amount is recorded as a separate refund.
1003
-
1004
- ### Subscription Handling
1005
-
1006
- For subscription renewals, use `SubscriptionService`. There is no `SubscriptionRenewal` class. Note the argument order: the transaction data comes **first**, the subscription second.
1007
-
1008
- ```
1009
- $recorded = \FluentCart\App\Modules\Subscriptions\Services\SubscriptionService::recordRenewalPayment(
1010
- [
1011
- 'total' => $amount, // cents
1012
- 'vendor_charge_id' => $paymentId, // also used to skip a charge already recorded
1013
- 'payment_method' => 'your_gateway',
1014
- ],
1015
- $subscription, // optional
1016
- [] // optional subscription update args
1017
- );
1018
-
1019
- if (is_wp_error($recorded) && $recorded->get_error_code() !== 'transaction_exists') {
1020
- // Not recorded. Answer non-2xx so the gateway delivers the event again.
1021
- status_header(500);
1022
- exit;
1023
- }
1024
- ```
1025
-
1026
- - `status` defaults to `Status::TRANSACTION_SUCCEEDED`. `total` defaults to the subscription's recurring total.
1027
- - The call returns the `OrderTransaction`, or a `WP_Error`. `transaction_exists` means the charge is already recorded: treat it as done.
1028
- - Do not add your own duplicate check around this call. It matches by `vendor_charge_id`.
1029
-
1030
- A store can also bill subscriptions itself instead of through the gateway (Store Billing). Which mode a store uses is the merchant's setting; your gateway only declares what it supports. See [Subscriptions](/modules/subscriptions.md) for `manual_subscription`, `system_subscription`, `shouldChargeSubscriptionAsOneTime()` and `chargeRenewal()`.
1031
-
1032
- ## Important Hooks
1033
-
1034
- Key hooks to be aware of:
1035
-
1036
- 1. **Payment Hooks** (Handled by StatusHelper):`fluent_cart/order_paid`
1037
- 2. `fluent_cart/order_paid_done`
1038
- 3. `fluent_cart/renewal_paid`
1039
- 4. `fluent_cart/cart_completed`
1040
- 5. **Subscription Hooks** (dispatched as events):`fluent_cart/subscription_activated`
1041
- 6. `fluent_cart/subscription_renewed`
1042
- 7. `fluent_cart/subscription_canceled` — one `l`, matching `Status::SUBSCRIPTION_CANCELED`
1043
- 8. `fluent_cart/subscription_renewal_failed`
1044
- 9. `fluent_cart/subscription_paused`, `_resumed`, `_reactivated`
1045
-
1046
- Learn more about hooks in [FluentCart Hooks](./../hooks/) documentation.
1047
-
1048
- ## Testing Your Gateway
1049
-
1050
- 1. **Install & Activate**: Activate your plugin in WordPress
1051
- 2. **Configure**: Go to FluentCart → Settings → Payment Methods
1052
- 3. **Test Payment**: Test a one-time payment on the checkout page
1053
- 4. **Test Subscription**: Test a subscription product if supported
1054
- 5. **Test Webhooks**: Send test events from your gateway's dashboard or CLI and check that: an event with a wrong or missing signature is rejected and the order does not change
1055
- 6. the same event sent twice answers 200 both times and the order changes once
1056
- 7. an event for a payment this site did not create answers 200 and changes nothing
1057
- 8. **Test Confirmation**: A payment that is not captured yet, or whose amount or currency differs from the order, is not marked paid
1058
- 9. **Test Refunds**: A full refund, then two partial refunds of the same amount on one order
1059
-
1060
- ## Common Pitfalls
1061
-
1062
- A few things that aren't obvious from the interface/base class alone and can cost time to reverse-engineer:
1063
-
1064
- - **Amounts are already in minor units.** FluentCart stores/passes order and transaction amounts in minor units (cents/øre — e.g. `$5.00` is `500`). Do not multiply by 100 again when sending amounts to your gateway's API — that doubles (well, 100×s) every charge. Only convert if your gateway's API expects major units.
1065
- - **`renderStoreModeNotice()` must be `public`.** It's called by the parent class to render the test/live mode notice in admin, so declaring it `protected`/`private` breaks the call even though it feels like an internal helper.
1066
- - **`getOrderInfo(array $data)` is required.** It's declared on `PaymentGatewayInterface`, not flagged with an `abstract` keyword on `AbstractPaymentGateway` itself — easy to miss and skip, but omitting it is a fatal error.
1067
- - **Read the store currency via `CurrencySettings::get('currency')`** (`FluentCart\Api\CurrencySettings`), not by re-deriving it from settings/options yourself.
1068
- - **Don't eagerly `require` your gateway class file** — see the warning in [Step 1](#step-1-register-your-gateway). Load it lazily from inside the `fluent_cart/register_payment_methods` callback, not at plugin bootstrap or on `fluentcart_loaded`.
1069
- - **Never store raw card details.** Tokenize the card with your gateway and save only the token it returns.
1070
- - **Show customers only the invoice number.** In emails and other customer-facing text use `invoice_no`. The order `uuid` opens the receipt page without a login, and the `id` is a running number. When `invoice_no` is empty, show no number.
1071
- - **Keep `isCurrencySupported()` and `isEnabled()` fast.** FluentCart calls them when it builds the checkout payment list. Read saved settings only. Call your gateway's API when the merchant saves the settings, not here.
1072
- - **Read webhook headers from `$_SERVER`.** `getallheaders()` is not available on every host. `X-Yourgateway-Signature` is `$_SERVER['HTTP_X_YOURGATEWAY_SIGNATURE']`.
1073
-
1074
- ## Additional Resources
1075
-
1076
- For more detailed examples, you can refer to:
1077
-
1078
- - Built-in payment methods in FluentCart (Stripe, PayPal)
1079
- - [Paddle Gateway Implementation](./paddle-example.md) for a complete, real-world example
1
+ # Payment Gateway Integration Guide
2
+
3
+ This guide provides a step-by-step approach to integrate your payment gateway with FluentCart. Follow these steps to create a fully functional payment gateway with support for one-time payments, subscriptions, and web hooks.
4
+
5
+ ## Implementation Steps
6
+
7
+ ### Step 1: Register Your Gateway
8
+
9
+ In your plugin's main file, register your gateway with FluentCart using the hook approach (recommended):
10
+
11
+ ```
12
+ // In your-plugin.php
13
+ add_action('fluent_cart/register_payment_methods', function() {
14
+ if (!function_exists('fluent_cart_api')) {
15
+ return; // FluentCart not active
16
+ }
17
+
18
+ // Register your custom gateway
19
+ fluent_cart_api()->registerCustomPaymentMethod(
20
+ 'your_gateway',
21
+ new \YourPlugin\PaymentMethods\YourGateway\YourGateway()
22
+ );
23
+ });
24
+ ```
25
+
26
+ Don't eagerly `require` your gateway class file
27
+
28
+ `fluent_cart/register_payment_methods` fires on WordPress `init` (after FluentCart's own `plugins_loaded` → `fluentcart_loaded` → `init` chain), so calling `registerCustomPaymentMethod` inside it — as shown above — is already safe timing-wise. The pitfall is elsewhere: if your plugin's bootstrap `require`s the file that *defines* `class YourGateway extends AbstractPaymentGateway` too early (top-level in your main plugin file, or tied to `fluentcart_loaded`), PHP fatals on class-not-found at include time — `AbstractPaymentGateway`/`BaseGatewaySettings` may not exist yet at that point. Only `require`/autoload the gateway class file from inside the `fluent_cart/register_payment_methods` callback itself (or via lazy PSR-4 autoloading triggered by `new YourGateway()` there), same as the example above.
29
+
30
+ Alternatively, you can register on the `init` hook (not recommended):
31
+
32
+ ```
33
+ add_action('init', function() {
34
+ if (!function_exists('fluent_cart_api')) {
35
+ return;
36
+ }
37
+ fluent_cart_api()->registerCustomPaymentMethod('your_gateway', new \YourPlugin\PaymentMethods\YourGateway\YourGateway());
38
+ });
39
+ ```
40
+
41
+ ### Step 2: Create the Settings Class
42
+
43
+ Create a settings class that extends `BaseGatewaySettings`:
44
+
45
+ ```
46
+ <?php
47
+ namespace YourPlugin\PaymentMethods\YourGateway;
48
+
49
+ use FluentCart\App\Helpers\Helper;
50
+ use FluentCart\App\Modules\PaymentMethods\Core\BaseGatewaySettings;
51
+ use FluentCart\Framework\Support\Arr;
52
+
53
+ class YourGatewaySettings extends BaseGatewaySettings
54
+ {
55
+ public $methodHandler = 'fluent_cart_payment_settings_your_gateway';
56
+
57
+ public static function getDefaults()
58
+ {
59
+ return [
60
+ 'is_active' => 'no',
61
+ 'payment_mode' => 'test', // test or live
62
+ 'test_api_key' => '',
63
+ 'test_secret_key' => '',
64
+ 'test_webhook_secret' => '',
65
+ 'live_api_key' => '',
66
+ 'live_secret_key' => '',
67
+ 'live_webhook_secret' => '',
68
+ ];
69
+ }
70
+
71
+ // Required by BaseGatewaySettings.
72
+ public function get($key = '')
73
+ {
74
+ if ($key) {
75
+ return Arr::get($this->settings, $key);
76
+ }
77
+
78
+ return $this->settings;
79
+ }
80
+
81
+ // Required by BaseGatewaySettings.
82
+ public function getMode()
83
+ {
84
+ return $this->get('payment_mode');
85
+ }
86
+
87
+ // Required by BaseGatewaySettings.
88
+ public function isActive()
89
+ {
90
+ return $this->get('is_active') === 'yes';
91
+ }
92
+
93
+ public function isTestMode()
94
+ {
95
+ return $this->getMode() === 'test';
96
+ }
97
+
98
+ public function getApiKey($mode = '')
99
+ {
100
+ $mode = $mode ?: $this->getMode();
101
+
102
+ return $this->get($mode . '_api_key');
103
+ }
104
+
105
+ public function getSecretKey($mode = '')
106
+ {
107
+ $mode = $mode ?: $this->getMode();
108
+
109
+ return (string) Helper::decryptKey($this->get($mode . '_secret_key'));
110
+ }
111
+
112
+ public function getWebhookSecret($mode = '')
113
+ {
114
+ $mode = $mode ?: $this->getMode();
115
+
116
+ return (string) Helper::decryptKey($this->get($mode . '_webhook_secret'));
117
+ }
118
+ }
119
+ ```
120
+
121
+ Encrypt the secret fields when the settings are saved. Add this to your gateway class (Step 3):
122
+
123
+ ```
124
+ public static function beforeSettingsUpdate($data, $oldSettings): array
125
+ {
126
+ $secretFields = ['test_secret_key', 'live_secret_key', 'test_webhook_secret', 'live_webhook_secret'];
127
+
128
+ foreach ($secretFields as $field) {
129
+ $value = Arr::get($data, $field, '');
130
+
131
+ // Encrypt only a value that changed. The stored one is already encrypted.
132
+ if ($value && $value !== Arr::get($oldSettings, $field, '')) {
133
+ $data[$field] = Helper::encryptKey($value);
134
+ }
135
+ }
136
+
137
+ return $data;
138
+ }
139
+ ```
140
+
141
+ Call `Helper::decryptKey()` only on a field you encrypted here. It returns `false` for a plain value that is valid base64, and most API keys are.
142
+
143
+ ### Step 3: Create your Gateway Class
144
+
145
+ Create base class that implements all required methods:
146
+
147
+ ```
148
+ <?php
149
+ namespace YourPlugin\PaymentMethods\YourGateway;
150
+
151
+ use FluentCart\App\Helpers\Helper;
152
+ use FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway;
153
+ use FluentCart\App\Services\Payments\PaymentInstance;
154
+ use FluentCart\Framework\Support\Arr;
155
+
156
+ class YourGateway extends AbstractPaymentGateway
157
+ {
158
+ // Define supported features
159
+ // 'payment' and 'refund' are queried through has(). 'webhook' is
160
+ // declarative, and every built-in gateway lists it.
161
+ //
162
+ // Leave 'subscriptions' out: AbstractPaymentGateway::__construct() appends
163
+ // it when you pass a subscription module.
164
+ public array $supportedFeatures = [
165
+ 'payment',
166
+ 'refund',
167
+ 'webhook'
168
+ ];
169
+
170
+ public function __construct()
171
+ {
172
+ // AbstractPaymentGateway::__construct() is type-enforced: it requires a
173
+ // BaseGatewaySettings instance as its first argument. Passing anything else
174
+ // (or omitting it) is a fatal TypeError, not a soft failure.
175
+ parent::__construct(new YourGatewaySettings());
176
+
177
+ }
178
+
179
+ public function boot()
180
+ {
181
+ // initialize any hanldere, webhook/ payment confirmation class if needed
182
+ }
183
+
184
+ // Required: Return gateway metadata
185
+ public function meta(): array
186
+ {
187
+ return [
188
+ 'title' => __('Your Gateway', 'your-plugin'),
189
+ 'route' => 'your_gateway',
190
+ 'slug' => 'your_gateway',
191
+ 'description' => __('Accept payments with Your Gateway', 'your-plugin'),
192
+ 'logo' => plugin_dir_url(__FILE__) .
193
+ 'assets/images/logo.svg',
194
+ 'icon' => plugin_dir_url(__FILE__) .
195
+ 'assets/images/icon.svg',
196
+ 'status' => $this->settings->get('is_active') === 'yes',
197
+ 'supported_features' => $this->supportedFeatures
198
+ ];
199
+ }
200
+
201
+ // Not required: AbstractPaymentGateway already implements has() against
202
+ // $supportedFeatures. Override it only if you need custom feature logic.
203
+
204
+ // Required: Process payment
205
+ public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance)
206
+ {
207
+ // Your payment processing logic here
208
+
209
+ }
210
+
211
+ // Required: Handle IPNs/Webhooks
212
+ public function handleIPN()
213
+ {
214
+ // Process the webhook
215
+
216
+ }
217
+
218
+ #required: Return settings fields configuration
219
+ public function fields(): array
220
+ {
221
+ // For a comprehensive guide on building gateway settings fields,
222
+ // see the detailed [Payment Gateway Settings Fields] documentation link given below
223
+ return [
224
+ ....
225
+ ];
226
+ }
227
+
228
+ // For a comprehensive guide on building gateway settings fields,
229
+ // see the detailed documentation: [Payment Gateway Settings Fields](./payment_setting_fields.md)
230
+
231
+ // Required: declared on PaymentGatewayInterface, not just a convention —
232
+ // omitting it is a fatal "abstract method not implemented" error, even though
233
+ // AbstractPaymentGateway doesn't spell it out with a PHP `abstract` keyword.
234
+ #required: Get order information for frontend
235
+ public function getOrderInfo(array $data)
236
+ {
237
+ // Prepare frontend data for checkout
238
+ $paymentArgs = [];
239
+
240
+ // Return data for frontend
241
+ wp_send_json([
242
+ 'status' => 'success',
243
+ 'payment_args' => $paymentArgs,
244
+ 'message' => __('Order info retrieved', 'your-plugin')
245
+ ], 200);
246
+ }
247
+
248
+ #required: Register scripts (automatically called by base gateway)
249
+ public function getEnqueueScriptSrc($hasSubscription = 'no'): array
250
+ {
251
+ // External gateway library, custom checkout scripts (if needed), otherwise return empty array
252
+ $gatewayLibUrl = 'https://js.yourgateway.com/v1/checkout.js';
253
+
254
+ return [
255
+ [
256
+ 'handle' => 'your-gateway-external-lib',
257
+ 'src' => $gatewayLibUrl,
258
+ ],
259
+ [
260
+ 'handle' => 'fluent-cart-your-gateway-checkout',
261
+ 'src' => plugin_dir_url(__FILE__) . 'assets/js/your-gateway-checkout.js',
262
+ 'deps' => ['your-gateway-external-lib'],
263
+ 'version' => FLUENTCART_VERSION
264
+ ]
265
+ ];
266
+ }
267
+ }
268
+ ```
269
+
270
+ #### fields() method setup
271
+
272
+ For a comprehensive guide on building gateway settings fields, see the detailed documentation: [Payment Gateway Settings Fields](./payment_setting_fields.md)
273
+
274
+ Now your gateway registration is done, you will see your gateway in the payment methods list in FluentCart admin dashboard. And if you follow the [Fields](./payment_setting_fields.md) guide and Configure your gateway settings and save with **Payment activation** on, you will see the gateway in the payment methods list in FluentCart checkout page.
275
+
276
+ ### Step 4: Create JavaScript File for Frontend Checkout
277
+
278
+ FluentCart uses a custom event system to load payment methods in the checkout page. When a customer selects your payment method, FluentCart triggers a custom event in the format: `fluent_cart_load_payments_[payment_method_slug]`.
279
+
280
+ Required — the Place Order button stays disabled without this
281
+
282
+ Every gateway **must** register a listener for its `fluent_cart_load_payments_[payment_method_slug]` event and call `e.detail.paymentLoader.enableCheckoutButton()` once the gateway is ready to accept the order. FluentCart keeps the Place Order button greyed out while the selected payment method is loading, and it is your listener's `enableCheckoutButton()` call that re-enables it. If the listener is missing (or never calls `enableCheckoutButton()`), the Place Order button stays greyed out and the customer cannot check out — even a gateway with no frontend UI (offline/COD-style) needs this listener.
283
+
284
+ Your JavaScript file must listen for this event and handle the payment process accordingly. Here's a simple example:
285
+
286
+ ```
287
+ window.addEventListener("fluent_cart_load_payments_your_gateway", function (e) {
288
+ const submitButton = window.fluentcart_checkout_vars?.submit_button;
289
+ const gatewayContainer = document.querySelector('.fluent-cart-checkout_embed_payment_container_your_gateway');
290
+ const translations = window.fct_your_gateway_data?.translations || {};
291
+
292
+ function $t(string) {
293
+ return translations[string] || string;
294
+ }
295
+
296
+ // Simple implementation (like COD/offline payments)
297
+ if (gatewayContainer) {
298
+ gatewayContainer.innerHTML = `<p>${$t('Your payment instructions here.')}</p>`;
299
+ }
300
+
301
+ // Enable the checkout button
302
+ e.detail.paymentLoader.enableCheckoutButton(submitButton.text);
303
+
304
+ // OR if you need to integrate with a third-party SDK:
305
+ // loadYourGatewaySDK(e.detail.paymentInfoUrl, e.detail.nonce, e.detail.form, e.detail.paymentLoader);
306
+ });
307
+
308
+ // Example function for loading a more complex gateway SDK
309
+ function loadYourGatewaySDK(paymentInfoUrl, nonce, form, paymentLoader) {
310
+ // Fetch payment information from server
311
+ fetch(paymentInfoUrl, {
312
+ method: "POST",
313
+ headers: {
314
+ "Content-Type": "application/json",
315
+ "X-WP-Nonce": nonce,
316
+ },
317
+ credentials: 'include'
318
+ }).then(response => response.json())
319
+ .then(data => {
320
+ // Initialize your gateway SDK with the data
321
+ // When ready, enable the checkout button:
322
+ paymentLoader.enableCheckoutButton('Pay Now');
323
+ });
324
+ }
325
+ ```
326
+
327
+ #### Payment methods list in FluentCart admin dashboard
328
+
329
+ #### Payment method settings configuration page
330
+
331
+ #### Active payment methods displayed in checkout page
332
+
333
+ ## Start taking payments with your gateway
334
+
335
+ ## Step 4: Create an API Handler
336
+
337
+ Create a class for API communications with your payment provider:
338
+
339
+ ```
340
+ <?php
341
+ namespace YourPlugin\PaymentMethods\YourGateway;
342
+
343
+ use FluentCart\Framework\Support\Arr;
344
+
345
+ class API
346
+ {
347
+ private $settings;
348
+ private $mode;
349
+ private $baseUrl;
350
+
351
+ // $mode: pass the payment's own mode when you read or change an existing payment.
352
+ public function __construct(YourGatewaySettings $settings, $mode = '')
353
+ {
354
+ $this->settings = $settings;
355
+ $this->mode = $mode ?: $settings->getMode();
356
+ $this->baseUrl = $this->mode === 'test'
357
+ ? 'https://api-test.yourgateway.com/v1'
358
+ : 'https://api.yourgateway.com/v1';
359
+ }
360
+
361
+ public function makeRequest($method, $endpoint, $data = [])
362
+ {
363
+ $args = [
364
+ 'method' => $method,
365
+ 'headers' => [
366
+ 'Authorization' => 'Bearer ' . $this->settings->getApiKey($this->mode),
367
+ 'Content-Type' => 'application/json',
368
+ ],
369
+ 'timeout' => 30
370
+ ];
371
+
372
+ if (!empty($data) && in_array($method, ['POST', 'PUT'])) {
373
+ $args['body'] = json_encode($data);
374
+ }
375
+
376
+ $response = wp_remote_request($this->baseUrl . $endpoint, $args);
377
+
378
+ if (is_wp_error($response)) {
379
+ return [
380
+ 'success' => false,
381
+ 'message' => $response->get_error_message()
382
+ ];
383
+ }
384
+
385
+ $body = wp_remote_retrieve_body($response);
386
+ $data = json_decode($body, true);
387
+ $code = wp_remote_retrieve_response_code($response);
388
+
389
+ if ($code >= 400 || !is_array($data)) {
390
+ return [
391
+ 'success' => false,
392
+ 'message' => is_array($data) ? Arr::get($data, 'error', 'API request failed') : 'Unreadable API response'
393
+ ];
394
+ }
395
+
396
+ return [
397
+ 'success' => true,
398
+ 'data' => $data
399
+ ];
400
+ }
401
+
402
+ public function createPayment($paymentData)
403
+ {
404
+ return $this->makeRequest('POST', '/payments', $paymentData);
405
+ }
406
+
407
+ public function getPayment($paymentId)
408
+ {
409
+ return $this->makeRequest('GET', '/payments/' . $paymentId);
410
+ }
411
+
412
+ public function createSubscription($subscriptionData)
413
+ {
414
+ return $this->makeRequest('POST', '/subscriptions', $subscriptionData);
415
+ }
416
+
417
+ public function refundPayment($paymentId, $amount, $reason = '')
418
+ {
419
+ return $this->makeRequest('POST', "/payments/{$paymentId}/refund", [
420
+ 'amount' => $amount,
421
+ 'reason' => $reason
422
+ ]);
423
+ }
424
+ }
425
+ ```
426
+
427
+ A payment that already exists is read, captured or refunded in the mode it was created in (`$transaction->payment_mode`), not the store's current mode. Only a new payment uses the current mode.
428
+
429
+ ## Step 5: Payment processing
430
+
431
+ ```
432
+ <?php
433
+
434
+ #YourGateway.php
435
+
436
+ public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance)
437
+ {
438
+ $order = $paymentInstance->order;
439
+
440
+ // check if this is a subscription payment
441
+ if ($paymentInstance->subscription) {
442
+ return $this->handleSubscriptionPayment($paymentInstance);
443
+ }
444
+
445
+ // This is a regular one-time payment
446
+ return $this->handleOneTimePayment($paymentInstance);
447
+ }
448
+
449
+ // Example of one-time payment processing
450
+
451
+ // option 1: make payment with hosted(redirect) checkout
452
+ private function handleOneTimePayment(PaymentInstance $paymentInstance)
453
+ {
454
+ $order = $paymentInstance->order;
455
+ $transaction = $paymentInstance->transaction;
456
+
457
+ $api = new API($this->settings);
458
+
459
+ // Prepare payment data for the API
460
+ $paymentData = [
461
+ 'amount' => (int) $transaction->total, // cents; convert only if your gateway expects decimals
462
+ 'currency' => $transaction->currency,
463
+ // Stamp our transaction on the payment. Confirm and webhook check it later.
464
+ 'metadata' => ['transaction_uuid' => $transaction->uuid],
465
+ ];
466
+
467
+ // A double click or a retried request must not create a second charge.
468
+ $seed = $paymentInstance->getIdempotencySeed();
469
+ if ($seed) {
470
+ $paymentData['idempotency_key'] = 'fct_' . $seed; // send it the way your gateway expects
471
+ }
472
+
473
+ // Create payment in your gateway
474
+ $result = $api->createPayment($paymentData);
475
+
476
+ if ($result['success']) {
477
+ // Store payment ID for later reference
478
+ $transaction->update([
479
+ ...
480
+ ]);
481
+
482
+ // Return the redirect response (for redirect-based gateways)
483
+ return [
484
+ 'status' => 'success',
485
+ 'nextAction' => 'your_gateway',
486
+ 'actionName' => 'redirect',
487
+ 'message' => __('Redirecting to payment...', 'fluent-cart'),
488
+ 'response' => $result,
489
+ 'payment_args' => [
490
+ 'checkout_url' => $result['data']['checkout_url'],
491
+ ],
492
+ ];
493
+ }
494
+ }
495
+
496
+ // option 2: make payment onsite
497
+ private function handleOneTimePayment(PaymentInstance $paymentInstance)
498
+ {
499
+ $order = $paymentInstance->order;
500
+ $transaction = $paymentInstance->transaction;
501
+
502
+ $api = new API($this->settings);
503
+
504
+ // Prepare payment data for the API
505
+ $paymentData = [
506
+ 'amount' => (int) $transaction->total, // cents; convert only if your gateway expects decimals
507
+ 'currency' => $transaction->currency,
508
+ // Stamp our transaction on the payment. Confirm and webhook check it later.
509
+ 'metadata' => ['transaction_uuid' => $transaction->uuid],
510
+ ];
511
+
512
+ // A double click or a retried request must not create a second charge.
513
+ $seed = $paymentInstance->getIdempotencySeed();
514
+ if ($seed) {
515
+ $paymentData['idempotency_key'] = 'fct_' . $seed; // send it the way your gateway expects
516
+ }
517
+
518
+ // Create payment in your gateway
519
+ $result = $api->createPayment($paymentData);
520
+
521
+ if ($result['success']) {
522
+ // Store payment ID for later reference
523
+ $transaction->update([
524
+ ...
525
+ ]);
526
+
527
+ // Return success response with custom action to redirect to your own your-gateway-checkout.js
528
+ return [
529
+ 'nextAction' => 'your_gateway',
530
+ 'actionName' => 'custom',
531
+ 'status' => 'success',
532
+ 'message' => __('Order has been placed successfully', 'fluent-cart'),
533
+ 'response' => $result,
534
+ ];
535
+ }
536
+ }
537
+
538
+ // ... subscription is similar to one-time payment
539
+ ```
540
+
541
+ `getIdempotencySeed()` returns the same value for a repeated submit of the same payment and a new value after a failed attempt is retried. It returns an empty string when there is no transaction yet. In that case send no idempotency key. Do not fall back to a fixed key.
542
+
543
+ ### Return format of `makePaymentFromPaymentInstance()`
544
+
545
+ The array returned from `makePaymentFromPaymentInstance()` tells the checkout frontend what to do next. The supported keys:
546
+
547
+ | Key | Required | Description |
548
+ | --- | --- | --- |
549
+ | `status` | Yes | `'success'` when the payment was initiated successfully. |
550
+ | `actionName` | Yes* | What the frontend should do: `'redirect'` (send the browser to `payment_args.checkout_url`) or `'custom'` (dispatch a `fluent_cart_payment_next_action_{nextAction}` event for your own JS to handle). |
551
+ | `nextAction` | Yes* | Your payment method slug. For `actionName: 'custom'` it names the event your JS listens to (`fluent_cart_payment_next_action_your_gateway`). |
552
+ | `message` | No | Status message shown while processing. |
553
+ | `response` | No | The raw gateway API response. For `actionName: 'custom'` your JS receives it in the event's `detail.response`. |
554
+ | `payment_args` | For redirect | Array of arguments for the next action. For `actionName: 'redirect'`, `payment_args.checkout_url` is the URL the browser is sent to (works inside the modal/iframe checkout too — the top window is redirected). |
555
+
556
+ * Alternatively, returning a top-level `redirect_to` key redirects the browser to that URL directly without `actionName`/`payment_args`. The `actionName: 'redirect'` format above is the canonical one used by FluentCart's own gateways.
557
+
558
+ For a redirect-based (hosted checkout) gateway, the full return looks like:
559
+
560
+ ```
561
+ return [
562
+ 'status' => 'success',
563
+ 'nextAction' => 'your_gateway',
564
+ 'actionName' => 'redirect',
565
+ 'message' => __('Redirecting...', 'fluent-cart'),
566
+ 'response' => $apiResponse,
567
+ 'payment_args' => [
568
+ 'checkout_url' => $redirectUrl,
569
+ ],
570
+ ];
571
+ ```
572
+
573
+ ## Step 6: Confirm Payment
574
+
575
+ A payment is confirmed in one method. The ajax handler, the webhook and a return-page check all call it, so the checks cannot differ between them.
576
+
577
+ ```
578
+ <?php
579
+
580
+ #YourGateway.php
581
+
582
+ public function boot()
583
+ {
584
+ ....
585
+ add_action('wp_ajax_fluent_cart_confirm_your_gateway_payment', [$this, 'confirmPayment']);
586
+ add_action('wp_ajax_nopriv_fluent_cart_confirm_your_gateway_payment', [$this, 'confirmPayment']);
587
+ }
588
+
589
+ // Ajax call from your-gateway-checkout.js (onsite payment)
590
+ public function confirmPayment()
591
+ {
592
+ $transactionUuid = sanitize_text_field(wp_unslash(Arr::get($_REQUEST, 'transaction_id', '')));
593
+ $paymentId = sanitize_text_field(wp_unslash(Arr::get($_REQUEST, 'payment_id', '')));
594
+
595
+ $transaction = OrderTransaction::query()
596
+ ->where('uuid', $transactionUuid)
597
+ ->where('payment_method', 'your_gateway')
598
+ ->first();
599
+
600
+ if (!$transaction) {
601
+ wp_send_json([
602
+ 'message' => __('Transaction not found.', 'your-plugin'),
603
+ 'status' => 'failed'
604
+ ], 404);
605
+ }
606
+
607
+ // Prefer the payment ID saved in Step 5 over the one the browser sent.
608
+ $paymentId = $transaction->vendor_charge_id ?: $paymentId;
609
+
610
+ $confirmed = $this->confirmTransaction($transaction, $paymentId);
611
+
612
+ if (is_wp_error($confirmed)) {
613
+ wp_send_json([
614
+ 'message' => $confirmed->get_error_message(),
615
+ 'status' => 'failed'
616
+ ], 422);
617
+ }
618
+
619
+ wp_send_json([
620
+ 'redirect_url' => $transaction->getReceiptPageUrl(),
621
+ 'order' => [
622
+ 'uuid' => $transaction->order->uuid,
623
+ ],
624
+ 'message' => __('Payment confirmed successfully.', 'your-plugin'),
625
+ 'status' => 'success'
626
+ ], 200);
627
+ }
628
+
629
+ /**
630
+ * @return true|\WP_Error
631
+ */
632
+ public function confirmTransaction(OrderTransaction $transaction, $paymentId)
633
+ {
634
+ // Already confirmed by the other path (webhook or ajax).
635
+ if ($transaction->status === Status::TRANSACTION_SUCCEEDED) {
636
+ return true;
637
+ }
638
+
639
+ // The ID can come from a request body. Check its format before it reaches a URL.
640
+ // Widen the pattern if your gateway's IDs use other characters.
641
+ if (!preg_match('/^[a-zA-Z0-9_-]+$/', (string) $paymentId)) {
642
+ return new \WP_Error('invalid_payment_id', __('Invalid payment reference.', 'your-plugin'));
643
+ }
644
+
645
+ // Ask the gateway, in the mode the payment was created in.
646
+ $api = new API($this->settings, $transaction->payment_mode);
647
+ $result = $api->getPayment($paymentId);
648
+
649
+ if (!Arr::get($result, 'success')) {
650
+ return new \WP_Error('payment_lookup_failed', __('Could not verify the payment.', 'your-plugin'));
651
+ }
652
+
653
+ $payment = Arr::get($result, 'data', []);
654
+
655
+ // Only your gateway's final "money captured" status counts as paid.
656
+ if (Arr::get($payment, 'status') !== 'paid') {
657
+ return new \WP_Error('payment_not_paid', __('The payment is not completed yet.', 'your-plugin'));
658
+ }
659
+
660
+ // It must be the payment created for this transaction, for this amount and currency.
661
+ $sameTransaction = Arr::get($payment, 'metadata.transaction_uuid') === $transaction->uuid;
662
+ $sameAmount = (int) Arr::get($payment, 'amount') === (int) $transaction->total;
663
+ $sameCurrency = strtoupper((string) Arr::get($payment, 'currency')) === strtoupper((string) $transaction->currency);
664
+
665
+ if (!$sameTransaction || !$sameAmount || !$sameCurrency) {
666
+ return new \WP_Error('payment_mismatch', __('The payment does not match this order.', 'your-plugin'));
667
+ }
668
+
669
+ $transaction->fill([
670
+ 'status' => Status::TRANSACTION_SUCCEEDED,
671
+ 'vendor_charge_id' => $paymentId,
672
+ ]);
673
+ $transaction->save();
674
+
675
+ $order = Order::query()->find($transaction->order_id);
676
+ (new StatusHelper($order))->syncOrderStatuses($transaction);
677
+
678
+ return true;
679
+ }
680
+ ```
681
+
682
+ - Mark a payment paid only after the gateway reports its final captured status. A status such as "authorized", "pending" or "processing" is not paid.
683
+ - Compare the amount in the unit your gateway uses. FluentCart amounts are in cents.
684
+
685
+ #### Webhook / IPN
686
+
687
+ Set this URL in your gateway's dashboard. In code it is `$this->getListenerUrl()['listener_url']`:
688
+
689
+ ```
690
+ https://your-site.com/?fluent-cart=fct_payment_listener_ipn&method=your_gateway
691
+ ```
692
+
693
+ ```
694
+ <?php
695
+
696
+ #YourGateway.php
697
+
698
+ public function handleIPN(): void
699
+ {
700
+ $rawBody = file_get_contents('php://input');
701
+ $event = json_decode($rawBody, true);
702
+
703
+ if (!is_array($event)) {
704
+ $this->sendWebhookResponse(400, 'Invalid payload');
705
+ }
706
+
707
+ // 1. Verify the event before acting on it.
708
+ $secret = $this->settings->getWebhookSecret();
709
+
710
+ if (!$secret) {
711
+ // No secret saved for this mode: reject. Never accept an unverified event.
712
+ $this->sendWebhookResponse(500, 'Webhook secret not configured');
713
+ }
714
+
715
+ // Read headers from $_SERVER. getallheaders() is missing on some hosts.
716
+ $signature = sanitize_text_field(wp_unslash(Arr::get($_SERVER, 'HTTP_X_YOURGATEWAY_SIGNATURE', '')));
717
+
718
+ if (!$signature || !hash_equals(hash_hmac('sha256', $rawBody, $secret), $signature)) {
719
+ $this->sendWebhookResponse(401, 'Invalid signature');
720
+ }
721
+
722
+ // 2. Is it ours? Find the transaction by the uuid stamped in Step 5.
723
+ $transactionUuid = sanitize_text_field(Arr::get($event, 'data.metadata.transaction_uuid', ''));
724
+
725
+ $transaction = OrderTransaction::query()
726
+ ->where('uuid', $transactionUuid)
727
+ ->where('payment_method', 'your_gateway')
728
+ ->first();
729
+
730
+ if (!$transaction) {
731
+ // Another site on the same gateway account, or not a FluentCart payment.
732
+ $this->sendWebhookResponse(200, 'Not for this store');
733
+ }
734
+
735
+ // 3. Act on the gateway's live state, through the same method as Step 6.
736
+ if (Arr::get($event, 'type') === 'payment.completed') {
737
+ $confirmed = $this->confirmTransaction($transaction, Arr::get($event, 'data.id', ''));
738
+
739
+ if (is_wp_error($confirmed) && $confirmed->get_error_code() === 'payment_lookup_failed') {
740
+ // The gateway could not be reached. A non-2xx makes it deliver the event again.
741
+ $this->sendWebhookResponse(503, 'Try again');
742
+ }
743
+ }
744
+
745
+ $this->sendWebhookResponse(200, 'OK');
746
+ }
747
+
748
+ private function sendWebhookResponse($code, $message)
749
+ {
750
+ wp_send_json(['message' => $message], $code);
751
+ }
752
+ ```
753
+
754
+ - **Verify first.** Check the signature the way your gateway documents it. If your gateway sends no signature, fetch the object from its API by ID and act only on what the API returns.
755
+ - **Act on live state, not on the event body.** `confirmTransaction()` fetches the payment again, so an event that claims "completed" for an unpaid payment changes nothing.
756
+ - **A repeated delivery answers 200.** Gateways send the same event more than once. `confirmTransaction()` returns early when the transaction is already succeeded. Answer 200 for work that is already done, or the gateway keeps retrying.
757
+ - **Work that is not safe to repeat needs a claim.** If a handler has no such built-in check, claim the event ID first with `add_option($key, '1', '', false)`, answer 200 when the claim is already taken, and delete the claim if the work throws. Do not expire the claim.
758
+ - **Look up by an ID of yours.** Match on the uuid you stamped, or on a vendor ID you saved, scoped to your gateway's `payment_method`. One gateway account often serves several sites.
759
+
760
+ ### Step 7: (optional) Create your-gateway-checkout.js
761
+
762
+ Create custom JavaScript file to handle (onsite) payment checkout, step #3 above is enough for (hosted) payment checkout.
763
+
764
+ #### Example of onsite payment checkout with custom checkout button
765
+
766
+ ```
767
+ // File: assets/js/your-gateway-checkout.js
768
+ class YourGatewayCheckout {
769
+ constructor(form, orderHandler, response, paymentLoader) {
770
+ this.form = form;
771
+ this.orderHandler = orderHandler;
772
+ this.response = response;
773
+ this.paymentLoader = paymentLoader;
774
+ this.paymentArgs = response?.payment_args || {};
775
+ }
776
+
777
+ init() {
778
+ // Find the payment container
779
+ const paymentContainer = document.querySelector('.fluent-cart-checkout_embed_payment_container_your_gateway');
780
+ if (!paymentContainer) {
781
+ console.error('Payment container not found');
782
+ return;
783
+ }
784
+
785
+ // Create payment button
786
+ this.createPaymentButton(paymentContainer);
787
+
788
+ // Initialize gateway SDK (if applicable)
789
+ this.initGatewaySDK();
790
+ }
791
+
792
+ createPaymentButton(container) {
793
+ // Clear container
794
+ container.innerHTML = '';
795
+
796
+ // Create button
797
+ const button = document.createElement('button');
798
+ button.type = 'button';
799
+ button.className = 'your-gateway-checkout-button';
800
+ button.textContent = 'Pay with Your Gateway';
801
+ button.style.cssText = `
802
+ width: 100%;
803
+ padding: 12px;
804
+ background: #007bff;
805
+ color: #fff;
806
+ border: none;
807
+ border-radius: 4px;
808
+ font-size: 16px;
809
+ cursor: pointer;
810
+ `;
811
+
812
+ // Add click event
813
+ button.addEventListener('click', () => {
814
+ this.handlePaymentButtonClick();
815
+ });
816
+
817
+ // Add to container
818
+ container.appendChild(button);
819
+ }
820
+
821
+ initGatewaySDK() {
822
+ // Initialize your gateway's SDK if required
823
+ if (window.YourGatewaySDK) {
824
+ window.YourGatewaySDK.initialize({
825
+ publicKey: this.paymentArgs.public_key,
826
+ environment: this.paymentArgs.mode
827
+ });
828
+ }
829
+ }
830
+
831
+ async handlePaymentButtonClick() {
832
+ try {
833
+ this.paymentLoader?.changeLoaderStatus('processing');
834
+
835
+ // Create order in FluentCart first
836
+ const orderResponse = await this.orderHandler.createOrder();
837
+
838
+ if (!orderResponse?.success) {
839
+ throw new Error('Failed to create order');
840
+ }
841
+
842
+ // For redirect-based gateways
843
+ if (orderResponse.redirect_url) {
844
+ window.location.href = orderResponse.redirect_url;
845
+ return;
846
+ }
847
+
848
+ // For JS-based gateways, open checkout modal
849
+ if (window.YourGatewaySDK) {
850
+ const result = await window.YourGatewaySDK.openCheckout({
851
+ amount: this.response.amount,
852
+ currency: this.response.currency,
853
+ orderId: orderResponse.order_id,
854
+ onSuccess: (data) => {
855
+ // Confirm payment on your server
856
+ this.confirmPayment(data, orderResponse);
857
+ },
858
+ onCancel: () => {
859
+ this.paymentLoader?.hideLoader();
860
+ }
861
+ });
862
+ }
863
+ } catch (error) {
864
+ this.paymentLoader?.changeLoaderStatus('Error: ' + error.message);
865
+ this.paymentLoader?.hideLoader();
866
+ }
867
+ }
868
+
869
+ async confirmPayment(gatewayData, orderData) {
870
+ try {
871
+ // Confirm payment on your server
872
+ const confirmResponse = await fetch(fluentCartData.ajax_url, {
873
+ method: 'POST',
874
+ headers: {"Content-Type": "application/json"},
875
+ credentials: 'same-origin',
876
+ body: JSON.stringify({
877
+ action: 'fluent_cart_confirm_your_gateway_payment',
878
+ transaction_id: orderData.transaction_id,
879
+ payment_id: gatewayData.paymentId
880
+ })
881
+ });
882
+
883
+ const confirmation = await confirmResponse.json();
884
+
885
+ if (confirmation.success && confirmation.redirect_url) {
886
+ window.location.href = confirmation.redirect_url;
887
+ } else {
888
+ throw new Error(confirmation.message || 'Payment confirmation failed');
889
+ }
890
+ } catch (error) {
891
+ this.paymentLoader?.changeLoaderStatus('Error: ' + error.message);
892
+ this.paymentLoader?.hideLoader();
893
+ }
894
+ }
895
+ }
896
+
897
+ // Initialize when FluentCart triggers the event
898
+ window.addEventListener("fluent_cart_load_payments_your_gateway", function (e) {
899
+ fetch(e.detail.paymentInfoUrl, {
900
+ method: "POST",
901
+ headers: {
902
+ "Content-Type": "application/json"
903
+ },
904
+ credentials: 'include'
905
+ })
906
+ .then(response => response.json())
907
+ .then(data => {
908
+ new YourGatewayCheckout(
909
+ e.detail.form,
910
+ e.detail.orderHandler,
911
+ data,
912
+ e.detail.paymentLoader
913
+ ).init();
914
+ })
915
+ .catch(error => {
916
+ console.error('Error initializing gateway:', error);
917
+ });
918
+ });
919
+ ```
920
+
921
+ ## Key FluentCart Services to Use
922
+
923
+ FluentCart provides these services to make gateway development easier:
924
+
925
+ ### StatusHelper for Order Updates
926
+
927
+ ```
928
+ // Update order status and fire all necessary hooks
929
+ (new \FluentCart\App\Helpers\StatusHelper($order))->syncOrderStatuses($transaction);
930
+
931
+ // Hooks this call fires:
932
+ // - fluent_cart/order_paid, then fluent_cart/order_paid_done
933
+ // - fluent_cart/renewal_paid (renewal orders)
934
+ // - fluent_cart/cart_completed
935
+ // - fluent_cart/subscription_activated (when a subscription starts)
936
+ $data = [
937
+ 'order' => $this->order,
938
+ 'customer' => $this->customer ?? null,
939
+ 'transaction' => $this->transaction ?? null
940
+ ];
941
+ ```
942
+
943
+ ### Refunds
944
+
945
+ A gateway talks to the provider. FluentCart records the refund. Keep the two apart.
946
+
947
+ Declare `'refund'` in `$supportedFeatures`. Without it, FluentCart records the refund without calling your gateway and tells the admin to return the money through the provider.
948
+
949
+ #### Admin refund: `processRefund()`
950
+
951
+ Call the provider and return the vendor refund ID, or a `WP_Error` when the provider reports `failed` or `canceled`.
952
+
953
+ ```
954
+ public function processRefund($transaction, $amount, $args)
955
+ {
956
+ $refund = $this->api->refund($transaction->vendor_charge_id, $amount, [
957
+ 'idempotency_key' => 'refund_' . wp_generate_uuid4(),
958
+ ]);
959
+
960
+ if (is_wp_error($refund) || in_array($refund['status'], ['failed', 'canceled'], true)) {
961
+ return new \WP_Error('refund_failed', 'Provider message');
962
+ }
963
+
964
+ return $refund['id']; // 'pending' is success; return '' if the provider gives no ID yet
965
+ }
966
+ ```
967
+
968
+ - Do not write, update or delete a refund row. FluentCart writes it after you return.
969
+ - Do not dispatch `OrderRefund`.
970
+ - A thrown exception or `WP_Error` shows the admin the "record locally" prompt, where the admin can choose to record the refund without the gateway.
971
+ - `$amount` is in cents. Convert it if your provider expects decimals.
972
+ - Generate the idempotency key once per `processRefund()` call and reuse it only to retry that request. A key built only from payment ID and amount makes a second refund of the same amount replay the first.
973
+
974
+ #### Webhook refund: `Refund::createOrRecordRefund()`
975
+
976
+ Resolve the parent charge, then record through the core helper. Do not match rows yourself.
977
+
978
+ ```
979
+ \FluentCart\App\Services\Payments\Refund::createOrRecordRefund([
980
+ 'vendor_charge_id' => $refundId, // the provider's refund ID
981
+ 'payment_method' => 'your_gateway',
982
+ 'status' => 'refunded', // refunded | pending | failed
983
+ 'total' => $refundAmount, // cents
984
+ ], $parentTransaction);
985
+ ```
986
+
987
+ Check the return value. If another refund holds the order's lock for 10 seconds, the helper records nothing and returns `WP_Error('refund_lock_timeout')`. Answer a non-2xx (503, or 500) for that code only, so the provider redelivers. Redelivery is safe: the refund matches by vendor refund ID. If you dedupe events before the handler runs, clear that mark first, or the redelivery is skipped.
988
+
989
+ ```
990
+ $recorded = \FluentCart\App\Services\Payments\Refund::createOrRecordRefund($data, $parentTransaction);
991
+
992
+ if (is_wp_error($recorded) && $recorded->get_error_code() === 'refund_lock_timeout') {
993
+ status_header(503);
994
+ exit;
995
+ }
996
+ ```
997
+
998
+ It matches an existing row by vendor refund ID, then a refund recorded without an ID for the same charge and amount, and otherwise creates one. When a refund first becomes `refunded`, it updates the charge's refunded total and fires `OrderRefund` once, so the refund email and order payment status update run once. A `pending` row adds nothing until it becomes `refunded`. A `failed` report never adopts a locally recorded row.
999
+
1000
+ #### Recording locally
1001
+
1002
+ When the provider cannot be reached or rejects the refund, an admin can record the refund in FluentCart only. It does not cancel the subscription and returns no money. If the provider later reports a refund of the same amount on the same charge, the helper above attaches its refund ID to that row instead of adding a second one. A different amount is recorded as a separate refund.
1003
+
1004
+ ### Subscription Handling
1005
+
1006
+ For subscription renewals, use `SubscriptionService`. There is no `SubscriptionRenewal` class. Note the argument order: the transaction data comes **first**, the subscription second.
1007
+
1008
+ ```
1009
+ $recorded = \FluentCart\App\Modules\Subscriptions\Services\SubscriptionService::recordRenewalPayment(
1010
+ [
1011
+ 'total' => $amount, // cents
1012
+ 'vendor_charge_id' => $paymentId, // also used to skip a charge already recorded
1013
+ 'payment_method' => 'your_gateway',
1014
+ ],
1015
+ $subscription, // optional
1016
+ [] // optional subscription update args
1017
+ );
1018
+
1019
+ if (is_wp_error($recorded) && $recorded->get_error_code() !== 'transaction_exists') {
1020
+ // Not recorded. Answer non-2xx so the gateway delivers the event again.
1021
+ status_header(500);
1022
+ exit;
1023
+ }
1024
+ ```
1025
+
1026
+ - `status` defaults to `Status::TRANSACTION_SUCCEEDED`. `total` defaults to the subscription's recurring total.
1027
+ - The call returns the `OrderTransaction`, or a `WP_Error`. `transaction_exists` means the charge is already recorded: treat it as done.
1028
+ - Do not add your own duplicate check around this call. It matches by `vendor_charge_id`.
1029
+
1030
+ A store can also bill subscriptions itself instead of through the gateway (Store Billing). Which mode a store uses is the merchant's setting; your gateway only declares what it supports. See [Subscriptions](/modules/subscriptions.md) for `manual_subscription`, `system_subscription`, `shouldChargeSubscriptionAsOneTime()` and `chargeRenewal()`.
1031
+
1032
+ ## Important Hooks
1033
+
1034
+ Key hooks to be aware of:
1035
+
1036
+ 1. **Payment Hooks** (Handled by StatusHelper):`fluent_cart/order_paid`
1037
+ 2. `fluent_cart/order_paid_done`
1038
+ 3. `fluent_cart/renewal_paid`
1039
+ 4. `fluent_cart/cart_completed`
1040
+ 5. **Subscription Hooks** (dispatched as events):`fluent_cart/subscription_activated`
1041
+ 6. `fluent_cart/subscription_renewed`
1042
+ 7. `fluent_cart/subscription_canceled` — one `l`, matching `Status::SUBSCRIPTION_CANCELED`
1043
+ 8. `fluent_cart/subscription_renewal_failed`
1044
+ 9. `fluent_cart/subscription_paused`, `_resumed`, `_reactivated`
1045
+
1046
+ Learn more about hooks in [FluentCart Hooks](./../hooks/) documentation.
1047
+
1048
+ ## Testing Your Gateway
1049
+
1050
+ 1. **Install & Activate**: Activate your plugin in WordPress
1051
+ 2. **Configure**: Go to FluentCart → Settings → Payment Methods
1052
+ 3. **Test Payment**: Test a one-time payment on the checkout page
1053
+ 4. **Test Subscription**: Test a subscription product if supported
1054
+ 5. **Test Webhooks**: Send test events from your gateway's dashboard or CLI and check that: an event with a wrong or missing signature is rejected and the order does not change
1055
+ 6. the same event sent twice answers 200 both times and the order changes once
1056
+ 7. an event for a payment this site did not create answers 200 and changes nothing
1057
+ 8. **Test Confirmation**: A payment that is not captured yet, or whose amount or currency differs from the order, is not marked paid
1058
+ 9. **Test Refunds**: A full refund, then two partial refunds of the same amount on one order
1059
+
1060
+ ## Common Pitfalls
1061
+
1062
+ A few things that aren't obvious from the interface/base class alone and can cost time to reverse-engineer:
1063
+
1064
+ - **Amounts are already in minor units.** FluentCart stores/passes order and transaction amounts in minor units (cents/øre — e.g. `$5.00` is `500`). Do not multiply by 100 again when sending amounts to your gateway's API — that doubles (well, 100×s) every charge. Only convert if your gateway's API expects major units.
1065
+ - **`renderStoreModeNotice()` must be `public`.** It's called by the parent class to render the test/live mode notice in admin, so declaring it `protected`/`private` breaks the call even though it feels like an internal helper.
1066
+ - **`getOrderInfo(array $data)` is required.** It's declared on `PaymentGatewayInterface`, not flagged with an `abstract` keyword on `AbstractPaymentGateway` itself — easy to miss and skip, but omitting it is a fatal error.
1067
+ - **Read the store currency via `CurrencySettings::get('currency')`** (`FluentCart\Api\CurrencySettings`), not by re-deriving it from settings/options yourself.
1068
+ - **Don't eagerly `require` your gateway class file** — see the warning in [Step 1](#step-1-register-your-gateway). Load it lazily from inside the `fluent_cart/register_payment_methods` callback, not at plugin bootstrap or on `fluentcart_loaded`.
1069
+ - **Never store raw card details.** Tokenize the card with your gateway and save only the token it returns.
1070
+ - **Show customers only the invoice number.** In emails and other customer-facing text use `invoice_no`. The order `uuid` opens the receipt page without a login, and the `id` is a running number. When `invoice_no` is empty, show no number.
1071
+ - **Keep `isCurrencySupported()` and `isEnabled()` fast.** FluentCart calls them when it builds the checkout payment list. Read saved settings only. Call your gateway's API when the merchant saves the settings, not here.
1072
+ - **Read webhook headers from `$_SERVER`.** `getallheaders()` is not available on every host. `X-Yourgateway-Signature` is `$_SERVER['HTTP_X_YOURGATEWAY_SIGNATURE']`.
1073
+
1074
+ ## Additional Resources
1075
+
1076
+ For more detailed examples, you can refer to:
1077
+
1078
+ - Built-in payment methods in FluentCart (Stripe, PayPal)
1079
+ - [Paddle Gateway Implementation](./paddle-example.md) for a complete, real-world example