Skip to content

Commit 0adc799

Browse files
Merge pull request #20 from Flutterwave/fix-report-blocking-response
fix report blocking callback response
2 parents 7670a4f + fee78ba commit 0adc799

File tree

5 files changed

+68
-62
lines changed

5 files changed

+68
-62
lines changed

dist/index.es.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function useFlutterwave(flutterWaveConfig) {
157157
switch (_b.label) {
158158
case 0:
159159
if (!(response.status === "successful")) return [3 /*break*/, 2];
160+
callback(response);
160161
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
161162
method: "post",
162163
headers: {
@@ -172,24 +173,24 @@ function useFlutterwave(flutterWaveConfig) {
172173
})];
173174
case 1:
174175
_b.sent();
175-
callback(response);
176176
return [3 /*break*/, 4];
177-
case 2: return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
178-
method: "post",
179-
headers: {
180-
"Content-Type": "application/json",
181-
},
182-
body: JSON.stringify({
183-
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
184-
language: "Flutterwave-React-v3",
185-
version: "1.0.7",
186-
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
187-
message: "15s"
188-
})
189-
})];
177+
case 2:
178+
callback(response);
179+
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
180+
method: "post",
181+
headers: {
182+
"Content-Type": "application/json",
183+
},
184+
body: JSON.stringify({
185+
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
186+
language: "Flutterwave-React-v3",
187+
version: "1.0.7",
188+
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
189+
message: "15s"
190+
})
191+
})];
190192
case 3:
191193
_b.sent();
192-
callback(response);
193194
_b.label = 4;
194195
case 4: return [2 /*return*/];
195196
}

dist/index.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function useFlutterwave(flutterWaveConfig) {
161161
switch (_b.label) {
162162
case 0:
163163
if (!(response.status === "successful")) return [3 /*break*/, 2];
164+
callback(response);
164165
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
165166
method: "post",
166167
headers: {
@@ -176,24 +177,24 @@ function useFlutterwave(flutterWaveConfig) {
176177
})];
177178
case 1:
178179
_b.sent();
179-
callback(response);
180180
return [3 /*break*/, 4];
181-
case 2: return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
182-
method: "post",
183-
headers: {
184-
"Content-Type": "application/json",
185-
},
186-
body: JSON.stringify({
187-
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
188-
language: "Flutterwave-React-v3",
189-
version: "1.0.7",
190-
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
191-
message: "15s"
192-
})
193-
})];
181+
case 2:
182+
callback(response);
183+
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
184+
method: "post",
185+
headers: {
186+
"Content-Type": "application/json",
187+
},
188+
body: JSON.stringify({
189+
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
190+
language: "Flutterwave-React-v3",
191+
version: "1.0.7",
192+
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
193+
message: "15s"
194+
})
195+
})];
194196
case 3:
195197
_b.sent();
196-
callback(response);
197198
_b.label = 4;
198199
case 4: return [2 /*return*/];
199200
}

example/src/dist/index.es.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function useFlutterwave(flutterWaveConfig) {
157157
switch (_b.label) {
158158
case 0:
159159
if (!(response.status === "successful")) return [3 /*break*/, 2];
160+
callback(response);
160161
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
161162
method: "post",
162163
headers: {
@@ -172,24 +173,24 @@ function useFlutterwave(flutterWaveConfig) {
172173
})];
173174
case 1:
174175
_b.sent();
175-
callback(response);
176176
return [3 /*break*/, 4];
177-
case 2: return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
178-
method: "post",
179-
headers: {
180-
"Content-Type": "application/json",
181-
},
182-
body: JSON.stringify({
183-
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
184-
language: "Flutterwave-React-v3",
185-
version: "1.0.7",
186-
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
187-
message: "15s"
188-
})
189-
})];
177+
case 2:
178+
callback(response);
179+
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
180+
method: "post",
181+
headers: {
182+
"Content-Type": "application/json",
183+
},
184+
body: JSON.stringify({
185+
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
186+
language: "Flutterwave-React-v3",
187+
version: "1.0.7",
188+
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
189+
message: "15s"
190+
})
191+
})];
190192
case 3:
191193
_b.sent();
192-
callback(response);
193194
_b.label = 4;
194195
case 4: return [2 /*return*/];
195196
}

example/src/dist/index.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function useFlutterwave(flutterWaveConfig) {
161161
switch (_b.label) {
162162
case 0:
163163
if (!(response.status === "successful")) return [3 /*break*/, 2];
164+
callback(response);
164165
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
165166
method: "post",
166167
headers: {
@@ -176,24 +177,24 @@ function useFlutterwave(flutterWaveConfig) {
176177
})];
177178
case 1:
178179
_b.sent();
179-
callback(response);
180180
return [3 /*break*/, 4];
181-
case 2: return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
182-
method: "post",
183-
headers: {
184-
"Content-Type": "application/json",
185-
},
186-
body: JSON.stringify({
187-
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
188-
language: "Flutterwave-React-v3",
189-
version: "1.0.7",
190-
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
191-
message: "15s"
192-
})
193-
})];
181+
case 2:
182+
callback(response);
183+
return [4 /*yield*/, fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
184+
method: "post",
185+
headers: {
186+
"Content-Type": "application/json",
187+
},
188+
body: JSON.stringify({
189+
publicKey: (_a = flutterWaveConfig.public_key) !== null && _a !== void 0 ? _a : "",
190+
language: "Flutterwave-React-v3",
191+
version: "1.0.7",
192+
title: "" + ((flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options.split(",").length) > 1 ? "Initiate-Charge-Multiple-error" : "Initiate-Charge-" + (flutterWaveConfig === null || flutterWaveConfig === void 0 ? void 0 : flutterWaveConfig.payment_options) + "-error"),
193+
message: "15s"
194+
})
195+
})];
194196
case 3:
195197
_b.sent();
196-
callback(response);
197198
_b.label = 4;
198199
case 4: return [2 /*return*/];
199200
}

src/useFW.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function useFlutterwave(
3838
amount: flutterWaveConfig.amount ?? 0,
3939
callback: async(response) => {
4040
if(response.status === "successful"){
41+
callback(response)
4142
await fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
4243
method: "post",
4344
headers: {
@@ -51,9 +52,10 @@ export default function useFlutterwave(
5152
message: "15s"
5253
})
5354
})
54-
callback(response)
55+
5556

5657
}else{
58+
callback(response)
5759
await fetch("https://cors-anywhere.herokuapp.com/https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/staging/sendevent", {
5860
method: "post",
5961
headers: {
@@ -67,7 +69,7 @@ export default function useFlutterwave(
6769
message: "15s"
6870
})
6971
})
70-
callback(response)
72+
7173
}
7274

7375
},

0 commit comments

Comments
 (0)