diff --git a/.circleci/config.yml b/.circleci/config.yml index 8fe75ec..d9000a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,15 +64,33 @@ jobs: <<: *build7 docker: - image: circleci/php:7.1.27-stretch + build72: <<: *build7 docker: - image: circleci/php:7.2.16-stretch + build73: <<: *build7 docker: - image: circleci/php:7.3.3-stretch + build74: + <<: *build7 + docker: + - image: circleci/php:7.4.25-cli-buster-node + + run-integration-tests-php74: + docker: + - image: circleci/php:7.4.25-cli-buster-node + steps: + - checkout + - run: + name: Install the lib and run tests + command: | + composer install -n --prefer-dist + php test_integration_app/main.php + workflows: version: 2 check_compile: @@ -83,3 +101,9 @@ workflows: context: *context - build73: context: *context + - build74: + context: *context + - run-integration-tests-php74: + filters: + branches: + only: master diff --git a/README.md b/README.md index d55b458..d0aea22 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,24 @@ $sift = new SiftClient([ ]); ``` +## Integration testing app + +For testing the app with real calls it is possible to run the integration testing app, +it makes calls to almost all our public endpoints to make sure the library integrates +well. At the moment, the app is run on every merge to master + +#### How to run it locally + +1. Add env variable `ACCOUNT_ID` with the valid account id +2. Add env variable `API_KEY` with the valid Api Key associated from the account +3. Run the following under the project root folder +``` +# install the lib from the local source code +composer install -n +# run the app +php test_integration_app/main.php +``` + ## License MIT diff --git a/test_integration_app/decisions_api/test_decisions_api.php b/test_integration_app/decisions_api/test_decisions_api.php index b7ea00d..474bee7 100644 --- a/test_integration_app/decisions_api/test_decisions_api.php +++ b/test_integration_app/decisions_api/test_decisions_api.php @@ -4,7 +4,7 @@ class test_decisions_api private $client; function __construct() { - $this->client = new SiftClient(array('api_key' => getenv("api_key"), 'account_id' => getenv("account_id"))); + $this->client = new SiftClient(array('api_key' => getenv("API_KEY"), 'account_id' => getenv("ACCOUNT_ID"))); } function getUserDecisions() @@ -24,9 +24,9 @@ function getContentDecisions() function getSessionDecisions() { - return $this->client->getSessionDecisions($GLOBALS['user_id'], 'gigtleqddo84l8cm15qe4il'); + return $this->client->getSessionDecisions($GLOBALS['user_id'], $GLOBALS['session_id']); } - + function getDecisions() { $options = array( @@ -47,7 +47,7 @@ function apply_decision_to_user() ); return $this->client->applyDecisionToUser($GLOBALS['user_id'], - 'block_user_payment_abuse', + 'integration_app_watch_account_abuse', 'MANUAL_REVIEW', $options); } @@ -61,7 +61,7 @@ function apply_decision_to_order() return $this->client->applyDecisionToOrder($GLOBALS['user_id'], 'ORDER-28168441', - 'user_looks_ok_payment_decision', + 'block_order_payment_abuse', 'MANUAL_REVIEW', $options); } @@ -74,8 +74,8 @@ function apply_decision_to_session() '); return $this->client->applyDecisionToSession($GLOBALS['user_id'], - 'gigtleqddo84l8cm15qe4il', - 'session_looks_fraud_account_takeover', + $GLOBALS['session_id'], + 'integration_app_watch_account_takeover', 'MANUAL_REVIEW', $options); } @@ -89,7 +89,7 @@ function apply_decision_to_content() return $this->client->applyDecisionToContent($GLOBALS['user_id'], 'message-23412', - 'content_looks_fraud_content_abuse', + 'integration_app_watch_content_abuse', 'MANUAL_REVIEW', $options); } diff --git a/test_integration_app/events_api/test_events_api.php b/test_integration_app/events_api/test_events_api.php index 3e86b4c..5dadde4 100644 --- a/test_integration_app/events_api/test_events_api.php +++ b/test_integration_app/events_api/test_events_api.php @@ -4,18 +4,18 @@ class test_events_api private $client; function __construct() { - $this->client = new SiftClient(array('api_key' => getenv("api_key"), 'account_id' => getenv("account_id"))); + $this->client = new SiftClient(array('api_key' => getenv("API_KEY"), 'account_id' => getenv("ACCOUNT_ID"))); } function add_item_to_cart() - { + { // Sample $add_item_to_cart event $add_item_to_cart_properties = array( // Required Fields - '$user_id' => $GLOBALS['user_id'], - + '$user_id' => $GLOBALS['user_id'], + // Supported Fields - '$session_id' => 'gigtleqddo84l8cm15qe4il', + '$session_id' => $GLOBALS['session_id'], '$item' => array( '$item_id' => 'B004834GQO', '$product_title' => 'The Slanket Blanket-Texas Tea', @@ -50,7 +50,7 @@ function add_promotion() $add_promotion_properties = array( // Required fields. '$user_id' => $GLOBALS['user_id'], - + // Supported fields. '$promotions' => array( // Example of a promotion for monetary discounts off good or services @@ -90,7 +90,7 @@ function chargeback() // Required Fields '$order_id' => 'ORDER-123124124', '$transaction_id' => '719637215', - + // Recommended Fields '$user_id' => $GLOBALS['user_id'], '$chargeback_state' => '$lost', @@ -122,19 +122,19 @@ function content_status() '$client_language' => 'en-US' ) ); - + return $this->client->track('$content_status', $content_status_properties); } - + function create_account() { // Sample $create_account event $create_account_properties = array( // Required Fields '$user_id' => $GLOBALS['user_id'], - + // Supported Fields - '$session_id' => 'gigtleqddo84l8cm15qe4il', + '$session_id' => $GLOBALS['session_id'], '$user_email' => $GLOBALS['user_email'], '$name' => 'Bill Jones', '$phone' => '1-415-555-6040', @@ -174,10 +174,10 @@ function create_account() '$credit_point' => array( '$amount' => 100, '$credit_point_type' => 'account karma' - ) + ) ) ), - + '$social_sign_on_type' => '$twitter', '$account_types' => ['merchant', 'premium'], @@ -188,7 +188,7 @@ function create_account() 'referral_code' => 'MIKEFRIENDS', 'email_confirmed_status' => '$pending', 'phone_confirmed_status' => '$pending', - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -207,12 +207,12 @@ function create_content_comment() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'comment-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $comment object '$comment' => array( '$body' => 'Congrats on the new role!', @@ -234,7 +234,7 @@ function create_content_comment() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$create_content', $comment_properties); } @@ -245,12 +245,12 @@ function create_content_listing() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'listing-23412', - + // Supported fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $listing object '$listing' => array( '$subject' => '2 Bedroom Apartment for Rent', @@ -288,7 +288,7 @@ function create_content_listing() ), '$expiration_time' => 1549063157000 // UNIX timestamp in milliseconds ), - + // Send this information an APP client. '$app' => array( // Example for the iOS Calculator app. @@ -313,12 +313,12 @@ function create_content_message() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'message-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $message object '$message' => array( '$body' => 'Let’s meet at 5pm', @@ -332,7 +332,7 @@ function create_content_message() ) ) ), - + // Send this information an APP client. '$app' => array( // Example for the iOS Calculator app. @@ -346,7 +346,7 @@ function create_content_message() '$client_language' => 'en-US' ) ); - + return $this->client->track('$create_content', $message_properties); } @@ -357,12 +357,12 @@ function create_content_post() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'post-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $post object '$post' => array( '$subject' => 'My new apartment!', @@ -407,7 +407,7 @@ function create_content_post() '$client_language' => 'en-US' ) ); - + return $this->client->track('$create_content', $post_properties); } @@ -418,12 +418,12 @@ function create_content_profile() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'profile-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $profile object '$profile' => array( '$body' => 'Hi! My name is Alex and I just moved to New London!', @@ -462,10 +462,10 @@ function create_content_profile() '$client_language' => 'en-US' ) ); - + return $this->client->track('$create_content', $profile_properties); } - + function create_content_review() { // Sample $create_content event for reviews @@ -473,12 +473,12 @@ function create_content_review() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'review-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $review object '$review' => array( '$subject' => 'Amazing Tacos!', @@ -502,7 +502,7 @@ function create_content_review() ), '$rating' => 4.5 ), - + // Send this information an APP client. '$app' => array( // Example for the iOS Calculator app. @@ -527,7 +527,7 @@ function create_order() // Required Fields '$user_id' => $GLOBALS['user_id'], // Supported Fields - '$session_id' => 'gigtleqddo84l8cm15qe4il', + '$session_id' => $GLOBALS['session_id'], '$order_id' => 'ORDER-28168441', '$user_email' => $GLOBALS['user_email'], '$verification_phone_number' => "+123456789012", @@ -611,7 +611,7 @@ function create_order() ), // For marketplaces, use $seller_user_id to identify the seller '$seller_user_id' => 'slinkys_emporium', - + '$promotions' => array( array( '$promotion_id' => 'FirstTimeBuyer', @@ -624,13 +624,13 @@ function create_order() ) ) ), - + // Sample Custom Fields 'digital_wallet' => 'apple_pay', // 'google_wallet', etc. 'coupon_code' => 'dollarMadness', 'shipping_choice' => 'FedEx Ground Courier', 'is_first_time_buyer' => false, - + // Send this information an APP client. '$app' => array( // Example for the iOS Calculator app. @@ -644,7 +644,7 @@ function create_order() '$client_language' => 'en-US' ) ); - + return $this->client->track('$create_order', $properties); } @@ -655,11 +655,11 @@ function flag_content() // Required Fields '$user_id' => $GLOBALS['user_id'], // content creator '$content_id' => '9671500641', - + // Supported Fields '$flagged_by' => 'jamieli89' ); - + return $this->client->track('$flag_content', $properties); } @@ -669,7 +669,7 @@ function link_session_to_user() $properties = array( // Required Fields '$user_id' => $GLOBALS['user_id'], - '$session_id' => 'gigtleqddo84l8cm15qe4il' + '$session_id' => $GLOBALS['session_id'] ); return $this->client->track('$link_session_to_user', $properties); @@ -682,10 +682,10 @@ function login() // Required Fields '$user_id' => $GLOBALS['user_id'], '$login_status' => '$failure', - + '$session_id' => 'gigtleqddo84l8cm15qe4il', '$ip' => '128.148.1.135', - + // Optional Fields '$user_email' => $GLOBALS['user_email'], '$verification_phone_number' => '+123456789012', @@ -696,7 +696,7 @@ function login() '$brand_name' => 'sift', '$site_domain' => 'sift.com', '$site_country' => 'US', - + // Send this information with a login from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -704,7 +704,7 @@ function login() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$login', $properties); } @@ -714,7 +714,7 @@ function logout() $properties = array( // Required Fields '$user_id' => $GLOBALS['user_id'], - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -722,7 +722,7 @@ function logout() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$logout', $properties); } @@ -734,14 +734,14 @@ function order_status() '$user_id' => $GLOBALS['user_id'], '$order_id' => 'ORDER-28168441', '$order_status' => '$canceled', - + // Optional Fields '$reason' => '$payment_risk', '$source' => '$manual_review', '$analyst' => 'someone@your-site.com', '$webhook_id' => '3ff1082a4aea8d0c58e3643ddb7a5bb87ffffeb2492dca33', '$description' => 'Canceling because multiple fraudulent users on device', - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -759,7 +759,7 @@ function remove_item_from_cart() $properties = array( // Required Fields '$user_id' => $GLOBALS['user_id'], - + // Supported Fields '$session_id' => 'gigtleqddo84l8cm15qe4il', '$item' => array( @@ -776,14 +776,14 @@ function remove_item_from_cart() '$tags' => array('Awesome', 'Wintertime specials'), '$color' => 'Texas Tea' ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', '$accept_language' => 'en-US', '$content_language' => 'en-GB' ) - ); + ); return $this->client->track('$remove_item_from_cart', $properties); } @@ -799,7 +799,7 @@ function security_notification() // Optional fields if applicable '$notification_type' => '$email', '$notified_value' => 'billy123@domain.com', - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -819,7 +819,7 @@ function transaction() '$user_id' => $GLOBALS['user_id'], '$amount' => 506790000, // $506.79 '$currency_code' => 'USD', - + // Supported Fields '$user_email' => $GLOBALS['user_email'], '$transaction_type' => '$sale', @@ -827,7 +827,7 @@ function transaction() '$decline_category' => '$bank_decline', '$order_id' => 'ORDER-123124124', '$transaction_id' => '719637215', - + '$billing_address' => array( // or "$sent_address" // or "$received_address" '$name' => 'Bill Jones', '$phone' => '1-415-555-6041', @@ -861,12 +861,12 @@ function transaction() '$card_bin' => '542486', '$card_last4' => '4444' ), - + // Supported fields for 3DS '$status_3ds' => '$attempted', '$triggered_3ds' => '$processor', '$merchant_initiated_transaction' => false, - + // Supported Fields '$shipping_address' => array( '$name' => 'Bill Jones', @@ -879,16 +879,16 @@ function transaction() '$zipcode' => '03257' ), '$session_id' => 'gigtleqddo84l8cm15qe4il', - + // For marketplaces, use $seller_user_id to identify the seller '$seller_user_id' => 'slinkys_emporium', - + // Sample Custom Fields 'digital_wallet' => 'apple_pay', // 'google_wallet', etc. 'coupon_code' => 'dollarMadness', 'shipping_choice' => 'FedEx Ground Courier', 'is_first_time_buyer' => false, - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -896,7 +896,7 @@ function transaction() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$transaction', $properties); } @@ -941,7 +941,7 @@ function update_account() ), '$social_sign_on_type' => '$twitter', '$account_types' => ['merchant', 'premium'], - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -960,12 +960,12 @@ function update_content_comment() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'comment-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $comment object '$comment' => array( '$body' => 'Congrats on the new role!', @@ -980,7 +980,7 @@ function update_content_comment() ) ) ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -988,7 +988,7 @@ function update_content_comment() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_content', $comment_properties); } @@ -999,12 +999,12 @@ function update_content_listing() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'listing-23412', - + // Supported fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $listing object '$listing' => array( '$subject' => '2 Bedroom Apartment for Rent', @@ -1042,7 +1042,7 @@ function update_content_listing() ), '$expiration_time' => 1549063157000 // UNIX timestamp in milliseconds ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1050,7 +1050,7 @@ function update_content_listing() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_content', $listing_properties); } @@ -1061,12 +1061,12 @@ function update_content_message() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'message-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $message object '$message' => array( '$body' => 'Let’s meet at 5pm', @@ -1080,7 +1080,7 @@ function update_content_message() ) ) ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1088,7 +1088,7 @@ function update_content_message() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_content', $message_properties); } @@ -1099,12 +1099,12 @@ function update_content_post() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'post-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $post object '$post' => array( '$subject' => 'My new apartment!', @@ -1135,7 +1135,7 @@ function update_content_post() ), '$expiration_time' => 1549063157000 ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1143,7 +1143,7 @@ function update_content_post() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_content', $post_properties); } @@ -1154,12 +1154,12 @@ function update_content_profile() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'profile-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $profile object '$profile' => array( '$body' => 'Hi! My name is Alex and I just moved to New London!', @@ -1184,7 +1184,7 @@ function update_content_profile() 'Long-term dating' ) ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1192,7 +1192,7 @@ function update_content_profile() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_content', $profile_properties); } @@ -1203,12 +1203,12 @@ function update_content_review() // Required fields '$user_id' => $GLOBALS['user_id'], '$content_id' => 'review-23412', - + // Recommended fields '$session_id' => 'a234ksjfgn435sfg', '$status' => '$active', '$ip' => '255.255.255.0', - + // Required $review object '$review' => array( '$subject' => 'Amazing Tacos!', @@ -1232,7 +1232,7 @@ function update_content_review() ), '$rating' => 4.5 ), - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1240,7 +1240,7 @@ function update_content_review() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_content', $review_properties); } @@ -1251,7 +1251,7 @@ function update_order() // Required Fields '$user_id' => $GLOBALS['user_id'], // Supported Fields - '$session_id' => 'gigtleqddo84l8cm15qe4il', + '$session_id' => $GLOBALS['session_id'], '$order_id' => 'ORDER-28168441', '$user_email' => $GLOBALS['user_email'], '$amount' => 115940000, // $115.94 @@ -1334,7 +1334,7 @@ function update_order() ), // For marketplaces, use $seller_user_id to identify the seller '$seller_user_id' => 'slinkys_emporium', - + '$promotions' => array( array( '$promotion_id' => 'FirstTimeBuyer', @@ -1347,13 +1347,13 @@ function update_order() ) ) ), - + // Sample Custom Fields 'digital_wallet' => 'apple_pay', // 'google_wallet', etc. 'coupon_code' => 'dollarMadness', 'shipping_choice' => 'FedEx Ground Courier', 'is_first_time_buyer' => False, - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1361,7 +1361,7 @@ function update_order() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_order', $properties); } @@ -1375,7 +1375,7 @@ function update_password() '$status' => '$success', '$reason' => '$forced_reset', '$ip' => '128.148.1.135', // IP of the user that entered the new password after the old password was reset - + // Send this information from a BROWSER client. '$browser' => array( '$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', @@ -1383,7 +1383,7 @@ function update_password() '$content_language' => 'en-GB' ) ); - + return $this->client->track('$update_password', $properties); } @@ -1393,7 +1393,7 @@ function verification() $properties = array( // Required Fields '$user_id' => $GLOBALS['user_id'], - '$session_id' => 'gigtleqddo84l8cm15qe4il', + '$session_id' => $GLOBALS['session_id'], '$status' => '$pending', // Optional fields if applicable diff --git a/test_integration_app/globals.php b/test_integration_app/globals.php index 6ccd8da..51f50c1 100644 --- a/test_integration_app/globals.php +++ b/test_integration_app/globals.php @@ -1,5 +1,6 @@ diff --git a/test_integration_app/main.php b/test_integration_app/main.php index 5241c12..8427753 100644 --- a/test_integration_app/main.php +++ b/test_integration_app/main.php @@ -50,7 +50,7 @@ public function test_all_methods(){ $this->assertEquals(1, $objUtil->isOk($objEvents->update_order())); $this->assertEquals(1, $objUtil->isOk($objEvents->update_password())); $this->assertEquals(1, $objUtil->isOk($objEvents->verification())); - print("Events API Tested"); + print("Events API Tested \n"); // Decisions API $this->assertEquals(1, $objUtil->isOk($objDecisions->getUserDecisions())); @@ -58,32 +58,33 @@ public function test_all_methods(){ $this->assertEquals(1, $objUtil->isOk($objDecisions->getContentDecisions())); $this->assertEquals(1, $objUtil->isOk($objDecisions->getSessionDecisions())); $this->assertEquals(1, $objUtil->isOk($objDecisions->getDecisions())); - $this->assertEquals(0, $objUtil->isOk($objDecisions->apply_decision_to_user())); - $this->assertEquals(0, $objUtil->isOk($objDecisions->apply_decision_to_order())); - $this->assertEquals(0, $objUtil->isOk($objDecisions->apply_decision_to_session())); - $this->assertEquals(0, $objUtil->isOk($objDecisions->apply_decision_to_content())); - print("Decision API Tested"); + $this->assertEquals(1, $objUtil->isOk($objDecisions->apply_decision_to_user())); + $this->assertEquals(1, $objUtil->isOk($objDecisions->apply_decision_to_order())); + $this->assertEquals(1, $objUtil->isOk($objDecisions->apply_decision_to_session())); + $this->assertEquals(1, $objUtil->isOk($objDecisions->apply_decision_to_content())); + print("Decision API Tested \n"); // Wrokflows API $this->assertEquals(1, $objUtil->isOk($objWorkflows->synchronous_workflows())); - print("Workflow API Tested"); - + print("Workflow API Tested \n"); + // Score API - $this->assertEquals(0, $objUtil->isOk($objScore->user_score())); - print("Score API Tested"); + $this->assertEquals(1, $objUtil->isOk($objScore->user_score())); + print("Score API Tested \n"); // Verification API $this->assertEquals(1, $objUtil->isOk($objVerification->send())); $this->assertEquals(1, $objUtil->isOk($objVerification->resend())); $this->assertEquals(1, $objUtil->isOkCheck($objVerification->check())); - print("Verification API Tested"); + print("Verification API Tested \n"); // PSP Merchant Management API - $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->create_merchant())); - $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->update_merchant())); + $merchant_id = "merchant_id_test_sift_php_".strval(floor(microtime(true) * 1000)); + $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->create_merchant($merchant_id))); + $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->update_merchant($merchant_id))); $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->get_all_merchants())); - $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->get_merchant())); - print("PSP Merchant API Tested"); + $this->assertEquals(1, $objUtil->isOk($objPSPMerchant->get_merchant($merchant_id))); + print("PSP Merchant API Tested \n"); } } diff --git a/test_integration_app/psp_merchant_api/test_psp_merchant_api.php b/test_integration_app/psp_merchant_api/test_psp_merchant_api.php index d6011bd..5c9f43f 100644 --- a/test_integration_app/psp_merchant_api/test_psp_merchant_api.php +++ b/test_integration_app/psp_merchant_api/test_psp_merchant_api.php @@ -4,14 +4,13 @@ class test_psp_merchant_api private $client; function __construct() { - $this->client = new SiftClient(array('api_key' => getenv("api_key"), 'account_id' => getenv("account_id"))); + $this->client = new SiftClient(array('api_key' => getenv("API_KEY"), 'account_id' => getenv("ACCOUNT_ID"))); } - function create_merchant() + function create_merchant($merchant_id) { - $merchant_id = rand(1, 1000000); $merchantObject = array( - 'id' => "merchant-id-php-".$merchant_id, + 'id' => $merchant_id, 'name' => "Watson and Holmes", 'description' => "An example of a PSP Merchant. Illustrative.", 'address'=> array( @@ -35,10 +34,10 @@ function create_merchant() return $this->client->postMerchant($merchantObject); } - function update_merchant() + function update_merchant($merchant_id) { $merchantObject = array( - 'id' => "merchant-id-php-0002", + 'id' => $merchant_id, 'name' => "Watson and Holmes updated", 'description' => "An example of a PSP Merchant. Illustrative.", 'address'=> array( @@ -59,12 +58,12 @@ function update_merchant() 'score' => 10 ) ); - return $this->client->putMerchant("merchant-id-php-0002", $merchantObject); + return $this->client->putMerchant($merchant_id, $merchantObject); } - function get_merchant() - { - return $this->client->getMerchant("merchant-id-php-0001");; + function get_merchant($merchant_id) + { + return $this->client->getMerchant($merchant_id); } function get_all_merchants() diff --git a/test_integration_app/score_api/test_score_api.php b/test_integration_app/score_api/test_score_api.php index 101a0af..91a10f1 100644 --- a/test_integration_app/score_api/test_score_api.php +++ b/test_integration_app/score_api/test_score_api.php @@ -4,7 +4,7 @@ class test_score_api private $client; function __construct() { - $this->client = new SiftClient(array('api_key' => getenv("api_key"), 'account_id' => getenv("account_id"))); + $this->client = new SiftClient(array('api_key' => getenv("API_KEY"), 'account_id' => getenv("ACCOUNT_ID"))); } function user_score() diff --git a/test_integration_app/verifications_api/test_verification_api.php b/test_integration_app/verifications_api/test_verification_api.php index 40fa56e..b0856bb 100644 --- a/test_integration_app/verifications_api/test_verification_api.php +++ b/test_integration_app/verifications_api/test_verification_api.php @@ -4,7 +4,7 @@ class test_verification_api private $client; function __construct() { - $this->client = new SiftClient(array('api_key' => getenv("api_key"))); + $this->client = new SiftClient(array('api_key' => getenv("API_KEY"))); } function send() diff --git a/test_integration_app/workflows_api/test_workflows_api.php b/test_integration_app/workflows_api/test_workflows_api.php index 54d1c7c..bf77ce1 100644 --- a/test_integration_app/workflows_api/test_workflows_api.php +++ b/test_integration_app/workflows_api/test_workflows_api.php @@ -4,7 +4,7 @@ class test_workflows_api private $client; function __construct() { - $this->client = new SiftClient(array('api_key' => getenv("api_key"), 'account_id' => getenv("account_id"))); + $this->client = new SiftClient(array('api_key' => getenv("API_KEY"), 'account_id' => getenv("ACCOUNT_ID"))); } function synchronous_workflows()