§
    °d»jq  ã            
       óV  — d Z ddlZddlZddlZej                             dej                             ej                             ej                             e	¦  «        d¦  «        ¦  «        ¦  «         ddl
mZmZmZmZ  G d„ dej        ¦  «        Zedk    r ej        ¦   «          dS dS )zë
Unit tests for FreeExile Platform Payment Compliance Router.
Enforces Apple App Store Guideline 3.1.1 and Google Play Billing requirements.
Guarantees iOS builds NEVER expose 3rd party gateways, while Web/PC can offer Crypto & Cards.
é    Nz../../server)ÚPaymentGatewayRouterÚPlatformTypeÚPaymentGatewayÚPlatformPolicyViolationErrorc                   ó,   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚTestPaymentCompliancec                 ó,   — t          ¦   «         | _        d S )N)r   Úrouter©Úselfs    ú;C:\Projects\FreeExile\tests\unit\test_payment_compliance.pyÚsetUpzTestPaymentCompliance.setUp   s   € Ý*Ñ,Ô,ˆŒˆˆó    c                 ó|  — | j                              t          j        d¬¦  «        }d„ |D ¦   «         }|                      t          |¦  «        d¦  «         |                      |d         t          j        ¦  «         |                      t          j	        |¦  «         |                      t          j
        |¦  «         dS )zÏ
        Apple App Store Guideline 3.1.1:
        iOS builds MUST ONLY offer Apple In-App Purchase (StoreKit 2).
        Third-party processors (Stripe, PayPal, Crypto, MoMo) are STRICTLY FORBIDDEN.
        ÚUS©ÚplatformÚcountry_codec                 ó   — g | ]	}|j         ‘Œ
S © ©Úgateway©Ú.0Úms     r   ú
<listcomp>zOTestPaymentCompliance.test_ios_strictly_limits_to_apple_iap.<locals>.<listcomp>#   ó   € Ð/Ð/Ð/ !�A”IÐ/Ð/Ð/r   é   r   N)r
   Úget_allowed_payment_methodsr   ÚPLATFORM_IOSÚassertEqualÚlenr   ÚGATEWAY_APPLE_IAPÚassertNotInÚGATEWAY_STRIPEÚGATEWAY_CRYPTO_WEB3©r   ÚmethodsÚgatewayss      r   Ú%test_ios_strictly_limits_to_apple_iapz;TestPaymentCompliance.test_ios_strictly_limits_to_apple_iap   s¯   € ð ”+×9Ò9Ý!Ô.Øð :ñ 
ô 
ˆð 0Ð/ wÐ/Ñ/Ô/ˆà×Ò�˜X™œ¨Ñ*Ô*Ð*Ø×Ò˜ !œ¥nÔ&FÑGÔGÐGØ×Ò�Ô6¸ÑAÔAÐAØ×Ò�Ô;¸XÑFÔFÐFÐFÐFr   c                 óœ  — |                       t          ¦  «        5  | j                             ddt          j        t          j        d¬¦  «         ddd¦  «         n# 1 swxY w Y   |                       t          ¦  «        5  | j                             ddt          j        t          j        d¬¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zaAttempting to initiate a Stripe or Web3 Crypto order from an iOS platform throws PolicyViolation.Úacc_ios_user_01Úcoin_pack_1000ÚVN)Ú
account_idÚ
product_idr   Úrequested_gatewayr   NÚacc_ios_user_02r   )	ÚassertRaisesr   r
   Úcreate_payment_orderr   r    r   r&   r%   r   s    r   Ú+test_ios_rejects_third_party_order_creationzATestPaymentCompliance.test_ios_rejects_third_party_order_creation*   sO  € à×ÒÕ;Ñ<Ô<ð 	ð 	ØŒK×,Ò,Ø,Ø+Ý%Ô2Ý"0Ô"DØ!ð -ñ ô ð ð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð ×ÒÕ;Ñ<Ô<ð 	ð 	ØŒK×,Ò,Ø,Ø+Ý%Ô2Ý"0Ô"?Ø!ð -ñ ô ð ð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s#   ›4AÁAÁ"AÂ 4CÃCÃCc                 óü   — | j                              t          j        d¬¦  «        }d„ |D ¦   «         }|                      t          |¦  «        d¦  «         |                      |d         t          j        ¦  «         dS )zAStandard Google Play builds must only expose Google Play Billing.r   r   c                 ó   — g | ]	}|j         ‘Œ
