
Code the EGW API library:  add credits; redeem credits; webhook processing

Move EGW webhook processing in the slave servers



/*

"game_id":"<x...x>",				// optional?

"game_name":"<x...x>",				// optional?
"game_username":"<x...x>"			// optional?
	
game_id
	
game_name		used to form response text message, should be looked up from the dbase tables, not supplied by the caller.
game_username	
		
--------------------------------------------------------------------------------
		
NOT USED

ep_main . ember_games
1	record					int
2	game_name				varchar(30)
		
--------------------------------------------------------------------------------

ep_main . egw_games
		
1	record Primary			int
2	game_name				varchar(30)
		
you would think this would include a game_id
		
--------------------------------------------------------------------------------
questions:

1) In the emberpayRfP api, I am trying to understand why the gaming parameters (game_id, game_distributor_id, game_name, game_username) are optional on the input. 
It looks to me that they would be absolutely required for this system, but the existing code is written to allow them to be omitted. 

A: required (as needed?)

2) Where do game_id values originate? who/what generates them?
--are game_id values unique to the distributor, (same game from two different distributors would have different game_id's)
--or are game_id values unique to the EGW api definitions (directly/indirectly from the game vendors)
--or are we generating them as globally unique values?

A: game_id values are given to us by the distributor when we onboard them, and their games
B:  Until I get the complete Spec from EGW, I am not 100% sure.  I believe a game_id is the same for all distributors


in ep_main.channel_partner_games, what is the difference between partner_id and game_distributor_id?
		
player games?  which games or distributors is the player signed up for?
*/

================================================================================
Guide to EGW data values
================================================================================

"operator_wallet_id": "1231",
"operator_wallet_id" – is the merchants/game operators id in your system. This can be what ever you want it to be.
*** use partner_id (channel_partner_id, distributor_id)

"player_wallet_id":  "123",
"player_wallet_id" is the players operators id in your system. This can be whatever you want it to be.
*** use subscribers.card_number

"operator_game_id": 42,
"operator_game_id” is our internal id for each merchants/game operators game platform they have registered. We will provide this to you.
*** comes from player game registration process

"player_game_user_id": 123
"player_game_user_id" is the players login id for the game platform they selected. The player will provide this to you and you will in turn provide to us.
*** comes from player game registration process

"operator_id": "0f6d7d8a-7e9a-4d95-9f73-5f7d9b8327a1",
identifies distributor/channel partner in egw system

"payment_provider_id": "ember",
"amount": "10.00",
  

embrpay.net/textalerts_api/process_distributor_redemption_response.php

line 62 in the spreadsheet -- duh

--------------------------------------------------------------------------------

subscribed_games -- games to which a player is subscribed.

record					int				table record id
group_number			varchar(10)		communities table key -- varchar(10) there
subscriber_id			int				subscribers table key -- local player id
phone_number			varchar(20)		subscribers table key -- local player id -- length changed from 16 to 20
partner_id				varchar(20)		partner_id of channel partner -- local distributor_id (new column)

game_distributor_id		varchar(20)		egw operator_id - this is passed in through the sigup link/qrcode
										comes from gaming company originally
										assuming that egw uses the same code internally and that this is their operator_id (IS THIS A VALID ASSUMPTION)

game_id					varchar(20)		egw operator_game_id
game_name				varchar(50)		egw display_name
game_username			varchar(20)		egw player_game_user_id -- comes from user input
game_password			varchar(20)		password for game account access, comes from user input (possible addition?)
created					datetime		

--------------------------------------------------------------------------------

channel_partner_games
​
record					int
group_number			varchar(10)		communities table key -- varchar(10) there
partner_id				varchar(20)
game_distributor_id		varchar(20)
game_id					varchar(20)
game_name				varchar(50)
enable_ledger_deposit	char(1)
enable_ledger_redeem	char(1)
created					datetime

--------------------------------------------------------------------------------

	Wait for Trice webhooks to determine outcome of RfP (actually, no. respond in sync, or async mode)

	If RfP is successful
	rfp webhook status == completed for emberRfp (source == 'E')
{
		If "enable_ledger_deposit" = "Y" for that game
			Ember uses the EGW API to load game credits
				Record EGW session_id found in API response																			
				Wait for EGW webhook with session_id																			
				Message both the Player and Distributor "Payment was made and credits were added"																			
		Else, we message the Distributor to add credits manually																					
			Message both the Player and Distributor																				
}

	Else if RfP fails
		emberRfpFailure - trice sendRFP call returns error
		emberRfpFailure - trice sendRFP webhooks report failure
{
		Message both the Player and Distributor with failure message
}

--------------------------------------------------------------------------------

Files changed:
redeemEmberpayPlayer.php
emberpayRfP.php
process_distributor_redemption_response.php



redeemEmberpayPlayer --> send sms message --> distributorYesResponse --> rtpSend --> rtpSuccess --> egw->redeem --> egwRedeemSuccess / egwRedeemFailure
	distributorNoResponse
	distributorTimeoutResponse







05/18/2026 16:43:12 EDT - 68.132.120.2 - 2161035 - SendRequest: json_response = '{"account_number":"2610568277","business":{"address":{"city":"Tampa","country":"US","line1":"3140 N Armenia Ave","line2":"STE 2","state":"FL","zip":"33607"},"business_dba":"Future 6","business_name":"Future 6 Helping Hand Fund","formation_state":"FL","phone":{"country_code":"1","number":"8135395564"},"tax_id_provided":true,"verification":{}},"business_profile":{"estimated_monthly_volumes_provided":true,"naics":"813410","name":"Future 6","product_description":"distribution of payments","url":"https:\\/\\/www.f6helpinghand.org\\/"},"business_type":"company","capabilities":{"aggregator":"inactive","monit… 21:05:38.930189","email":"info@f6helpinghand.org","hold_details":null,"id":"88007eb2-5dc4-11f0-a3a9-a2cf1d3a5109","individual":null,"ip_address_allow_list":["44.241.134.243","44.195.133.182","44.226.114.221"],"notes":[],"status":"ok","tos_acceptance":null,"updated":"2025-07-22 18:18:56.797052","verified_for":[{"bank_id":"gnb","bank_name":"Great North Bank","verified":"2025-07-22 18:18:56"}]}'



