fraganzas/omnipago

euPago integration in omnipay

dev-master 2023-10-10 23:20 UTC

This package is auto-updated.

Last update: 2024-05-11 00:40:46 UTC


README

This is the euPago solution for omnipay payment processing library

Eupago is one Portuguese payment gateway that has multiple methods available. To use it you need create one account in euPago website. Once installed and configured you are able to use all the features of our API.

Instalation

composer require league/omnipay:^3 fraganzas/omnipay

Implemented Payment Methods

  • Multibanco - Create MB references with and without start/end date, minimum/maximum amount support (just set the respective parameters)
  • MBWay - MBWay payment system
  • PayShop
  • Pagaqui

Examples

Create Multibanco reference

$gateway = Omnipay::create('Eupago_Multibanco');

// required fields
$gateway->setApiKey('xxx-xxx-xxx-xxx');
$gateway->setCurrency('EUR');
$gateway->setTransactionId('xxxxx');
// Optionally with start/end date
$gateway->setStartDate(new \DateTime);
$gateway->setEndDate((new \DateTime)->modify('48 hours'));

$response = $gateway->purchase(['amount' => '10.00'])->send();

if ($response->isSuccessful()) {
	// return the euPago api response with payment credentials
	// see src/Message/MultibancoResponse.php methods for more information
	$paymentData = $response->getData();

	// return the Transaction Reference
	// the transaction Reference is required for call the status of payment, you should store them in your "orders" table related database
	$referenceId = $response->getTransactionReference();
} else {
    // Transaction creation failed: display message to customer
    echo $response->getMessage();
}

Check Multibanco reference status

$gateway = Omnipay::create('Eupago_Multibanco');

// The transaction reference is required
$paymentStatus = $gateway->checkStatus([
	'transactionReference' => 'xxxxxx'
])->send();

if ($paymentStatus->isPaid()) {
    // payment was successful: update database
} else {
    // payment failed: display message to customer
    echo $paymentStatus->getMessage();
}

Create MBWay Reference

$gateway = Omnipay::create('Eupago_MBWay');

// Campos obrigatórios
$gateway->setApiKey('xxxx-xxxx-xxx-xxx'); //ver aqui: replica.eupago.pt/clientes/contas/fichas
$gateway->setCurrency('EUR');
$gateway->setTransactionId('1');
$gateway->setAlias('910000000'); //número tlm cliente
// Campos opcionais
$gateway->setStartDate(new \DateTime);
$gateway->setEndDate((new \DateTime)->modify('48 hours')); //limite

$response = $gateway->purchase(['amount' => '10.00'])->send();

if ($response->isSuccessful()) {
// return the euPago api response with payment credentials
// see src/Message/MultibancoResponse.php methods for more information
$paymentData = $response->getData();

// return the Transaction Reference
// the transaction Reference is required for call the status of payment, you should store them in your "orders" table related database
$referenceId = $response->getTransactionReference();

//Exemplo de resposta bem sucedida
/*
+"sucesso": true
+"referencia": "xxxx"
+"valor": 10.0
+"estado": 0
+"resposta": "OK"
+"alias": "351#910000000"
*/

} 
else {
// Transaction creation failed: display message to customer
echo $response->getMessage();
}

```

Check Multibanco reference status

$gateway = Omnipay::create('Eupago_MBWay');

// The transaction reference is required
$paymentStatus = $gateway->checkStatus([
'transactionReference' => $request->referenceID
])->send();

if ($paymentStatus->isPaid()) {
//Referência paga
} else {
/*
 * Valor de "$paymentStatus->getMessage();" pode ser:
 * "OK" : Referência existe mas não está pago
 * "Referência Inexistente." : Referência não existe.
 */
echo $paymentStatus->getMessage();
}