@zendfi/sdk 0.7.0 → 0.7.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.
package/dist/index.d.mts CHANGED
@@ -1856,6 +1856,10 @@ declare class ZendFiEmbeddedCheckout {
1856
1856
  * Poll for payment confirmation
1857
1857
  */
1858
1858
  private startPaymentPolling;
1859
+ /**
1860
+ * Fetch full payment details and handle success
1861
+ */
1862
+ private fetchAndHandlePaymentSuccess;
1859
1863
  /**
1860
1864
  * Handle successful payment
1861
1865
  */
package/dist/index.d.ts CHANGED
@@ -1856,6 +1856,10 @@ declare class ZendFiEmbeddedCheckout {
1856
1856
  * Poll for payment confirmation
1857
1857
  */
1858
1858
  private startPaymentPolling;
1859
+ /**
1860
+ * Fetch full payment details and handle success
1861
+ */
1862
+ private fetchAndHandlePaymentSuccess;
1859
1863
  /**
1860
1864
  * Handle successful payment
1861
1865
  */
package/dist/index.js CHANGED
@@ -3615,7 +3615,7 @@ var ZendFiEmbeddedCheckout = class {
3615
3615
  if (response.ok) {
3616
3616
  const data = await response.json();
3617
3617
  if (data.status === "confirmed") {
3618
- this.handlePaymentSuccess(data);
3618
+ await this.fetchAndHandlePaymentSuccess();
3619
3619
  } else if (data.status === "failed") {
3620
3620
  this.handlePaymentFailure(data);
3621
3621
  } else if (data.status === "expired") {
@@ -3627,6 +3627,29 @@ var ZendFiEmbeddedCheckout = class {
3627
3627
  }
3628
3628
  }, 3e3);
3629
3629
  }
3630
+ /**
3631
+ * Fetch full payment details and handle success
3632
+ */
3633
+ async fetchAndHandlePaymentSuccess() {
3634
+ if (!this.checkoutData) return;
3635
+ try {
3636
+ const response = await fetch(
3637
+ `${this.config.apiUrl}/api/v1/payments/${this.checkoutData.payment_id}`,
3638
+ {
3639
+ method: "GET",
3640
+ headers: {
3641
+ "Content-Type": "application/json"
3642
+ }
3643
+ }
3644
+ );
3645
+ if (response.ok) {
3646
+ const payment = await response.json();
3647
+ this.handlePaymentSuccess(payment);
3648
+ }
3649
+ } catch (error) {
3650
+ console.error("Failed to fetch payment details:", error);
3651
+ }
3652
+ }
3630
3653
  /**
3631
3654
  * Handle successful payment
3632
3655
  */
@@ -3638,8 +3661,8 @@ var ZendFiEmbeddedCheckout = class {
3638
3661
  this.config.onSuccess({
3639
3662
  paymentId: data.id,
3640
3663
  transactionSignature: data.transaction_signature,
3641
- amount: data.amount_usd || data.amount,
3642
- token: data.payment_token,
3664
+ amount: data.amount_usd,
3665
+ token: this.checkoutData?.token || "USDC",
3643
3666
  merchantName: this.checkoutData?.merchant_name || "Merchant"
3644
3667
  });
3645
3668
  this.renderSuccess();
package/dist/index.mjs CHANGED
@@ -2559,7 +2559,7 @@ var ZendFiEmbeddedCheckout = class {
2559
2559
  if (response.ok) {
2560
2560
  const data = await response.json();
2561
2561
  if (data.status === "confirmed") {
2562
- this.handlePaymentSuccess(data);
2562
+ await this.fetchAndHandlePaymentSuccess();
2563
2563
  } else if (data.status === "failed") {
2564
2564
  this.handlePaymentFailure(data);
2565
2565
  } else if (data.status === "expired") {
@@ -2571,6 +2571,29 @@ var ZendFiEmbeddedCheckout = class {
2571
2571
  }
2572
2572
  }, 3e3);
2573
2573
  }
2574
+ /**
2575
+ * Fetch full payment details and handle success
2576
+ */
2577
+ async fetchAndHandlePaymentSuccess() {
2578
+ if (!this.checkoutData) return;
2579
+ try {
2580
+ const response = await fetch(
2581
+ `${this.config.apiUrl}/api/v1/payments/${this.checkoutData.payment_id}`,
2582
+ {
2583
+ method: "GET",
2584
+ headers: {
2585
+ "Content-Type": "application/json"
2586
+ }
2587
+ }
2588
+ );
2589
+ if (response.ok) {
2590
+ const payment = await response.json();
2591
+ this.handlePaymentSuccess(payment);
2592
+ }
2593
+ } catch (error) {
2594
+ console.error("Failed to fetch payment details:", error);
2595
+ }
2596
+ }
2574
2597
  /**
2575
2598
  * Handle successful payment
2576
2599
  */
@@ -2582,8 +2605,8 @@ var ZendFiEmbeddedCheckout = class {
2582
2605
  this.config.onSuccess({
2583
2606
  paymentId: data.id,
2584
2607
  transactionSignature: data.transaction_signature,
2585
- amount: data.amount_usd || data.amount,
2586
- token: data.payment_token,
2608
+ amount: data.amount_usd,
2609
+ token: this.checkoutData?.token || "USDC",
2587
2610
  merchantName: this.checkoutData?.merchant_name || "Merchant"
2588
2611
  });
2589
2612
  this.renderSuccess();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendfi/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Zero-config TypeScript SDK for ZendFi crypto payments",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",