public function fromJson($responseData) { $paymentCompleteResponse = new PaymentCompleteResponse(); $paymentCompleteResponse->setClientId($responseData[responseData][clientId]); $paymentCompleteResponse->setClientIdHash($responseData[responseData][clientIdHash]); $paymentCompleteResponse->setTransactionType($responseData[responseData][transactionType]); $creditCard = new CreditCard(); $creditCard->setType($responseData[responseData][creditCard][type]); $creditCard->setHolderName($responseData[responseData][creditCard][holderName]); $creditCard->setNumber($responseData[responseData][creditCard][number]); $creditCard->setExpiry($responseData[responseData][creditCard][expiry]); $paymentCompleteResponse->setCreditCard($creditCard); $transactionAmount = new TransactionAmount(); $transactionAmount->setTotalAmount($responseData[responseData][transactionAmount][totalAmount]); $transactionAmount->setPaymentAmount($responseData[responseData][transactionAmount][paymentAmount]); $transactionAmount->setServiceFeeAmount($responseData[responseData][transactionAmount][serviceFeeAmount]); $transactionAmount->setWithholdingAmount($responseData[responseData][transactionAmount][withholdingAmount]); $transactionAmount->setCurrency($responseData[responseData][transactionAmount][currency]); $paymentCompleteResponse->setTransactionAmount($transactionAmount); $paymentCompleteResponse->setClientRef($responseData[responseData][clientRef]); $paymentCompleteResponse->setComment($responseData[responseData][comment]); $paymentCompleteResponse->setTxnReference($responseData[responseData][txnReference]); $paymentCompleteResponse->setFeeReference($responseData[responseData][feeReference]); $paymentCompleteResponse->setResponseCode($responseData[responseData][responseCode]); $paymentCompleteResponse->setResponseText($responseData[responseData][responseText]); $paymentCompleteResponse->setSettlementDate($responseData[responseData][settlementDate]); $paymentCompleteResponse->setToken($responseData[responseData][token]); $paymentCompleteResponse->setTokenized($responseData[responseData][tokenized]); $paymentCompleteResponse->setTokenResponseText($responseData[responseData][tokenResponseText]); $paymentCompleteResponse->setAuthCode($responseData[responseData][authCode]); $paymentCompleteResponse->setCvcResponse($responseData[responseData][cvcResponse]); return $paymentCompleteResponse; }
/* ------------------------------------------------------------------------------ STEP3: Build PaymentRealTimeRequest object ------------------------------------------------------------------------------ */ $realTimeRequest = new PaymentRealTimeRequest(); $realTimeRequest->setClientId($clientId); $realTimeRequest->setTransactionType($transactionType); $realTimeRequest->setOriginalTxnReference($originalTxnReference); $realTimeRequest->setClientRef("cvdb-123"); $realTimeRequest->setComment("testing"); $extraData = array("invoice-no" => "I99999", "job-no" => "J10101"); $realTimeRequest->setExtraData($exData); // sets credit-card details $creditCard = new CreditCard(); $creditCard->setType($cardType); $creditCard->setHolderName("Bob Marley"); $creditCard->setExpiry($expiryDate); $creditCard->setNumber($cardNo); $creditCard->setSecureId($secureId); $creditCard->setSecureIdSupplied(TRUE); $realTimeRequest->setCreditCard($creditCard); // sets transaction-amounts details (all amounts are in cents) $transactionAmount = new TransactionAmount($paymentAmount); $transactionAmount->setTotalAmount(); //$transactionAmount->setPaymentAmount($paymentAmount); $transactionAmount->setServiceFeeAmount(); $transactionAmount->setCurrency($currency); $realTimeRequest->setTransactionAmount($transactionAmount); /* ------------------------------------------------------------------------------ STEP4: Process PaycorpRealTimeRequest object ------------------------------------------------------------------------------ */ $realTimeResponse = $client->getPayment()->realTime($realTimeRequest);