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;
 }
Example #2
0
       ------------------------------------------------------------------------------ */
    $client = new GatewayClient($clientConfig);
    /* ------------------------------------------------------------------------------
       STEP3: Build PaymentInitRequest object
       ------------------------------------------------------------------------------ */
    $initRequest = new PaymentInitRequest();
    $initRequest->setClientId($clientId);
    $initRequest->setTransactionType(TransactionType::$PURCHASE);
    $initRequest->setClientRef($clientRef);
    $initRequest->setComment($comment);
    $initRequest->setTokenize(TRUE);
    $initRequest->setExtraData(array("msisdn" => "{$msisdn}", "sessionId" => "{$sessionId}"));
    // sets transaction-amounts details (all amounts are in cents)
    $transactionAmount = new TransactionAmount($paymentAmount);
    $transactionAmount->setTotalAmount($totalAmount);
    $transactionAmount->setServiceFeeAmount($serviceFeeAmount);
    //$transactionAmount->setPaymentAmount((float) $paymentAmount);
    $transactionAmount->setCurrency($currency);
    $initRequest->setTransactionAmount($transactionAmount);
    // sets redirect settings
    $redirect = new Redirect($returnUrl);
    // $redirect->setReturnUrl($returnUrl);
    $redirect->setReturnMethod($returnMethod);
    $initRequest->setRedirect($redirect);
    /* ------------------------------------------------------------------------------
       STEP4: Process PaymentInitRequest object
       ------------------------------------------------------------------------------ */
    $initResponse = $client->getPayment()->init($initRequest);
}
?>