@@ -12,6 +12,7 @@ const frameService = require("../../../src/lib/frame-service/external");
12
12
const { fake, yieldsAsync } = require ( "../../helpers" ) ;
13
13
const methods = require ( "../../../src/lib/methods" ) ;
14
14
const errors = require ( "../../../src/paypal-checkout/errors" ) ;
15
+ const constants = require ( "../../../src/paypal/shared/constants" ) ;
15
16
16
17
describe ( "PayPalCheckout" , ( ) => {
17
18
let testContext ;
@@ -3268,7 +3269,7 @@ describe("PayPalCheckout", () => {
3268
3269
firstHeadElement
3269
3270
) ;
3270
3271
expect ( fakeScript . src ) . toMatch (
3271
- "https://www.te- braintree.qa .paypal.com/sdk/js?"
3272
+ "https://www.braintree.stage .paypal.com/sdk/js?"
3272
3273
) ;
3273
3274
} ) ;
3274
3275
} ) ;
@@ -3845,6 +3846,7 @@ describe("PayPalCheckout", () => {
3845
3846
testContext . configuration = {
3846
3847
authorization : "development_testing_altpay_merchant" ,
3847
3848
gatewayConfiguration : {
3849
+ merchantId : "merchant-id" ,
3848
3850
paypal : {
3849
3851
assetsUrl : "https://paypal.assets.url" ,
3850
3852
displayName : "my brand" ,
@@ -3946,6 +3948,100 @@ describe("PayPalCheckout", () => {
3946
3948
expect ( actual . cancelUrl ) . toBe ( "www.example.com/cancel" ) ;
3947
3949
} ) ;
3948
3950
3951
+ it ( "includes BT source parameter with value 'bsdk'" , ( ) => {
3952
+ const options = {
3953
+ flow : "checkout" ,
3954
+ } ;
3955
+
3956
+ const actual = PayPalCheckout . prototype . _formatPaymentResourceData . call (
3957
+ {
3958
+ _configuration : testContext . configuration ,
3959
+ _formatPaymentResourceCheckoutData : jest . fn ( ) ,
3960
+ _formatPaymentResourceVaultData : jest . fn ( ) ,
3961
+ } ,
3962
+ options ,
3963
+ testContext . config
3964
+ ) ;
3965
+
3966
+ expect ( actual . source ) . toBe ( constants . BT_SOURCE ) ;
3967
+ } ) ;
3968
+
3969
+ it ( "includes BT merchant parameter from gateway configuration" , ( ) => {
3970
+ const options = {
3971
+ flow : "checkout" ,
3972
+ } ;
3973
+
3974
+ const actual = PayPalCheckout . prototype . _formatPaymentResourceData . call (
3975
+ {
3976
+ _configuration : testContext . configuration ,
3977
+ _merchantAccountId : "DEFAULT_MERCHANT_ID" ,
3978
+ _formatPaymentResourceCheckoutData : jest . fn ( ) ,
3979
+ _formatPaymentResourceVaultData : jest . fn ( ) ,
3980
+ } ,
3981
+ options ,
3982
+ testContext . config
3983
+ ) ;
3984
+
3985
+ expect ( actual . merchant ) . toBe ( "merchant-id" ) ;
3986
+ } ) ;
3987
+
3988
+ it ( "includes BT flowType parameter as 'ecs' for checkout flow" , ( ) => {
3989
+ const options = {
3990
+ flow : "checkout" ,
3991
+ } ;
3992
+
3993
+ const actual = PayPalCheckout . prototype . _formatPaymentResourceData . call (
3994
+ {
3995
+ _configuration : testContext . configuration ,
3996
+ _formatPaymentResourceCheckoutData : jest . fn ( ) ,
3997
+ _formatPaymentResourceVaultData : jest . fn ( ) ,
3998
+ } ,
3999
+ options ,
4000
+ testContext . config
4001
+ ) ;
4002
+
4003
+ expect ( actual . flowType ) . toBe ( constants . BT_FLOW_TYPES . EXPRESS_CHECKOUT ) ;
4004
+ } ) ;
4005
+
4006
+ it ( "includes BT flowType parameter as 'va' for vault flow" , ( ) => {
4007
+ const options = {
4008
+ flow : "vault" ,
4009
+ } ;
4010
+
4011
+ const actual = PayPalCheckout . prototype . _formatPaymentResourceData . call (
4012
+ {
4013
+ _configuration : testContext . configuration ,
4014
+ _formatPaymentResourceCheckoutData : jest . fn ( ) ,
4015
+ _formatPaymentResourceVaultData : jest . fn ( ) ,
4016
+ } ,
4017
+ options ,
4018
+ testContext . config
4019
+ ) ;
4020
+
4021
+ expect ( actual . flowType ) . toBe ( constants . BT_FLOW_TYPES . VAULT ) ;
4022
+ } ) ;
4023
+
4024
+ it ( "includes all BT parameters together" , ( ) => {
4025
+ const options = {
4026
+ flow : "checkout" ,
4027
+ } ;
4028
+
4029
+ const actual = PayPalCheckout . prototype . _formatPaymentResourceData . call (
4030
+ {
4031
+ _configuration : testContext . configuration ,
4032
+ _merchantAccountId : "DEFAULT_MERCHANT_ID" ,
4033
+ _formatPaymentResourceCheckoutData : jest . fn ( ) ,
4034
+ _formatPaymentResourceVaultData : jest . fn ( ) ,
4035
+ } ,
4036
+ options ,
4037
+ testContext . config
4038
+ ) ;
4039
+
4040
+ expect ( actual . source ) . toBe ( constants . BT_SOURCE ) ;
4041
+ expect ( actual . merchant ) . toBe ( "merchant-id" ) ;
4042
+ expect ( actual . flowType ) . toBe ( constants . BT_FLOW_TYPES . EXPRESS_CHECKOUT ) ;
4043
+ } ) ;
4044
+
3949
4045
it ( "passes along appSwitchPreference when passed" , ( ) => {
3950
4046
const options = {
3951
4047
appSwitchPreference : {
0 commit comments