@paypal/checkout-components 5.0.302 → 5.0.303-alpha.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/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getClientID,
|
|
8
8
|
getMerchantID as getSDKMerchantID,
|
|
9
9
|
} from "@paypal/sdk-client/src";
|
|
10
|
+
import { FUNDING } from "@paypal/sdk-constants/src";
|
|
10
11
|
|
|
11
12
|
import type {
|
|
12
13
|
ButtonVariables,
|
|
@@ -208,6 +209,14 @@ export const buildHostedButtonOnApprove = ({
|
|
|
208
209
|
merchant_id: merchantId,
|
|
209
210
|
context_id: data.orderID,
|
|
210
211
|
}),
|
|
212
|
+
}).then((response) => {
|
|
213
|
+
// The "Debit or Credit Card" button does not open a popup
|
|
214
|
+
// so we need to redirect to the thank you page for buyers who complete
|
|
215
|
+
// a checkout via "Debit or Credit Card".
|
|
216
|
+
if (data.paymentSource === FUNDING.CARD) {
|
|
217
|
+
window.location = `${baseUrl}/ncp/payment/${hostedButtonId}/${data.orderID}`;
|
|
218
|
+
}
|
|
219
|
+
return response;
|
|
211
220
|
});
|
|
212
221
|
};
|
|
213
222
|
};
|
|
@@ -264,6 +264,28 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
264
264
|
);
|
|
265
265
|
expect.assertions(1);
|
|
266
266
|
});
|
|
267
|
+
|
|
268
|
+
describe("inline guest", () => {
|
|
269
|
+
const onApprove = buildHostedButtonOnApprove({
|
|
270
|
+
hostedButtonId,
|
|
271
|
+
merchantId,
|
|
272
|
+
});
|
|
273
|
+
// $FlowIssue
|
|
274
|
+
request.mockImplementation(() =>
|
|
275
|
+
// eslint-disable-next-line compat/compat
|
|
276
|
+
Promise.resolve({
|
|
277
|
+
body: {},
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
test("redirects from the merchant's site to a thank you page", async () => {
|
|
282
|
+
expect(window.location.href).toBe("http://localhost:3000/");
|
|
283
|
+
await onApprove({ orderID, paymentSource: "card" });
|
|
284
|
+
expect(window.location).toBe(
|
|
285
|
+
"https://example.com/ncp/payment/B1234567890/EC-1234567890"
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
267
289
|
});
|
|
268
290
|
|
|
269
291
|
/* eslint-enable no-restricted-globals, promise/no-native */
|