Payment Notification Updated on 10-03-2017

Workflow of Multibanco, Credit card and Bank Transfer payments notification implementation.

1 - easypay call your URL

When a payment is made, easypay call your "Url de Notificação" / "Notification URL".
You can configure this URL on easypay's backoffice under "URL Configurations"

Example URL

http://www.yoursite.com/your/notification_url.php?ep_cin=9999&ep_user=USER010101&ep_doc=TESTE2515860102158412061588102125

Parameters

ep_cin CIN of the payment received.
Example value: 9999
ep_user USER of the payment received.
Example value: USER010101
ep_doc Document Number of the payment received.
Example value: TESTE2515860102158412061588102125
If the funds are transferred by the acquirer
ep_type Acquirer used for this transaction.
Example value: credorax

2 - Populate your notifications table

You need to have a table where you can store all the information about each payment.

Notifications table

CREATE TABLE `easypay_notifications` (
      `ep_key` int(11) NOT NULL auto_increment,
      `ep_doc` varchar(50) default NULL,
      `ep_cin` varchar(20) default NULL,
      `ep_user` varchar(20) default NULL,
      `ep_status` varchar(20) default 'pending',
      `ep_entity` varchar(10) default NULL,
      `ep_reference` varchar(9) default NULL,
      `ep_value` double default NULL,
      `ep_date` datetime default NULL,
      `ep_payment_type` varchar(10) default NULL,
      `ep_value_fixed` double default NULL,
      `ep_value_var` double default NULL,
      `ep_value_tax` double default NULL,
      `ep_value_transf` double default NULL,
      `ep_date_transf` date default NULL,
      `t_key` varchar(255) default NULL,
      `notification_date` timestamp NULL default CURRENT_TIMESTAMP,
      `ep_type` varchar(15) default NULL,
PRIMARY KEY (`ep_key`),
UNIQUE KEY `ep_doc` (`ep_doc`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Now, with the parameters received you have to add a record to easypay_notifications table and fetch the ep_key generated.
The ep_type may or may not be sent, you need to take precautions, if we send ep_type, you'll need it later, if not, there is no need to save or use it.

Insert query

INSERT INTO `easypay_notifications` (`ep_doc`, `ep_cin`, `ep_user`, `ep_type`)
  VALUES ('TESTE2515860102158412061588102125', '9999', 'USER010101', 'credorax');

3 - Give us some feedback

Once you have saved the data into your database, you'll need to build and return the following XML as a responce:


  ok0
  generated document
  9999
  USER010101
  TESTE2515860102158412061588102125
  5

4 - Fetch payment detail and populate the missing fields

Call api_easypay_03AG.php with the data from the record inserted

https://www.easypay.pt/_s/api_easypay_03AG.php?ep_cin=9999&ep_user=USER010101&ep_doc=TESTE2515860102158412061588102125&ep_key=5
http://test.easypay.pt/_s/api_easypay_03AG.php?ep_cin=9999&ep_user=USER010101&ep_doc=TESTE2515860102158412061588102125&ep_key=5
Update the record on easypay_notifications and mark your order as payed.
UPDATE `easypay_notifications` SET
      `ep_status` = 'processed',
      `ep_entity` = '10611',
      `ep_reference` = '999907994',
      `ep_value` = '15.25',
      `ep_date` = '2012-01-01 10:00:00',
      `ep_payment_type` = 'MB',
      `ep_value_fixed` = '0.30',
      `ep_value_var` = '3.4',
      `ep_value_tax` = '2.03',
      `ep_value_transf` = '10',
      `ep_date_transf` = '2012-01-02',
      `t_key` = '3'
  WHERE `ep_doc` = 'TESTE2515860102158412061588102125';