PHP code example of birkof / netopia-mobilpay-bundle
1. Go to this page and download the library: Download birkof/netopia-mobilpay-bundle 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/ */
use birkof\NetopiaMobilPay\Exception\NetopiaMobilPayException;
use birkof\NetopiaMobilPay\Notification\NetopiaMobilPayIpnHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
public function ipn(Request $request, NetopiaMobilPayIpnHandlerInterface $ipn): Response
{
try {
$result = $ipn->decrypt(
(string) $request->request->get('env_key'),
(string) $request->request->get('data'),
$request->request->get('cipher'), // null for legacy RC4 payloads
$request->request->get('iv'), // null for legacy RC4 payloads
);
} catch (NetopiaMobilPayException $e) {
// transient failure on our side → ask Netopia to retry
return new Response(
$ipn->errorResponse('cannot process', $ipn::ERROR_TYPE_TEMPORARY),
200, ['Content-Type' => 'application/xml'],
);
}
if ($result->isConfirmed()) {
// SECURITY: decrypt() proves the sender is Netopia, NOT the amount.
// Load the order by $result->purchaseId and confirm $result->processedAmount
// matches what you expected BEFORE marking it paid.
}
return new Response(
$ipn->confirmResponse(),
200, ['Content-Type' => 'application/xml'],
);
}
public function __construct(
private NetopiaMobilPayServiceInterface $payments, // outbound
private NetopiaMobilPayIpnHandlerInterface $ipn, // inbound
) {}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.