azirid-react 0.9.8 → 0.9.9

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.
package/README.md CHANGED
@@ -713,7 +713,9 @@ function CheckoutPage({ intentId }: { intentId: string }) {
713
713
 
714
714
  The hook handles both phases automatically:
715
715
  1. **Widget phase**: Calls checkout API, loads Payphone SDK, widget renders via `<PayphoneWidget />`.
716
- 2. **Confirmation phase**: After Payphone redirects back (same page), detects URL params and confirms the payment.
716
+ 2. **Confirmation phase**: After Payphone redirects back to your configured **Response URL** (set in Payphone Developer dashboard), detects `?id=X&clientTransactionId=Y` params and confirms the payment.
717
+
718
+ > **Important:** The redirect URL after payment is configured in the **Payphone Developer dashboard** (not passed via code). Make sure your Response URL points to the page where `usePayphoneCheckout` or `<PayphoneCallback>` is rendered.
717
719
 
718
720
  ### `usePayButton`
719
721
 
@@ -924,7 +926,7 @@ import { InvoiceList } from 'azirid-react'
924
926
 
925
927
  #### `PayphoneCallback`
926
928
 
927
- Page component for handling Payphone payment callbacks. Reads `id` and `clientTransactionId` from URL query params automatically.
929
+ Page component for handling Payphone payment callbacks. Reads `id` and `clientTransactionId` from URL query params automatically. Deploy this page at the **Response URL** configured in your Payphone Developer dashboard.
928
930
 
929
931
  ```tsx
930
932
  // app/payphone/callback/page.tsx
package/dist/index.cjs CHANGED
@@ -2297,7 +2297,6 @@ function loadPayphoneSdk() {
2297
2297
  }
2298
2298
  function PayphoneWidgetRenderer({
2299
2299
  config,
2300
- responseUrl,
2301
2300
  containerId,
2302
2301
  onReady,
2303
2302
  onError
@@ -2319,18 +2318,17 @@ function PayphoneWidgetRenderer({
2319
2318
  amountWithoutTax: config.amountWithoutTax,
2320
2319
  currency: config.currency,
2321
2320
  storeId: config.storeId,
2322
- reference: config.reference,
2323
- responseUrl
2321
+ reference: config.reference
2324
2322
  }).render(containerId);
2325
2323
  onReady?.();
2326
2324
  });
2327
2325
  }).catch((err) => {
2328
2326
  onError?.(new Error(err instanceof Error ? err.message : "Failed to load Payphone SDK"));
2329
2327
  });
2330
- }, [config, responseUrl, containerId, onReady, onError]);
2328
+ }, [config, containerId, onReady, onError]);
2331
2329
  return /* @__PURE__ */ jsxRuntime.jsx("div", { id: containerId });
2332
2330
  }
2333
- function PayphoneModal({ config, successUrl, onClose }) {
2331
+ function PayphoneModal({ config, onClose }) {
2334
2332
  const [error, setError] = react.useState(null);
2335
2333
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle, onClick: (e) => e.stopPropagation(), children: [
2336
2334
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: titleStyle, children: "Payphone" }),
@@ -2339,7 +2337,6 @@ function PayphoneModal({ config, successUrl, onClose }) {
2339
2337
  PayphoneWidgetRenderer,
2340
2338
  {
2341
2339
  config,
2342
- responseUrl: successUrl,
2343
2340
  containerId: "pp-button-azirid",
2344
2341
  onError: (err) => setError(err.message)
2345
2342
  }
@@ -2864,7 +2861,6 @@ function PricingTable({
2864
2861
  PayphoneModal,
2865
2862
  {
2866
2863
  config: payphoneData.widgetConfig,
2867
- successUrl,
2868
2864
  onClose: () => setPayphoneData(null)
2869
2865
  }
2870
2866
  )
@@ -2944,7 +2940,6 @@ function usePayButton({
2944
2940
  const [payphoneConfig, setPayphoneConfig] = react.useState(null);
2945
2941
  const [currentError, setCurrentError] = react.useState(null);
2946
2942
  const payphoneConfirmTriggered = react.useRef(false);
2947
- const responseUrl = typeof window !== "undefined" ? window.location.href.split("?")[0] : "";
2948
2943
  const params = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : new URLSearchParams();
2949
2944
  const callbackId = params.get("id");
2950
2945
  const callbackClientTxId = params.get("clientTransactionId");
@@ -2995,15 +2990,16 @@ function usePayButton({
2995
2990
  setSelectedProvider(provider);
2996
2991
  setStatus("processing");
2997
2992
  setCurrentError(null);
2993
+ const currentUrl = typeof window !== "undefined" ? window.location.href.split("?")[0] : "";
2998
2994
  doCheckout({
2999
2995
  intentId,
3000
2996
  planId,
3001
2997
  provider,
3002
- successUrl: responseUrl,
3003
- cancelUrl: responseUrl
2998
+ successUrl: currentUrl,
2999
+ cancelUrl: currentUrl
3004
3000
  });
3005
3001
  },
3006
- [doCheckout, intentId, planId, responseUrl]
3002
+ [doCheckout, intentId, planId]
3007
3003
  );
3008
3004
  const { mutate: confirmPayphone } = usePayphoneConfirm({
3009
3005
  onSuccess: (data) => {
@@ -3150,12 +3146,11 @@ function usePayButton({
3150
3146
  if (!payphoneConfig || isPayphoneCallback) return null;
3151
3147
  return PayphoneWidgetRenderer({
3152
3148
  config: payphoneConfig,
3153
- responseUrl,
3154
3149
  containerId: PP_CONTAINER_ID,
3155
3150
  onError: handleSdkError
3156
3151
  });
3157
3152
  };
3158
- }, [payphoneConfig, responseUrl, isPayphoneCallback, handleSdkError]);
3153
+ }, [payphoneConfig, isPayphoneCallback, handleSdkError]);
3159
3154
  return {
3160
3155
  providers,
3161
3156
  checkout,
@@ -3454,7 +3449,6 @@ function PayButton({
3454
3449
  PayphoneModal,
3455
3450
  {
3456
3451
  config: checkoutData.widgetConfig,
3457
- successUrl,
3458
3452
  onClose: () => {
3459
3453
  onSuccess?.(checkoutData);
3460
3454
  }
@@ -3978,7 +3972,6 @@ function usePayphoneCheckout({
3978
3972
  const [currentError, setCurrentError] = react.useState(null);
3979
3973
  const checkoutTriggered = react.useRef(false);
3980
3974
  const confirmTriggered = react.useRef(false);
3981
- const responseUrl = typeof window !== "undefined" ? window.location.href.split("?")[0] : "";
3982
3975
  const params = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : new URLSearchParams();
3983
3976
  const callbackId = params.get("id");
3984
3977
  const callbackClientTxId = params.get("clientTransactionId");
@@ -4004,10 +3997,10 @@ function usePayphoneCheckout({
4004
3997
  checkout({
4005
3998
  intentId,
4006
3999
  provider: "PAYPHONE",
4007
- successUrl: responseUrl,
4008
- cancelUrl: responseUrl
4000
+ successUrl: window.location.href,
4001
+ cancelUrl: window.location.href
4009
4002
  });
4010
- }, [checkout, intentId, responseUrl, isCallback]);
4003
+ }, [checkout, intentId, isCallback]);
4011
4004
  const { mutate: confirm } = usePayphoneConfirm({
4012
4005
  onSuccess: (data) => {
4013
4006
  setStatus(data.status === "confirmed" || data.status === "already_confirmed" ? "confirmed" : "cancelled");
@@ -4038,12 +4031,11 @@ function usePayphoneCheckout({
4038
4031
  if (!widgetConfig || isCallback) return null;
4039
4032
  return PayphoneWidgetRenderer({
4040
4033
  config: widgetConfig,
4041
- responseUrl,
4042
4034
  containerId: CONTAINER_ID,
4043
4035
  onError: handleSdkError
4044
4036
  });
4045
4037
  };
4046
- }, [widgetConfig, responseUrl, isCallback, handleSdkError]);
4038
+ }, [widgetConfig, isCallback, handleSdkError]);
4047
4039
  return { PayphoneWidget, status, intentId, error: currentError };
4048
4040
  }
4049
4041
  function useTransferPayment({
@@ -4283,7 +4275,7 @@ function usePasswordToggle() {
4283
4275
  }
4284
4276
 
4285
4277
  // src/index.ts
4286
- var SDK_VERSION = "0.9.8";
4278
+ var SDK_VERSION = "0.9.9";
4287
4279
 
4288
4280
  exports.AuthForm = AuthForm;
4289
4281
  exports.AziridProvider = AziridProvider;