S r   r   r   s     r   r   z^TestPaymentCompliance.test_android_playstore_limits_to_google_play_billing.<locals>.<listcomp>D   r   r   r   r   N)r
   r   r   ÚPLATFORM_ANDROID_PLAYSTOREr!   r"   r   ÚGATEWAY_GOOGLE_PLAYr'   s      r   Ú4test_android_playstore_limits_to_google_play_billingzJTestPaymentCompliance.test_android_playstore_limits_to_google_play_billing>   s{   € à”+×9Ò9Ý!Ô<Øð :ñ 
ô 
ˆð 0Ð/ wÐ/Ñ/Ô/ˆØ×Ò�˜X™œ¨Ñ*Ô*Ð*Ø×Ò˜ !œ¥nÔ&HÑIÔIÐIÐIÐIr   c                 ó*  — | j                              t          j        d¬¦  «        }d„ |D ¦   «         }|                      t
          j        |¦  «         |                      t
          j        |¦  «         |                      t
          j	        |¦  «         dS )zŠ
        Official Web Direct Portal and APK sideload allow full gateway suite:
        Stripe, PayPal, Local QR, and Web3 Crypto.
        r.   r   c                 ó   — h | ]	}|j         ’Œ
S r   r   r   s     r   ú	<setcomp>zfTestPaymentCompliance.test_web_pc_and_sideload_allow_full_gateways_including_crypto.<locals>.<setcomp>Q   s   € Ð7Ð7Ð7 a˜œ	Ð7Ð7Ð7r   N)
r
   r   r   ÚPLATFORM_WEB_PCÚassertInr   r&   r%   r$   r#   )r   Úweb_methodsÚweb_gatewayss      r   Ú=test_web_pc_and_sideload_allow_full_gateways_including_cryptozSTestPaymentCompliance.test_web_pc_and_sideload_allow_full_gateways_including_cryptoH   s‹   € ð
 ”k×=Ò=Ý!Ô1Øð >ñ 
ô 
ˆð 8Ð7¨;Ð7Ñ7Ô7ˆà�Š•nÔ8¸,ÑGÔGÐGØ�Š•nÔ3°\ÑBÔBÐBØ×Ò�Ô9¸<ÑHÔHÐHÐHÐHr   N)Ú__name__Ú
__module__Ú__qualname__r   r*   r5   r:   rB   r   r   r   r   r      sj   € € € € € ð-ð -ð -ðGð Gð Gð"ð ð ð(Jð Jð JðIð Ið Ið Ið Ir   r   Ú__main__)Ú__doc__ÚunittestÚsysÚosÚpathÚinsertÚabspathÚjoinÚdirnameÚ__file__Úshop.payment_gateway_routerr   r   r   r   ÚTestCaser   rC   Úmainr   r   r   ú<module>rT      s  ððð ð €€€Ø 
€
€
€
Ø 	€	€	€	à „‡‚��2”7—?’? 2¤7§<¢<°´·²ÀÑ0IÔ0IÈ>Ñ#ZÔ#ZÑ[Ô[Ñ \Ô \Ð \ðð ð ð ð ð ð ð ð ð ð ð ð@Ið @Ið @Ið @Ið @I˜HÔ-ñ @Iô @Ið @IðF ˆzÒÐØ€H„M�O„O€O€O€Oð Ðr   