public function payEmail() { $options = self::getOptions(); $options['merchant'] = $this->gatewayModel->username; $options['passwd'] = $this->gatewayModel->shared_secret; $dp = new DragonpayRequest($options); $dp->set('txnid', $this->attemptModel->attempt_id); $dp->set('amount', number_format($this->attemptModel->amount, 2, '.', '')); $dp->set('ccy', 'PHP'); //$this->campaignModel->currency_id); $dp->set('description', $this->campaignModel->profile->descriptor_name); $dp->set('email', $this->customerModel->email); $dp->set('param1', $this->attemptModel->attempt_id); //$dp->set('mode', '1'); //Change Attempt Status to inprogress Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS); //or submitted? $this->_paymetnResponse->redirectUrl = $dp->redirectUrl(); //Set success status to response $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS; $this->_paymetnResponse->attemptModel = $this->attemptModel; $this->_paymetnResponse->paymentModel = $this->paymentModel; OrderLog::createLog(0, $this->orderModel->order_id, 22, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id); return true; }
protected function beforePay() { $profileMethod = ProfileMethod::model()->findByPk(array('profile_id' => $this->campaignModel->profile->profile_id, 'method_id' => $this->paymentMethod->method_id)); if ($profileMethod && $profileMethod->isFlag(ProfileMethod::FLAG_FILTER) && $this->paymentModel->cc_number) { if (!Bin::verificationCreditCard($this->paymentModel->cc_number)) { Attempt::setAttemptStatus($this->attemptModel, Attempt::FRAUD_STATUS); $this->_paymetnResponse->addError('error_processing_request'); $this->_paymetnResponse->addAlert('please_use_a_different_card'); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; // log prepaid card attempt OrderLog::createLog(0, $this->orderModel->order_id, 28, 'Prepaid Card'); return false; } } return true; }
public function payCreditCard() { if (self::$isTest) { //Approved STP transaction //$this->paymentModel->cc_number='4444444444444444'; //$this->paymentModel->cc_cvv='001'; //Declined transaction //$this->paymentModel->cc_number='4444444444444444'; //$this->paymentModel->cc_cvv='002'; //Error (general error) //$this->paymentModel->cc_number='4444444444444444'; //$this->paymentModel->cc_cvv='003'; //3D Secure redirect response ??? //$this->paymentModel->cc_number='4444444444444441'; //$this->paymentModel->cc_cvv='111'; // NOTE: These test cards will generate test data into the database and will be available on the reporting interface. //Approved STP transaction //$this->paymentModel->cc_number='4773654827386427'; //$this->paymentModel->cc_cvv='777'; //Declined transaction* //$this->paymentModel->cc_number='4773654827386427'; //$this->paymentModel->cc_cvv='444'; } Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS); $transaction = new AldraPay(array('merchantID' => $this->gatewayModel->username, 'passCode' => $this->gatewayModel->shared_secret)); $transaction->set('amount', number_format($this->attemptModel->amount, 2)); $transaction->set('currency', $this->campaignModel->currency_id); $transaction->set('orderID', $this->attemptModel->getrequest_id('ap')); $transaction->set('customerIP', $this->orderModel->ip_formatted); $transaction->set('customerEmail', substr($this->customerModel->email, 0, 120)); $transaction->set('customerFirstName', substr($this->billingAddressModel->fname, 0, 32)); $transaction->set('customerLastName', substr($this->billingAddressModel->lname, 0, 32)); $transaction->set('customerAddress1', substr($this->billingAddressModel->address1, 0, 64)); $transaction->set('customerCity', substr($this->billingAddressModel->city, 0, 32)); $transaction->set('customerZipCode', substr($this->billingAddressModel->zip, 0, 16)); $transaction->set('customerCountry', strtoupper($this->billingAddressModel->country_id)); $transaction->set('cardNumber', $this->paymentModel->cc_number); $transaction->set('cardCVV2', $this->paymentModel->cc_cvv); $transaction->set('cardExpiryDate', str_pad($this->paymentModel->exp_date, 4, "0", STR_PAD_LEFT)); $transaction->set('description', substr($this->gatewayModel->directdebittext, 0, 64)); $transaction->sale(); try { $result = $transaction->execute(); fb($result); } catch (Exception $e) { $aErrors = array('Error processing your request'); $this->attemptError($aErrors); return false; } if (!$result) { // payment server errors $aErrors = array('Error processing your request'); $this->attemptError($aErrors); return false; } // if not approved if (!isset($result['responseCode']) || !in_array($result['responseCode'], array(1, 6))) { //decline error $error = isset($result['reasonCodeString']) ? $result['reasonCodeString'] : 'Error processing your request'; if (isset($result['transaction']['transactionID'])) { $this->attemptModel->custom_data = json_encode(array('tracking_number' => $result['transaction']['transactionID'])); } $this->attemptError(array($error)); return false; } switch ($result['responseCode']) { case '1': $this->attemptModel->status = Attempt::SUCCESS_STATUS; break; case '6': $this->attemptModel->status = Attempt::SUBMITED_STATUS; break; } if (isset($result['transaction']['transactionID'])) { //the field tracking_number DECIMAL(16,0) //$this->attemptModel->tracking_number=$result['transaction']['transactionID']; $this->attemptModel->custom_data = json_encode(array('tracking_number' => $result['transaction']['transactionID'])); } $this->attemptModel->status_note = ''; if ($result['responseCodeString']) { $this->attemptModel->status_note .= $result['responseCodeString']; } if ($result['reasonCodeString']) { $this->attemptModel->status_note .= ' (' . $result['reasonCodeString'] . ')'; } $this->attemptModel->save(); //Set success status to response $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS; $this->_paymetnResponse->attemptModel = $this->attemptModel; $this->_paymetnResponse->paymentModel = $this->paymentModel; OrderLog::createLog(0, $this->orderModel->order_id, 22, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id); return true; /* * array( ['responseCode'] => 2 ['reasonCode'] =>2 ['transaction'] => array( ['transactionID'] => '20150320-3E750665AFAD0212AC4F-A19D5AB4270C177447CA' ['amount'] => 2.00 ['currency'] => 'GBP' ['orderID'] => 'PN4AP119665' ['executed'] => '2015-03-20 03:30:39' ) ['pSign'] => 'b21ac5997b00dd429e66e02b416326a15f1674ea' ) */ }
public function voidCreditCard() { fb('PayPal void'); Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS); $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id); $successAttemptCustomData = json_decode($successAttemptModel->custom_data, true); $options = array('username' => $this->gatewayModel->username, 'password' => $this->gatewayModel->routing_number, 'signature' => $this->gatewayModel->shared_secret); $transaction = new PayPal($options); if (self::$isTest) { $transaction->setIsProduction(false); } $transaction->set('TRANSACTIONID', $successAttemptCustomData['tracking_number']); $transaction->void(); try { $response = $transaction->execute(); fb($response); } catch (Exception $e) { $aErrors = array('Error processing your request'); $this->attemptError($aErrors); return false; } if (!is_array($response) || !isset($response['ACK'])) { // payment server errors $aErrors = array('Error processing your request'); $this->attemptError($aErrors); return false; } if (in_array($response['ACK'], array(Paypal::STATUS_SUCCESS, Paypal::STATUS_SUCCESS_WITH_WARNING))) { $this->attemptModel->status = Attempt::SUCCESS_STATUS; $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS; } else { $this->attemptModel->status = Attempt::DECLINED_STATUS; $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; } //Save custom data $customData = array(); if (isset($response['TRANSACTIONID'])) { $customData['tracking_number'] = $response['REFUNDTRANSACTIONID']; } if (isset($response['CORRELATIONID'])) { $customData['correlation_id'] = $response['CORRELATIONID']; } if (isset($response['REFUNDSTATUS'])) { $customData['refund_status'] = $response['REFUNDSTATUS']; } if (isset($response['PENDINGREASON'])) { $customData['pending_reason'] = $response['PENDINGREASON']; } if ($customData) { $this->attemptModel->custom_data = json_encode($customData); } //Save status_note $errors = array(); if (isset($response['L_ERRORCODE0'])) { $errors[] = 'Code: ' . $response['L_ERRORCODE0']; } if (isset($response['L_LONGMESSAGE0'])) { $errors[] = 'Message: ' . $response['L_LONGMESSAGE0']; } if ($errors) { $this->attemptModel->status_note = implode('. ', $errors); } $this->attemptModel->save(); //Set success status to response $this->_paymetnResponse->attemptModel = $this->attemptModel; $this->_paymetnResponse->paymentModel = $this->paymentModel; OrderLog::createLog(0, $this->orderModel->order_id, 13, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id); return true; }
private function updateUser($shopperID) { // Update Shopper Add Credit Card $xmlArray = array('shopper' => array('web-info' => $this->requestArray('web-info'), 'shopper-info' => array('seller-shopper-id' => $this->customerModel->customer_id, 'shopper-currency' => $this->campaignModel->currency_id, 'store-id' => $this->_paymentOptions['store-id'], 'shopper-contact-info' => $this->requestArray('shopper-contact-info'), 'invoice-contacts-info' => array('invoice-contact-info' => $this->requestArray('invoice-contact-info')), 'payment-info' => array('credit-cards-info' => array('credit-card-info' => array('billing-contact-info' => $this->requestArray('billing-contact-info'), 'credit-card' => $this->requestArray('credit-card'))))))); // if there is no cc_encrypt present if (!$this->paymentModel->cc_number_encrypt) { unset($xmlArray['shopper']['shopper-info']['payment-info']); } try { //Send request $response = $this->send($xmlArray, 'shoppers/' . $shopperID, 'shopper', true, true); fb($response); } catch (Exception $e) { //Change Attempt Status to unknown Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS); $this->_paymetnResponse->addError('error_processing_request'); $this->_paymetnResponse->addAlert('error_processing_your_request'); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; return false; } // add //if($response) return true; }
public function checkResponseStatusID($RESPONSE) { $statusID = $RESPONSE->ROW->STATUSID; if (!$statusID) { $statusID = $RESPONSE->STATUS->STATUSID; } if (!$statusID) { return false; } if ($statusID < 100) { Attempt::setAttemptStatus($this->attemptModel, Attempt::SUBMITED_STATUS); $this->_paymetnResponse->addError('declined', (string) $RESPONSE->ERROR->MESSAGE); $this->_paymetnResponse->addAlert('try_again_later'); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; } elseif ($statusID >= 100 && $statusID <= 500) { Attempt::setAttemptStatus($this->attemptModel, Attempt::DECLINED_STATUS); $this->_paymetnResponse->addError('declined', (string) $RESPONSE->ERROR->MESSAGE); $this->_paymetnResponse->addAlert('order_is_void'); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; } elseif ($statusID >= 800 && $statusID <= 1050) { $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS; if ($statusID >= 1000) { Attempt::setAttemptStatus($this->attemptModel, Attempt::SUCCESS_STATUS); } else { Attempt::setAttemptStatus($this->attemptModel, Attempt::SUBMITED_STATUS); } } }
public function voidCreditCard() { $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id); if (!$successAttemptModel) { //it need to test Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; return false; } $pacnetOptions = $this->gatewayModel->getAttributes(); //$pacnetOptions['currency_id']=$this->campaignModel->currency_id; $pacnetOptions['isTest'] = self::$isTest; // Create and populate a request object $pymtReq = new RavenRequest('void', $pacnetOptions); $pymtReq->set('RequestID', $this->attemptModel->getrequest_id('pn')); $pymtReq->set('TrackingNumber', $successAttemptModel->tracking_number); $pymtReq->set('PymtType', self::CC_DEBIT); Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS); // Submit the request try { //Send request $pymtResp = $pymtReq->send(); } catch (Exception $e) { //Change Attempt Status to unknown Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS); $this->_paymetnResponse->addError('error_processing_request'); $this->_paymetnResponse->addAlert('error_processing_your_request'); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; return false; } $errors = array(); if ($pymtResp->get('httpStatus') == 'timeout') { $respReq = new RavenRequest('response', $this->gatewayModel->getAttributes()); $respReq->set('RequestID', $pymtReq->get('RequestID')); $pymtResp = $respReq->send(); } if ($pymtResp->get('httpStatus') != 200) { $this->_paymetnResponse->addAlert('error_processing_your_request'); $errors['httpStatus'] = $pymtResp->get('httpStatus'); } if ($pymtResp->get('ErrorCode')) { $errorCode = strtolower($pymtResp->get('ErrorCode')); $this->_paymetnResponse->addAlert($pymtResp->get('Message')); if (!in_array($errorCode, $errors)) { $errors['ErrorCode'] = $errorCode; } } if ($errors) { //Change Attempt Status to decline Attempt::setAttemptStatus($this->attemptModel, Attempt::DECLINED_STATUS); foreach ($errors as $key => $error) { $this->_paymetnResponse->addError($key, $error); } $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; OrderLog::createLog(0, $this->orderModel->order_id, 21, implode(',', $errors)); return false; } // Fill and save attempt Model $this->attemptModel->status = Attempt::SUCCESS_STATUS; $this->attemptModel->tracking_number = $pymtResp->get('TrackingNumber'); $this->attemptModel->status_note = $pymtResp->get('Status') ? $pymtResp->get('Status') : ''; $this->attemptModel->amount = $pymtResp->get('FormattedAmount'); $this->attemptModel->save(); //Set success status to response $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS; return true; }