@@ -842,6 +842,121 @@ def test_set_billing_agreement_details
842842 assert_equal ( true , res . success )
843843 end
844844
845+ def test_set_billing_agreement_details_sca_with_amount_overriden_currency
846+ seller_note = 'seller_note'
847+ store_name = 'store_name'
848+ custom_information = 'custom_information'
849+ seller_billing_agreement_id = 'seller_billing_agreement_id'
850+ billing_agreement_type = 'MerchantInitiatedTransaction'
851+ subscription_amount = '1.23'
852+ subscription_currency_code = 'GBP'
853+
854+ post_url = "AWSAccessKeyId=#{ ACCESS_KEY } " \
855+ "&Action=SetBillingAgreementDetails&AmazonBillingAgreementId=#{ AMAZON_BILLING_AGREEMENT_ID } " \
856+ "&BillingAgreementAttributes.BillingAgreementType=#{ billing_agreement_type } " \
857+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.CustomInformation=#{ custom_information } " \
858+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.SellerBillingAgreementId=#{ seller_billing_agreement_id } " \
859+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.StoreName=#{ store_name } " \
860+ "&BillingAgreementAttributes.SellerNote=seller_note" \
861+ "&BillingAgreementAttributes.SubscriptionAmount.Amount=#{ subscription_amount } " \
862+ "&BillingAgreementAttributes.SubscriptionAmount.CurrencyCode=#{ subscription_currency_code } " \
863+ "&SellerId=#{ MERCHANT_ID } " \
864+ "&SignatureMethod=HmacSHA256" \
865+ "&SignatureVersion=2" \
866+ "&Timestamp=#{ @operation . send :custom_escape , Time . now . utc . iso8601 } &Version=2013-01-01"
867+ post_body = [ "POST" , "mws.amazonservices.com" , "/OffAmazonPayments_Sandbox/2013-01-01" , post_url ] . join ( "\n " )
868+
869+ stub_request ( :post , "https://mws.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01" ) . with ( :body => "#{ post_url } " \
870+ "&Signature=#{ @operation . send :sign , post_body } " ,
871+ :headers => HEADERS ) . to_return ( :status => 200 )
872+
873+ res = @client . set_billing_agreement_details (
874+ AMAZON_BILLING_AGREEMENT_ID ,
875+ store_name : store_name ,
876+ seller_billing_agreement_id : seller_billing_agreement_id ,
877+ custom_information : custom_information ,
878+ seller_note : seller_note ,
879+ billing_agreement_type : billing_agreement_type ,
880+ subscription_amount : subscription_amount ,
881+ subscription_currency_code : subscription_currency_code
882+ )
883+ assert_equal ( true , res . success )
884+ end
885+
886+ def test_set_billing_agreement_details_sca_with_amount_default_currency
887+ seller_note = 'seller_note'
888+ store_name = 'store_name'
889+ custom_information = 'custom_information'
890+ seller_billing_agreement_id = 'seller_billing_agreement_id'
891+ billing_agreement_type = 'MerchantInitiatedTransaction'
892+ subscription_amount = '1.23'
893+
894+ post_url = "AWSAccessKeyId=#{ ACCESS_KEY } " \
895+ "&Action=SetBillingAgreementDetails&AmazonBillingAgreementId=#{ AMAZON_BILLING_AGREEMENT_ID } " \
896+ "&BillingAgreementAttributes.BillingAgreementType=#{ billing_agreement_type } " \
897+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.CustomInformation=#{ custom_information } " \
898+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.SellerBillingAgreementId=#{ seller_billing_agreement_id } " \
899+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.StoreName=#{ store_name } " \
900+ "&BillingAgreementAttributes.SellerNote=seller_note" \
901+ "&BillingAgreementAttributes.SubscriptionAmount.Amount=#{ subscription_amount } " \
902+ "&BillingAgreementAttributes.SubscriptionAmount.CurrencyCode=USD" \
903+ "&SellerId=#{ MERCHANT_ID } " \
904+ "&SignatureMethod=HmacSHA256" \
905+ "&SignatureVersion=2" \
906+ "&Timestamp=#{ @operation . send :custom_escape , Time . now . utc . iso8601 } &Version=2013-01-01"
907+ post_body = [ "POST" , "mws.amazonservices.com" , "/OffAmazonPayments_Sandbox/2013-01-01" , post_url ] . join ( "\n " )
908+
909+ stub_request ( :post , "https://mws.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01" ) . with ( :body => "#{ post_url } " \
910+ "&Signature=#{ @operation . send :sign , post_body } " ,
911+ :headers => HEADERS ) . to_return ( :status => 200 )
912+
913+ res = @client . set_billing_agreement_details (
914+ AMAZON_BILLING_AGREEMENT_ID ,
915+ store_name : store_name ,
916+ seller_billing_agreement_id : seller_billing_agreement_id ,
917+ custom_information : custom_information ,
918+ seller_note : seller_note ,
919+ billing_agreement_type : billing_agreement_type ,
920+ subscription_amount : subscription_amount
921+ )
922+ assert_equal ( true , res . success )
923+ end
924+
925+ def test_set_billing_agreement_details_sca_without_amount
926+ seller_note = 'seller_note'
927+ store_name = 'store_name'
928+ custom_information = 'custom_information'
929+ seller_billing_agreement_id = 'seller_billing_agreement_id'
930+ billing_agreement_type = 'CustomerInitiatedTransaction'
931+
932+ post_url = "AWSAccessKeyId=#{ ACCESS_KEY } " \
933+ "&Action=SetBillingAgreementDetails&AmazonBillingAgreementId=#{ AMAZON_BILLING_AGREEMENT_ID } " \
934+ "&BillingAgreementAttributes.BillingAgreementType=#{ billing_agreement_type } " \
935+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.CustomInformation=#{ custom_information } " \
936+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.SellerBillingAgreementId=#{ seller_billing_agreement_id } " \
937+ "&BillingAgreementAttributes.SellerBillingAgreementAttributes.StoreName=#{ store_name } " \
938+ "&BillingAgreementAttributes.SellerNote=seller_note" \
939+ "&SellerId=#{ MERCHANT_ID } " \
940+ "&SignatureMethod=HmacSHA256" \
941+ "&SignatureVersion=2" \
942+ "&Timestamp=#{ @operation . send :custom_escape , Time . now . utc . iso8601 } &Version=2013-01-01"
943+ post_body = [ "POST" , "mws.amazonservices.com" , "/OffAmazonPayments_Sandbox/2013-01-01" , post_url ] . join ( "\n " )
944+
945+ stub_request ( :post , "https://mws.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01" ) . with ( :body => "#{ post_url } " \
946+ "&Signature=#{ @operation . send :sign , post_body } " ,
947+ :headers => HEADERS ) . to_return ( :status => 200 )
948+
949+ res = @client . set_billing_agreement_details (
950+ AMAZON_BILLING_AGREEMENT_ID ,
951+ store_name : store_name ,
952+ seller_billing_agreement_id : seller_billing_agreement_id ,
953+ custom_information : custom_information ,
954+ seller_note : seller_note ,
955+ billing_agreement_type : billing_agreement_type
956+ )
957+ assert_equal ( true , res . success )
958+ end
959+
845960 def test_confirm_billing_agreement
846961 post_url = "AWSAccessKeyId=#{ ACCESS_KEY } " \
847962 "&Action=ConfirmBillingAgreement&AmazonBillingAgreementId=#{ AMAZON_BILLING_AGREEMENT_ID } " \
@@ -859,6 +974,29 @@ def test_confirm_billing_agreement
859974 assert_equal ( true , res . success )
860975 end
861976
977+ def test_confirm_billing_agreement_sca
978+ post_url = "AWSAccessKeyId=#{ ACCESS_KEY } " \
979+ "&Action=ConfirmBillingAgreement&AmazonBillingAgreementId=#{ AMAZON_BILLING_AGREEMENT_ID } " \
980+ "&FailureUrl=#{ FAILURE_URL_ENCODED } " \
981+ "&SellerId=#{ MERCHANT_ID } " \
982+ "&SignatureMethod=HmacSHA256" \
983+ "&SignatureVersion=2" \
984+ "&SuccessUrl=#{ SUCCESS_URL_ENCODED } " \
985+ "&Timestamp=#{ @operation . send :custom_escape , Time . now . utc . iso8601 } &Version=2013-01-01"
986+ post_body = [ "POST" , "mws.amazonservices.com" , "/OffAmazonPayments_Sandbox/2013-01-01" , post_url ] . join ( "\n " )
987+
988+ stub_request ( :post , "https://mws.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01" ) . with ( :body => "#{ post_url } " \
989+ "&Signature=#{ @operation . send :sign , post_body } " ,
990+ :headers => HEADERS ) . to_return ( :status => 200 )
991+
992+ res = @client . confirm_billing_agreement (
993+ AMAZON_BILLING_AGREEMENT_ID ,
994+ success_url : SUCCESS_URL ,
995+ failure_url : FAILURE_URL
996+ )
997+ assert_equal ( true , res . success )
998+ end
999+
8621000 def test_validate_billing_agreement
8631001 post_url = "AWSAccessKeyId=#{ ACCESS_KEY } " \
8641002 "&Action=ValidateBillingAgreement&AmazonBillingAgreementId=#{ AMAZON_BILLING_AGREEMENT_ID } " \
@@ -897,10 +1035,10 @@ def test_authorize_on_billing_agreement
8971035 :headers => HEADERS ) . to_return ( :status => 200 )
8981036
8991037 res = @client . authorize_on_billing_agreement (
900- AMAZON_BILLING_AGREEMENT_ID ,
901- AUTHORIZATION_REFERENCE_ID ,
902- AMOUNT ,
903- capture_now : "capture_now" ,
1038+ AMAZON_BILLING_AGREEMENT_ID ,
1039+ AUTHORIZATION_REFERENCE_ID ,
1040+ AMOUNT ,
1041+ capture_now : "capture_now" ,
9041042 transaction_timeout : "transaction_timeout" ,
9051043 supplementary_data : '{"AirlineMetaData" : {"version": 1.0}}'
9061044 )
0 commit comments