-
Notifications
You must be signed in to change notification settings - Fork 4
Performing a Payment
ofetisov edited this page Aug 12, 2016
·
12 revisions
To make a new payment with full card details:
$payment = $judopay->getModel('Payment');
$payment->setAttributeValues(
array(
'judoId' => 'your_judo_id',
'yourConsumerReference' => '12345',
'yourPaymentReference' => '12345',
'amount' => 1.01,
'currency' => 'GBP',
'cardNumber' => '4976000000003436',
'expiryDate' => '12/15',
'cv2' => 452
)
);You can check on the required fields and the format of each field in the Judopay REST API reference. To send the request to the API, call:
$response = $payment->create();If the payment is successful, you'll receive a response array like this:
Array
(
[receiptId] => 520882
[type] => Payment
[createdAt] => 2014-08-18T16:28:39.6164+01:00
[result] => Success
[message] => AuthCode: 476590
[judoId] => 100978394
[merchantName] => Joe Bloggs
[appearsOnStatementAs] => JudoPay/JoeBlo
[originalAmount] => 1.01
[netAmount] => 1.01
[amount] => 1.01
[currency] => GBP
[cardDetails] => Array
(
[cardLastfour] => 3436
[endDate] => 1215
[cardToken] => mw51OLKsXxm0J49qb5uVj6KJGNOgledk
[cardType] => 1
)
[consumer] => Array
(
[consumerToken] => n1uLVW6OirKhR693
[yourConsumerReference] => 12345
)
[yourPaymentReference] => 12345
)Your code will look like that. Also important to handle different exceptions in your code. See more details in our Error handling section.
$response = $payment->create();
if ($response['result'] === 'Success') {
echo 'Payment succesful';
} else {
echo 'There were some problems while processing your payment';
}