PHP code example of judopay / judopay-sdk
1. Go to this page and download the library: Download judopay/judopay-sdk 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/ */
judopay / judopay-sdk example snippets
$judopay = new Judopay(
array(
'apiToken' => 'your-token',
'apiSecret' => 'your-secret',
'judoId' => 'your-judo-id'
)
);
$payment = $judopay->getModel('Payment');
$payment->setAttributeValues(
array(
'judoId' => 'your_judo_id',
'yourConsumerReference' => '12345',
'yourPaymentReference' => '12345',
'amount' => 1.01,
'currency' => 'GBP',
'cardNumber' => '4976000000003436',
'expiryDate' => '12/25',
'cv2' => 452
)
);
$payment = $judopay->getModel('Payment');
$payment->setAttributeValues(
array(
'judoId' => 'your_judo_id',
'yourConsumerReference' => '12345',
'yourPaymentReference' => '12345',
'amount' => 1.01,
'currency' => 'GBP',
'cardNumber' => '4976000000003436',
'expiryDate' => '12/25',
'cv2' => 452,
'cardAddress' => array('address1' => '1 Market Street', 'postCode' => 'E20 6PQ', 'countryCode' => 826)
)
);
$response = $payment->create();
Array
(
[receiptId] => 520882
[type] => Payment
[createdAt] => 2014-08-18T16:28:39.6164+01:00
[result] => Success
...
[amount] => 10.00
...
[yourPaymentReference] => 12345
)
try {
$response = $payment->create();
if ($response['result'] === 'Success') {
echo 'Payment successful';
} else {
echo 'There were some problems while processing your payment';
}
} catch (JudopayExceptionValidationError $e) {
echo $e->getSummary();
} catch (JudopayExceptionApiException $e) {
echo $e->getSummary();
} catch (Exception $e) {
echo $e->getMessage();
}