@waffo/pancake-ts 0.4.1 → 0.5.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/CHANGELOG.md +25 -0
- package/README.md +18 -10
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/docs/webhook-guide.md +60 -8
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -875,13 +875,59 @@ declare enum WebhookEventType {
|
|
|
875
875
|
*/
|
|
876
876
|
interface WebhookEventData {
|
|
877
877
|
orderId: string;
|
|
878
|
+
/** Order status (e.g., "completed", "active", "canceling") */
|
|
879
|
+
orderStatus?: string;
|
|
878
880
|
buyerEmail: string;
|
|
881
|
+
/** Merchant-provided buyer identity from checkout session */
|
|
882
|
+
merchantProvidedBuyerIdentity?: string;
|
|
879
883
|
currency: string;
|
|
884
|
+
/** Billing/shipping address (structured object) */
|
|
885
|
+
billingDetail?: Record<string, unknown>;
|
|
886
|
+
/** Order-level metadata from checkout session (flat key-value pairs) */
|
|
887
|
+
orderMetadata?: Record<string, string>;
|
|
880
888
|
/** Amount as display string (e.g., "9.99" for USD, "1000" for JPY) */
|
|
881
889
|
amount: string;
|
|
882
890
|
/** Tax amount as display string (e.g., "0.91" for USD) */
|
|
883
891
|
taxAmount: string;
|
|
892
|
+
/** Tax rate as decimal (e.g., 0.1 for 10%) */
|
|
893
|
+
taxRate?: number;
|
|
894
|
+
/** Tax name (e.g., "Consumption Tax") */
|
|
895
|
+
taxName?: string;
|
|
896
|
+
/** Subtotal as display string (before tax) */
|
|
897
|
+
subtotal?: string;
|
|
898
|
+
/** Total as display string (after tax) */
|
|
899
|
+
total?: string;
|
|
884
900
|
productName: string;
|
|
901
|
+
/** Product description */
|
|
902
|
+
productDescription?: string;
|
|
903
|
+
/** Product-level metadata set when creating/updating the product */
|
|
904
|
+
productMetadata?: Record<string, string>;
|
|
905
|
+
/** Payment ID */
|
|
906
|
+
paymentId?: string;
|
|
907
|
+
/** Payment status (e.g., "succeeded", "failed") */
|
|
908
|
+
paymentStatus?: string;
|
|
909
|
+
/** Payment method type (e.g., "card") */
|
|
910
|
+
paymentMethod?: string;
|
|
911
|
+
/** Last 4 digits of payment instrument */
|
|
912
|
+
paymentLast4?: string;
|
|
913
|
+
/** Payment failure reason (present when payment failed) */
|
|
914
|
+
paymentFailureReason?: string;
|
|
915
|
+
/** Payment date (ISO 8601 date, e.g., "2026-04-18") */
|
|
916
|
+
paymentDate?: string;
|
|
917
|
+
/** Billing period: "weekly", "monthly", "quarterly", "yearly" */
|
|
918
|
+
billingPeriod?: string;
|
|
919
|
+
/** Current billing period start date (ISO 8601, e.g., "2026-04-01") */
|
|
920
|
+
currentPeriodStart?: string;
|
|
921
|
+
/** Current billing period end date (ISO 8601, e.g., "2026-05-01") */
|
|
922
|
+
currentPeriodEnd?: string;
|
|
923
|
+
/** Subscription cancellation timestamp (ISO 8601, present when canceled) */
|
|
924
|
+
canceledAt?: string;
|
|
925
|
+
/** Refund status (e.g., "succeeded", "failed") */
|
|
926
|
+
refundStatus?: string;
|
|
927
|
+
/** Refund reason */
|
|
928
|
+
refundReason?: string;
|
|
929
|
+
/** Refund creation timestamp (ISO 8601) */
|
|
930
|
+
refundCreatedAt?: string;
|
|
885
931
|
}
|
|
886
932
|
/**
|
|
887
933
|
* Webhook event payload.
|
|
@@ -896,7 +942,7 @@ interface WebhookEventData {
|
|
|
896
942
|
* eventId: "PAY_5xK9mRtYvWnPqLsJ3hBfDe",
|
|
897
943
|
* storeId: "STO_2aUyqjCzEIiEcYMKj7TZtw",
|
|
898
944
|
* mode: "prod",
|
|
899
|
-
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: "29.00", taxAmount: "2.90", productName: "Pro Plan" }
|
|
945
|
+
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: "29.00", taxAmount: "2.90", productName: "Pro Plan", orderMetadata: { planId: "pro" } }
|
|
900
946
|
* }
|
|
901
947
|
*/
|
|
902
948
|
interface WebhookEvent<T = WebhookEventData> {
|
package/dist/index.d.ts
CHANGED
|
@@ -875,13 +875,59 @@ declare enum WebhookEventType {
|
|
|
875
875
|
*/
|
|
876
876
|
interface WebhookEventData {
|
|
877
877
|
orderId: string;
|
|
878
|
+
/** Order status (e.g., "completed", "active", "canceling") */
|
|
879
|
+
orderStatus?: string;
|
|
878
880
|
buyerEmail: string;
|
|
881
|
+
/** Merchant-provided buyer identity from checkout session */
|
|
882
|
+
merchantProvidedBuyerIdentity?: string;
|
|
879
883
|
currency: string;
|
|
884
|
+
/** Billing/shipping address (structured object) */
|
|
885
|
+
billingDetail?: Record<string, unknown>;
|
|
886
|
+
/** Order-level metadata from checkout session (flat key-value pairs) */
|
|
887
|
+
orderMetadata?: Record<string, string>;
|
|
880
888
|
/** Amount as display string (e.g., "9.99" for USD, "1000" for JPY) */
|
|
881
889
|
amount: string;
|
|
882
890
|
/** Tax amount as display string (e.g., "0.91" for USD) */
|
|
883
891
|
taxAmount: string;
|
|
892
|
+
/** Tax rate as decimal (e.g., 0.1 for 10%) */
|
|
893
|
+
taxRate?: number;
|
|
894
|
+
/** Tax name (e.g., "Consumption Tax") */
|
|
895
|
+
taxName?: string;
|
|
896
|
+
/** Subtotal as display string (before tax) */
|
|
897
|
+
subtotal?: string;
|
|
898
|
+
/** Total as display string (after tax) */
|
|
899
|
+
total?: string;
|
|
884
900
|
productName: string;
|
|
901
|
+
/** Product description */
|
|
902
|
+
productDescription?: string;
|
|
903
|
+
/** Product-level metadata set when creating/updating the product */
|
|
904
|
+
productMetadata?: Record<string, string>;
|
|
905
|
+
/** Payment ID */
|
|
906
|
+
paymentId?: string;
|
|
907
|
+
/** Payment status (e.g., "succeeded", "failed") */
|
|
908
|
+
paymentStatus?: string;
|
|
909
|
+
/** Payment method type (e.g., "card") */
|
|
910
|
+
paymentMethod?: string;
|
|
911
|
+
/** Last 4 digits of payment instrument */
|
|
912
|
+
paymentLast4?: string;
|
|
913
|
+
/** Payment failure reason (present when payment failed) */
|
|
914
|
+
paymentFailureReason?: string;
|
|
915
|
+
/** Payment date (ISO 8601 date, e.g., "2026-04-18") */
|
|
916
|
+
paymentDate?: string;
|
|
917
|
+
/** Billing period: "weekly", "monthly", "quarterly", "yearly" */
|
|
918
|
+
billingPeriod?: string;
|
|
919
|
+
/** Current billing period start date (ISO 8601, e.g., "2026-04-01") */
|
|
920
|
+
currentPeriodStart?: string;
|
|
921
|
+
/** Current billing period end date (ISO 8601, e.g., "2026-05-01") */
|
|
922
|
+
currentPeriodEnd?: string;
|
|
923
|
+
/** Subscription cancellation timestamp (ISO 8601, present when canceled) */
|
|
924
|
+
canceledAt?: string;
|
|
925
|
+
/** Refund status (e.g., "succeeded", "failed") */
|
|
926
|
+
refundStatus?: string;
|
|
927
|
+
/** Refund reason */
|
|
928
|
+
refundReason?: string;
|
|
929
|
+
/** Refund creation timestamp (ISO 8601) */
|
|
930
|
+
refundCreatedAt?: string;
|
|
885
931
|
}
|
|
886
932
|
/**
|
|
887
933
|
* Webhook event payload.
|
|
@@ -896,7 +942,7 @@ interface WebhookEventData {
|
|
|
896
942
|
* eventId: "PAY_5xK9mRtYvWnPqLsJ3hBfDe",
|
|
897
943
|
* storeId: "STO_2aUyqjCzEIiEcYMKj7TZtw",
|
|
898
944
|
* mode: "prod",
|
|
899
|
-
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: "29.00", taxAmount: "2.90", productName: "Pro Plan" }
|
|
945
|
+
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: "29.00", taxAmount: "2.90", productName: "Pro Plan", orderMetadata: { planId: "pro" } }
|
|
900
946
|
* }
|
|
901
947
|
*/
|
|
902
948
|
interface WebhookEvent<T = WebhookEventData> {
|
package/dist/index.js
CHANGED
|
@@ -203,7 +203,7 @@ var HttpClient = class {
|
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
// src/validation.ts
|
|
206
|
-
var SHORT_ID_REGEX = /^[A-Z]{2,
|
|
206
|
+
var SHORT_ID_REGEX = /^[A-Z]{2,5}_[0-9A-Za-z]{22}$/;
|
|
207
207
|
var CURRENCY_CODE_REGEX = /^[A-Z]{3}$/;
|
|
208
208
|
var COUNTRY_CODE_REGEX = /^[A-Z]{2}$/;
|
|
209
209
|
var AMOUNT_STRING_REGEX = /^\d+(\.\d+)?$/;
|
|
@@ -1145,6 +1145,7 @@ var WaffoPancake = class {
|
|
|
1145
1145
|
graphql;
|
|
1146
1146
|
webhooks;
|
|
1147
1147
|
constructor(config) {
|
|
1148
|
+
validateShortId("merchantId", config.merchantId, "MER");
|
|
1148
1149
|
this.config = config;
|
|
1149
1150
|
this.http = new HttpClient(config);
|
|
1150
1151
|
this.auth = new AuthResource(this.http);
|