05/18/2026 16:43:10 EDT - 68.132.120.2 - 2161035 - TriceApi ( array (
  'groupId' => '2',
  'selectorId' => '22',
  'merchantId' => '',
  'gateway_code' => '15',
  'gateway_name' => 'trice',
  'gateway_mode' => 'live',
  'gateway_services' => 'rtp',
  'record_id' => '34',
  'country_code' => 'US',
  'currency_code' => 'USD',
  'account_id' => '14cc2d6c-007e-11f1-a666-875524d58a6f',
  'client_id' => '88fa3f88-5dc4-11f0-aeba-df3ceec389bf',
  'client_secret' => 'f7t33E6E8wDJztcf',
  'access_token' => 'eyJraWQiOiJhMmNiNzUxZi00MjdiLTQ4MmQtYTg0MS1jMjVkYTg5OWViMDciLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJjbGllbnQ6ODhmYTNmODgtNWRjNC0xMWYwLWFlYmEtZGYzY2VlYzM4OWJmIiwiYXVkIjoiaHR0cHM6Ly9hcGkudHJpY2UuY28iLCJhY2NvdW50SWQiOiI4ODAwN2ViMi01ZGM0LTExZjAtYTNhOS1hMmNmMWQzYTUxMDkiLCJuYmYiOjE3NzEwMTY2ODQsInNjb3BlIjpbInJ0cC5yZnBfc2VuZGVyIiwicnRwLnNlbmRlciJdLCJpc3MiOiJodHRwczovL2FwaS50cmljZS5jby9hdXRoL3YxIiwiZXhwIjoxNzcxMDQ1NDg0LCJpYXQiOjE3NzEwMTY2ODQsImp0aSI6IjE3YTE4ZGUyLWZmOWMtNGQ1ZS04MzY1LTg0NmY4YjA2YWVmYiJ9.rFihi5BVEK8QtDA_5gyeo0o4kNeyOB5oviG2hJjPKTu7u9bC0y8UQid5biS9IKgh3FdkoQr-kOxqctTcrCg3sWZ4gBlChzZ9jsnMEDNdwkdtFjh346ncwBf8Do0cHYn2VTfdLNd0UmHxh-O5ee383qz_kaRzQACUDWXDDMfjyZ6IZCjPpSHpiuvxK1ObAoqoa71c-IqE-Tdf3PLJWFRlH1DhpZ10G-AAoMfUybUld8Ageu1oQ2D19hR5E9adKfZuR80zMRqnn0I-JRX-vWVzhWqW8M9CBMubzUeGjjbPvPJXIdpAQVN-ITtAU1zrCy2lNtecLfO0meL3NGqBHrL5-Q',
  'token_type' => 'Bearer',
  'expires_at' => '1771045483',
  'value_1' => '',
  'value_2' => '',
  'value_3' => '',
  'value_4' => '',
  'value_5' => '',
) )


createOperator

05/19/2026 15:54:00 EDT - 74.110.227.200 - post response decoded = array (
  'operator_id' => '29de67f1-f666-4aba-ad9f-6b4c13f754a2',
  'username' => 'operator_test_01',
)


Step 1: You send a Operator registration request and we create an Operator.
Step 2: We send a email to Operator to login and setup an operator games. Each game got a game_id.

Please use predefined Operator id: 
73b83a81-0293-45ae-99ba-bdd7f3555aa4
we already setup all games for it.


05/20/2026 09:47:54 EDT - 74.110.227.200 - get response decoded = array (
  0 => 
  array (
    'game_id' => 'c054e606-8778-49d7-b519-edfccb899b25',
    'name' => 'Dragon City',
    'game_pos_url_box' => 'https://pos.goldendragon.city/login/9521499',
    'status' => 'active',
  ),
  1 => 
  array (
    'game_id' => '2f4776d5-a091-4058-a13f-42e715f00ca8',
    'name' => 'Fortune 2 go',
    'game_pos_url_box' => 'https://pos2.fortune2go20.com/pos/index-fortune2go.html?k=undefined',
    'status' => 'active',
  ),
  2 => 
  array (
    'game_id' => '92d9a074-3a27-463a-9255-b8ba671df802',
    'name' => 'Golden Dragon',
    'game_pos_url_box' => 'https://pos.goldendragoncity.com/pos/2636393',
    'status' => 'active',
  ),
  3 => 
  array (
    'game_id' => '822b6efa-1e8c-466f-a8a8-a850512784cb',
    'name' => 'Magic City',
    'game_pos_url_box' => 'https://pos.magiccity777.com/pos/login',
    'status' => 'active',
  ),
  4 => 
  array (
    'game_id' => 'e3d253f9-903d-4f1b-aeb4-5063697eff51',
    'name' => 'River Sweeps',
    'game_pos_url_box' => 'https://river-pay.com/office/login',
    'status' => 'active',
  ),
  5 => 
  array (
    'game_id' => '184aee6c-deca-4de1-bcee-fdc8af792cc1',
    'name' => 'Ultra Panda',
    'game_pos_url_box' => 'https://ht.ultrapanda.mobi/',
    'status' => 'active',
  ),
)




payment_tracking_2 -- copy structure only

payment_rules_2 -- copied structure and data

payment_fraud_events_2 -- copy structure only

