create-brainerce-store 1.57.0 → 1.58.0

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/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var require_package = __commonJS({
31
31
  "package.json"(exports2, module2) {
32
32
  module2.exports = {
33
33
  name: "create-brainerce-store",
34
- version: "1.57.0",
34
+ version: "1.58.0",
35
35
  description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
36
36
  bin: {
37
37
  "create-brainerce-store": "dist/index.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-brainerce-store",
3
- "version": "1.57.0",
3
+ "version": "1.58.0",
4
4
  "description": "Scaffold a production-ready e-commerce storefront connected to Brainerce",
5
5
  "bin": {
6
6
  "create-brainerce-store": "dist/index.js"
@@ -77,6 +77,13 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
77
77
  const { storeInfo } = useStoreInfo();
78
78
 
79
79
  const [paymentIntent, setPaymentIntent] = useState<PaymentIntent | null>(null);
80
+
81
+ // The provider's payment URL. `clientSdk.renderArg` is the URL; `clientSecret`
82
+ // is only a fallback for providers that duplicate it there. Reading
83
+ // clientSecret alone breaks providers that return a real identifier (MAX,
84
+ // Takbull) — the iframe/link silently points at an id instead of a page.
85
+ const paymentIntentUrl =
86
+ paymentIntent?.clientSdk?.renderArg || paymentIntent?.clientSecret || '';
80
87
  const [preloadedSdk, setPreloadedSdk] = useState<PaymentClientSdk | null>(null);
81
88
  const [loading, setLoading] = useState(true);
82
89
  const [error, setError] = useState<string | null>(null);
@@ -368,12 +375,20 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
368
375
  // Sandbox mode — no SDK to load, UI handles it
369
376
  if (sdk.renderType === 'sandbox') return;
370
377
 
378
+ // The URL to send the customer to is `renderArg`; `clientSecret` is only
379
+ // a fallback for providers that duplicate the URL into it. Reading
380
+ // clientSecret first silently breaks any provider that puts a real
381
+ // identifier there (MAX, Takbull) — the host check rejects the id and the
382
+ // customer never reaches the payment page. Mirrors the sdk-widget branch
383
+ // above, which already prefers renderArg.
384
+ const paymentUrl = sdk.renderArg || intent.clientSecret;
385
+
371
386
  if (sdk.renderType === 'redirect') {
372
- if (!isAllowedPaymentUrl(intent.clientSecret)) {
387
+ if (!isAllowedPaymentUrl(paymentUrl)) {
373
388
  setError(t('paymentRedirectBlocked'));
374
389
  return;
375
390
  }
376
- safePaymentRedirect(intent.clientSecret);
391
+ safePaymentRedirect(paymentUrl);
377
392
  return;
378
393
  }
379
394
 
@@ -383,13 +398,13 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
383
398
  // (2) a Brainerce-hosted embed page on an allowlisted payment host
384
399
  // that wraps provider-specific logic (e.g. Cardcom OpenFields).
385
400
  if (sdk.renderType === 'iframe') {
386
- if (!isAllowedPaymentUrl(intent.clientSecret)) {
401
+ if (!isAllowedPaymentUrl(paymentUrl)) {
387
402
  setError(t('paymentRedirectBlocked'));
388
403
  return;
389
404
  }
390
405
  const iframeOrigin = (() => {
391
406
  try {
392
- return new URL(intent.clientSecret).origin;
407
+ return new URL(paymentUrl).origin;
393
408
  } catch {
394
409
  return '';
395
410
  }
@@ -622,7 +637,7 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
622
637
  return (
623
638
  <div className={cn('w-full', className)}>
624
639
  <iframe
625
- src={paymentIntent.clientSecret}
640
+ src={paymentIntentUrl}
626
641
  className="block w-full border-0"
627
642
  style={iframeStyle}
628
643
  title={t('payment')}
@@ -681,7 +696,7 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
681
696
  </div>
682
697
  {/* Iframe body */}
683
698
  <iframe
684
- src={paymentIntent.clientSecret}
699
+ src={paymentIntentUrl}
685
700
  className="w-full border-0"
686
701
  style={iframeStyle}
687
702
  title={t('payment')}
@@ -724,7 +739,7 @@ export function PaymentStep({ checkoutId, className }: PaymentStepProps) {
724
739
  <p className="text-muted-foreground mt-4 text-sm">{t('redirectingToPayment')}</p>
725
740
  <p className="text-muted-foreground mt-2 text-xs">
726
741
  {t('redirectingHint')}
727
- <a href={paymentIntent.clientSecret} className="text-primary hover:underline">
742
+ <a href={paymentIntentUrl} className="text-primary hover:underline">
728
743
  {t('clickHere')}
729
744
  </a>
730
745
  .