PHP code example of michelmelo / payments-gateway
1. Go to this page and download the library: Download michelmelo/payments-gateway library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
michelmelo / payments-gateway example snippets
use MichelMelo\PaymentGateway\PaymentGateway;
$paymentGateway = new PaymentGateway(
'your-bearer-token',
'your-client-id',
'your-terminal-id',
'PURS', // ou 'AUTH'
'https://api.paymentgateway.com'
);
$customer = [
'customerInfo' => [
'customerName' => 'John Smith',
'customerEmail' => '[email protected] ',
'customerPhone' => '+351-912345678',
'shippingAddress' => [
'street1' => 'Shipping street1',
'street2' => 'Shipping street2',
'city' => 'Lisbon',
'postcode' => '1700-123',
'country' => 'PT',
],
'billingAddress' => [
'street1' => 'Billing street1',
'street2' => 'Billing street2',
'city' => 'Lisbon',
'postcode' => '1700-123',
'country' => 'PT',
],
],
];
$data = [
'amount' => 10.00,
'currency' => 'EUR',
];
$response = $paymentGateway->processPayment('mbway', $data, $customer);
use MichelMelo\PaymentGateway\Helpers\PaymentWidget;
echo PaymentWidget::widget($response['transactionId'], 'https://example.com');
echo PaymentWidget::form('checkout', '{"key":"value"}');
$customer = [
'customerInfo' => [
'customerName' => 'John Smith',
'customerEmail' => '[email protected] ',
'customerPhone' => '+351-912345678',
'shippingAddress' => [
'street1' => 'Shipping street1',
'street2' => 'Shipping street2',
'city' => 'Lisbon',
'postcode' => '1700-123',
'country' => 'PT',
],
'billingAddress' => [
'street1' => 'Billing street1',
'street2' => 'Billing street2',
'city' => 'Lisbon',
'postcode' => '1700-123',
'country' => 'PT',
],
],
];
$data = [
'entity' => '12345',
'reference' => '123456789',
'amount' => 10.00,
];
$response = $paymentGateway->processPayment('multibanco', $data, $customer);
$data = [
'card_number' => '4111111111111111',
'expiry_date' => '12/25',
'cvv' => '123',
'amount' => 10.00,
];
$response = $paymentGateway->processPayment('card', $data);
$data = [
'xpay_token' => 'your-xpay-token',
'amount' => 10.00,
];
$response = $paymentGateway->processPayment('xpay', $data);
$data = [
'blik_code' => '123456',
'amount' => 10.00,
];
$response = $paymentGateway->processPayment('blik', $data);
$data = [
'email' => '[email protected] ',
'amount' => 10.00,
];
$response = $paymentGateway->processPayment('paybylink', $data);
use MichelMelo\PaymentGateway\Exceptions\PaymentException;
try {
$response = $paymentGateway->processPayment('mbway', $data);
echo "Pagamento processado com sucesso!";
} catch (PaymentException $e) {
echo "Erro ao processar pagamento: " . $e->getMessage();
}