-
Notifications
You must be signed in to change notification settings - Fork 1
/
qa-donations-payzone-process.php
55 lines (50 loc) · 2.01 KB
/
qa-donations-payzone-process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
class qa_donations_payzone_process
{
const CONNECT_GATEWAY = 'https://paiement.payzone.ma';
function match_request($request)
{
$parts = explode('/', $request);
return $parts[0] == 'process-donation';
}
function process_request($request)
{
require_once 'Connect2PayClient.php';
$connect2pay = 'https://paiement.payzone.ma';
$merchant = qa_opt('payzone_merchant_id');
$password = qa_opt('payzone_merchant_password');
/*
* Initialize the payment using the class Connect2PayClient.php
* */
$c2pClient = new Connect2PayClient($connect2pay, $merchant, $password);
if ($c2pClient->handleCallbackStatus()) {
// Get the Error code
$status = $c2pClient->getStatus();
// The payment status code
$errorCode = $status->getErrorCode();
// Custom data that could have been provided in ctrlCustomData when creating
// the payment
$merchantData = $status->getCtrlCustomData();
// The transaction ID generated for this payment
$transactionId = $status->getTransactionID();
// The unique token, known only by the payment page and the merchant
$merchantToken = $status->getMerchantToken();
$selectspec=array(
'columns' => array('code'),
'source' => '^donators WHERE code=$',
'arguments' => array($merchantToken),
);
$existDonation = qa_db_single_select($selectspec);
if (!empty($existDonation)){
if ($errorCode == '000') {
qa_db_query_sub(
'UPDATE ^donators SET status=1 WHERE code=$',
$merchantToken
);
// If we reach this part of the code the payment succeeded
// Do the required stuff to validate the payment in the application
}
}
}
}
}