@@ -2203,10 +2203,6 @@ def test_card_type_indicators(self):
22032203 def test_create_can_set_recurring_flag (self ):
22042204 result = Transaction .sale ({
22052205 "amount" : "100" ,
2206- "customer" : {
2207- "first_name" : "Adam" ,
2208- "last_name" : "Williams"
2209- },
22102206 "credit_card" : {
22112207 "number" : "4111111111111111" ,
22122208 "expiration_date" : "05/2009"
@@ -2218,13 +2214,23 @@ def test_create_can_set_recurring_flag(self):
22182214 transaction = result .transaction
22192215 self .assertEqual (True , transaction .recurring )
22202216
2221- def test_create_can_set_transaction_source_flag_recurring (self ):
2217+ def test_create_can_set_transaction_source_flag_recurring_first (self ):
22222218 result = Transaction .sale ({
22232219 "amount" : "100" ,
2224- "customer " : {
2225- "first_name " : "Adam " ,
2226- "last_name " : "Williams "
2220+ "credit_card " : {
2221+ "number " : "4111111111111111 " ,
2222+ "expiration_date " : "05/2009 "
22272223 },
2224+ "transaction_source" : "recurring_first"
2225+ })
2226+
2227+ self .assertTrue (result .is_success )
2228+ transaction = result .transaction
2229+ self .assertEqual (True , transaction .recurring )
2230+
2231+ def test_create_can_set_transaction_source_flag_recurring (self ):
2232+ result = Transaction .sale ({
2233+ "amount" : "100" ,
22282234 "credit_card" : {
22292235 "number" : "4111111111111111" ,
22302236 "expiration_date" : "05/2009"
@@ -2236,13 +2242,23 @@ def test_create_can_set_transaction_source_flag_recurring(self):
22362242 transaction = result .transaction
22372243 self .assertEqual (True , transaction .recurring )
22382244
2239- def test_create_can_set_transaction_source_flag_moto (self ):
2245+ def test_create_can_set_transaction_source_flag_merchant (self ):
22402246 result = Transaction .sale ({
22412247 "amount" : "100" ,
2242- "customer " : {
2243- "first_name " : "Adam " ,
2244- "last_name " : "Williams "
2248+ "credit_card " : {
2249+ "number " : "4111111111111111 " ,
2250+ "expiration_date " : "05/2009 "
22452251 },
2252+ "transaction_source" : "merchant"
2253+ })
2254+
2255+ self .assertTrue (result .is_success )
2256+ transaction = result .transaction
2257+ self .assertEqual (False , transaction .recurring )
2258+
2259+ def test_create_can_set_transaction_source_flag_moto (self ):
2260+ result = Transaction .sale ({
2261+ "amount" : "100" ,
22462262 "credit_card" : {
22472263 "number" : "4111111111111111" ,
22482264 "expiration_date" : "05/2009"
@@ -2254,6 +2270,22 @@ def test_create_can_set_transaction_source_flag_moto(self):
22542270 transaction = result .transaction
22552271 self .assertEqual (False , transaction .recurring )
22562272
2273+ def test_create_can_set_transaction_source_flag_invalid (self ):
2274+ result = Transaction .sale ({
2275+ "amount" : "100" ,
2276+ "credit_card" : {
2277+ "number" : "4111111111111111" ,
2278+ "expiration_date" : "05/2009"
2279+ },
2280+ "transaction_source" : "invalid_value"
2281+ })
2282+
2283+ self .assertFalse (result .is_success )
2284+ self .assertEqual (
2285+ ErrorCodes .Transaction .TransactionSourceIsInvalid ,
2286+ result .errors .for_object ("transaction" ).on ("transaction_source" )[0 ].code
2287+ )
2288+
22572289 def test_create_can_store_customer_and_credit_card_in_the_vault (self ):
22582290 result = Transaction .sale ({
22592291 "amount" : "100" ,
@@ -4054,6 +4086,67 @@ def test_creating_paypal_transaction_with_one_time_use_nonce(self):
40544086 self .assertNotEqual (None , transaction .paypal_details .image_url )
40554087 self .assertNotEqual (None , transaction .paypal_details .debug_id )
40564088
4089+ def test_creating_paypal_transaction_with_payee_id (self ):
4090+ result = Transaction .sale ({
4091+ "amount" : TransactionAmounts .Authorize ,
4092+ "payment_method_nonce" : Nonces .PayPalOneTimePayment ,
4093+ "paypal_account" : {
4094+ "payee_id" : "fake-payee-id"
4095+ }
4096+ })
4097+
4098+ self .assertTrue (result .is_success )
4099+ transaction = result .transaction
4100+
4101+ self .assertEqual (transaction .paypal_details .payer_email , "payer@example.com" )
4102+ self .assertNotEqual (None , re .search (r'PAY-\w+' , transaction .paypal_details .payment_id ))
4103+ self .assertNotEqual (None , re .search (r'AUTH-\w+' , transaction .paypal_details .authorization_id ))
4104+ self .assertNotEqual (None , transaction .paypal_details .image_url )
4105+ self .assertNotEqual (None , transaction .paypal_details .debug_id )
4106+ self .assertEqual (transaction .paypal_details .payee_id , "fake-payee-id" )
4107+
4108+ def test_creating_paypal_transaction_with_payee_id_in_options_params (self ):
4109+ result = Transaction .sale ({
4110+ "amount" : TransactionAmounts .Authorize ,
4111+ "payment_method_nonce" : Nonces .PayPalOneTimePayment ,
4112+ "paypal_account" : {},
4113+ "options" : {
4114+ "payee_id" : "fake-payee-id"
4115+ }
4116+ })
4117+
4118+ self .assertTrue (result .is_success )
4119+ transaction = result .transaction
4120+
4121+ self .assertEqual (transaction .paypal_details .payer_email , "payer@example.com" )
4122+ self .assertNotEqual (None , re .search (r'PAY-\w+' , transaction .paypal_details .payment_id ))
4123+ self .assertNotEqual (None , re .search (r'AUTH-\w+' , transaction .paypal_details .authorization_id ))
4124+ self .assertNotEqual (None , transaction .paypal_details .image_url )
4125+ self .assertNotEqual (None , transaction .paypal_details .debug_id )
4126+ self .assertEqual (transaction .paypal_details .payee_id , "fake-payee-id" )
4127+
4128+ def test_creating_paypal_transaction_with_payee_id_in_options_paypal_params (self ):
4129+ result = Transaction .sale ({
4130+ "amount" : TransactionAmounts .Authorize ,
4131+ "payment_method_nonce" : Nonces .PayPalOneTimePayment ,
4132+ "paypal_account" : {},
4133+ "options" : {
4134+ "paypal" : {
4135+ "payee_id" : "fake-payee-id"
4136+ }
4137+ }
4138+ })
4139+
4140+ self .assertTrue (result .is_success )
4141+ transaction = result .transaction
4142+
4143+ self .assertEqual (transaction .paypal_details .payer_email , "payer@example.com" )
4144+ self .assertNotEqual (None , re .search (r'PAY-\w+' , transaction .paypal_details .payment_id ))
4145+ self .assertNotEqual (None , re .search (r'AUTH-\w+' , transaction .paypal_details .authorization_id ))
4146+ self .assertNotEqual (None , transaction .paypal_details .image_url )
4147+ self .assertNotEqual (None , transaction .paypal_details .debug_id )
4148+ self .assertEqual (transaction .paypal_details .payee_id , "fake-payee-id" )
4149+
40574150 def test_creating_paypal_transaction_with_payee_email (self ):
40584151 result = Transaction .sale ({
40594152 "amount" : TransactionAmounts .Authorize ,
0 commit comments