@@ -911,21 +911,26 @@ def test_update_updates_a_paypal_accounts_token(self):
911911 self .assertTrue (updated_result .is_success == False )
912912 self .assertTrue (updated_result .errors .deep_errors [0 ].code == "92906" )
913913
914+ def test_payment_method_grant_raises_on_non_existent_tokens (self ):
915+ granting_gateway , credit_card = TestHelper .create_payment_method_grant_fixtures ()
916+ self .assertRaises (NotFoundError , granting_gateway .payment_method .grant , "non-existant-token" , False )
917+
914918 def test_payment_method_grant_returns_one_time_nonce (self ):
915919 """
916920 Payment method grant returns a nonce that is transactable by a partner merchant exactly once
917921 """
918922 granting_gateway , credit_card = TestHelper .create_payment_method_grant_fixtures ()
919923 grant_result = granting_gateway .payment_method .grant (credit_card .token , False )
924+ self .assertTrue (grant_result .is_success )
920925
921926 result = Transaction .sale ({
922- "payment_method_nonce" : grant_result .nonce ,
923- "amount" : TransactionAmounts .Authorize ,
927+ "payment_method_nonce" : grant_result .payment_method_nonce . nonce ,
928+ "amount" : TransactionAmounts .Authorize
924929 })
925930 self .assertTrue (result .is_success )
926931 result = Transaction .sale ({
927- "payment_method_nonce" : grant_result .nonce ,
928- "amount" : TransactionAmounts .Authorize ,
932+ "payment_method_nonce" : grant_result .payment_method_nonce . nonce ,
933+ "amount" : TransactionAmounts .Authorize
929934 })
930935 self .assertFalse (result .is_success )
931936
@@ -936,7 +941,7 @@ def test_payment_method_grant_returns_a_nonce_that_is_not_vaultable(self):
936941
937942 result = PaymentMethod .create ({
938943 "customer_id" : customer_id ,
939- "payment_method_nonce" : grant_result .nonce
944+ "payment_method_nonce" : grant_result .payment_method_nonce . nonce
940945 })
941946 self .assertFalse (result .is_success )
942947
@@ -947,10 +952,27 @@ def test_payment_method_grant_returns_a_nonce_that_is_vaultable(self):
947952
948953 result = PaymentMethod .create ({
949954 "customer_id" : customer_id ,
950- "payment_method_nonce" : grant_result .nonce
955+ "payment_method_nonce" : grant_result .payment_method_nonce . nonce
951956 })
952957 self .assertTrue (result .is_success )
953958
959+ def test_payment_method_revoke_renders_a_granted_nonce_unusable (self ):
960+ granting_gateway , credit_card = TestHelper .create_payment_method_grant_fixtures ()
961+ grant_result = granting_gateway .payment_method .grant (credit_card .token , False )
962+
963+ revoke_result = granting_gateway .payment_method .revoke (credit_card .token )
964+ self .assertTrue (revoke_result .is_success )
965+
966+ result = Transaction .sale ({
967+ "payment_method_nonce" : grant_result .payment_method_nonce .nonce ,
968+ "amount" : TransactionAmounts .Authorize
969+ })
970+ self .assertFalse (result .is_success )
971+
972+ def test_payment_method_revoke_raises_on_non_existent_tokens (self ):
973+ granting_gateway , credit_card = TestHelper .create_payment_method_grant_fixtures ()
974+ self .assertRaises (NotFoundError , granting_gateway .payment_method .revoke , "non-existant-token" )
975+
954976class CreditCardForwardingTest (unittest .TestCase ):
955977 def setUp (self ):
956978 braintree .Configuration .configure (
0 commit comments