idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
48,500
public function getRefundAmountInfo ( $ param ) { $ chargeHistory = $ this -> getChargeHistory ( $ param ) ; $ charges = $ chargeHistory -> getCharges ( ) ; $ chargesArray = $ charges -> toArray ( ) ; $ totalRefunded = 0 ; foreach ( $ chargesArray as $ num => $ values ) { if ( in_array ( CheckoutApi_Client_Constant :: STATUS_CAPTURE , $ values ) ) { $ capturedAmount = $ values [ 'value' ] ; } if ( in_array ( CheckoutApi_Client_Constant :: STATUS_REFUND , $ values ) ) { $ totalRefunded += $ values [ 'value' ] ; } } $ refundInfo = array ( 'capturedAmount' => $ capturedAmount , 'totalRefunded' => $ totalRefunded , 'remainingAmount' => $ capturedAmount - $ totalRefunded ) ; return $ refundInfo ; }
Refund Info This method returns the Captured amount total refunded amount and the amount remaing to refund
48,501
public function refundCharge ( $ param ) { $ chargeHistory = $ this -> getChargeHistory ( $ param ) ; $ charges = $ chargeHistory -> getCharges ( ) ; $ uri = $ this -> getUriCharge ( ) ; if ( ! empty ( $ charges ) ) { $ chargesArray = $ charges -> toArray ( ) ; $ toRefund = false ; $ toVoid = false ; $ toRefundData = false ; $ toVoidData = false ; foreach ( $ chargesArray as $ key => $ charge ) { if ( in_array ( CheckoutApi_Client_Constant :: STATUS_CAPTURE , $ charge ) || in_array ( CheckoutApi_Client_Constant :: STATUS_REFUND , $ charge ) ) { if ( strtolower ( $ charge [ 'status' ] ) == strtolower ( CheckoutApi_Client_Constant :: STATUS_CAPTURE ) ) { $ toRefund = true ; $ toRefundData = $ charge ; break ; } } else { $ toVoid = true ; $ toVoidData = $ charge ; } } if ( $ toRefund ) { $ refundChargeId = $ toRefundData [ 'id' ] ; $ param [ 'chargeId' ] = $ refundChargeId ; $ uri = "$uri/{$param['chargeId']}/refund" ; } if ( $ toVoid ) { $ voidChargeId = $ toVoidData [ 'id' ] ; $ param [ 'chargeId' ] = $ voidChargeId ; $ uri = "$uri/{$param['chargeId']}/void" ; } } else { $ this -> throwException ( 'Please provide a valid charge id' , array ( 'param' => $ param ) ) ; } $ hasError = false ; $ param [ 'postedParam' ] [ 'type' ] = CheckoutApi_Client_Constant :: CHARGE_TYPE ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_POST ; $ postedParam = $ param [ 'postedParam' ] ; $ this -> flushState ( ) ; $ isAmountValid = CheckoutApi_Client_Validation_GW3 :: isValueValid ( $ postedParam ) ; $ isChargeIdValid = CheckoutApi_Client_Validation_GW3 :: isChargeIdValid ( $ param ) ; if ( ! $ isChargeIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid charge id' , array ( 'param' => $ param ) ) ; } if ( ! $ isAmountValid ) { $ this -> throwException ( 'Please provide a amount (in cents)' , array ( 'param' => $ param ) , false ) ; } return $ this -> _responseUpdateStatus ( $ this -> request ( $ uri , $ param , ! $ hasError ) ) ; }
Refund Charge This method refunds a Card Charge that has previously been created but not yet refunded or void a charge that has been capture
48,502
public function voidCharge ( $ param ) { $ hasError = false ; $ param [ 'postedParam' ] [ 'type' ] = CheckoutApi_Client_Constant :: CHARGE_TYPE ; $ postedParam = $ param [ 'postedParam' ] ; $ this -> flushState ( ) ; $ isAmountValid = CheckoutApi_Client_Validation_GW3 :: isValueValid ( $ postedParam ) ; $ isChargeIdValid = CheckoutApi_Client_Validation_GW3 :: isChargeIdValid ( $ param ) ; $ uri = $ this -> getUriCharge ( ) ; if ( ! $ isChargeIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid charge id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['chargeId']}/void" ; } if ( ! $ isAmountValid ) { $ this -> throwException ( 'Please provide a amount (in cents)' , array ( 'param' => $ param ) , false ) ; } return $ this -> _responseUpdateStatus ( $ this -> request ( $ uri , $ param , ! $ hasError ) ) ; }
Void Charge This method void a Card Charge that has previously been created
48,503
public function getCharge ( $ param ) { $ hasError = false ; $ param [ 'postedParam' ] [ 'type' ] = CheckoutApi_Client_Constant :: CHARGE_TYPE ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_GET ; $ this -> flushState ( ) ; $ isChargeIdValid = CheckoutApi_Client_Validation_GW3 :: isChargeIdValid ( $ param ) ; $ uri = $ this -> getUriCharge ( ) ; if ( ! $ isChargeIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid charge id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['chargeId']}" ; } return $ this -> _responseUpdateStatus ( $ this -> request ( $ uri , $ param , ! $ hasError ) ) ; }
Get Charge . Get the specified Card Charge by setting the values of the parameters passed .
48,504
public function createLocalPaymentCharge ( $ param ) { $ hasError = false ; $ param [ 'postedParam' ] [ 'type' ] = CheckoutApi_Client_Constant :: LOCALPAYMENT_CHARGE_TYPE ; $ postedParam = $ param [ 'postedParam' ] ; $ this -> flushState ( ) ; $ uri = $ this -> getUriCharge ( ) ; $ isValidEmail = CheckoutApi_Client_Validation_GW3 :: isEmailValid ( $ postedParam ) ; $ isValidSessionToken = CheckoutApi_Client_Validation_GW3 :: isSessionToken ( $ postedParam ) ; $ isValidLocalPaymentHash = CheckoutApi_Client_Validation_GW3 :: isLocalPyamentHashValid ( $ postedParam ) ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_POST ; if ( ! $ isValidEmail ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid email address' , array ( 'postedParam' => $ postedParam ) ) ; } if ( ! $ isValidSessionToken ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid session token' , array ( 'postedParam' => $ postedParam ) ) ; } if ( ! $ isValidLocalPaymentHash ) { $ hasError = true ; $ this -> throwException ( 'Please provide a local payment hash' , array ( 'postedParam' => $ postedParam ) ) ; } if ( ! isset ( $ param [ 'postedParam' ] [ 'localPayment' ] [ 'userData' ] ) ) { $ param [ 'postedParam' ] [ 'localPayment' ] [ 'userData' ] = '{}' ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Create LocalPayment Charge . Creates a LocalPayment Charge using a Session Token and
48,505
public function getListCustomer ( $ param ) { $ hasError = false ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_GET ; $ this -> flushState ( ) ; $ uri = $ this -> getUriCustomer ( ) ; $ delimiter = '?' ; $ createdAt = 'created=' ; if ( isset ( $ param [ 'created_on' ] ) ) { $ uri = "{$uri}{$delimiter}{$createdAt}{$param['created_on']}|" ; $ delimiter = '&' ; } else { if ( isset ( $ param [ 'from_date' ] ) ) { $ fromDate = time ( $ param [ 'from_date' ] ) ; $ uri = "{$uri}{$delimiter}{$createdAt}{$fromDate}" ; $ delimiter = '&' ; $ createdAt = '|' ; } if ( isset ( $ param [ 'to_date' ] ) ) { $ toDate = time ( $ param [ 'to_date' ] ) ; $ uri = "{$uri}{$createdAt}{$toDate}" ; $ delimiter = '&' ; } } if ( isset ( $ param [ 'count' ] ) ) { $ uri = "{$uri}{$delimiter}count={$param['count']}" ; $ delimiter = '&' ; } if ( isset ( $ param [ 'offset' ] ) ) { $ uri = "{$uri}{$delimiter}offset={$param['offset']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Getting a list of customer
48,506
public function updateCard ( $ param ) { $ this -> flushState ( ) ; $ uri = $ this -> getUriCustomer ( ) ; $ hasError = false ; $ isCustomerIdValid = CheckoutApi_Client_Validation_GW3 :: isCustomerIdValid ( $ param ) ; $ isCardIdValid = CheckoutApi_Client_Validation_GW3 :: isGetCardIdValid ( $ param ) ; if ( ! $ isCustomerIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid customer id' , array ( 'param' => $ param ) ) ; } elseif ( ! $ isCardIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid card id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['customerId']}/cards/{$param['cardId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Update a card
48,507
public function getLocalPaymentProvider ( $ param ) { $ this -> flushState ( ) ; $ uri = $ this -> getUriProvider ( ) ; $ hasError = false ; $ isTokenValid = CheckoutApi_Client_Validation_GW3 :: isSessionToken ( $ param ) ; $ isValidProvider = CheckoutApi_Client_Validation_GW3 :: isProvider ( $ param ) ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_GET ; $ delimiter = '/localpayments/' ; if ( ! $ isTokenValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid session token' , array ( 'param' => $ param ) ) ; } if ( ! $ isValidProvider ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid provider id' , array ( 'param' => $ param ) ) ; } if ( ! $ hasError ) { $ uri = "{$uri}{$delimiter}{$param['providerId']}?token={$param['token']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Get LocalPayment Provider
48,508
public function getCardProvidersList ( $ param ) { $ this -> flushState ( ) ; $ uri = $ this -> getUriProvider ( ) . '/cards' ; $ hasError = false ; return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Get Card Provider list
48,509
public function getCardProvider ( $ param ) { $ this -> flushState ( ) ; $ isValidProvider = CheckoutApi_Client_Validation_GW3 :: isProvider ( $ param ) ; $ uri = $ this -> getUriProvider ( ) . '/cards' ; $ hasError = false ; if ( ! $ isValidProvider ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid provider id' , array ( 'param' => $ param ) ) ; } if ( ! $ hasError ) { $ uri = "{$uri}/{$param['providerId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Get a list of card provider
48,510
public function updatePaymentPlan ( $ param ) { $ hasError = false ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_PUT ; $ this -> flushState ( ) ; $ uri = $ this -> getUriRecurringPayments ( ) . '/plans' ; ; $ isPlanIdValid = CheckoutApi_Client_Validation_GW3 :: isPlanIdValid ( $ param ) ; if ( ! $ isPlanIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid plan id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['planId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Update Recurring Payment Plan . Updates the specified Recurring Payment Plan by setting the values of the parameters passed .
48,511
public function cancelPaymentPlan ( $ param ) { $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_DELETE ; $ this -> flushState ( ) ; $ uri = $ this -> getUriRecurringPayments ( ) . '/plans' ; $ hasError = false ; $ isPlanIdValid = CheckoutApi_Client_Validation_GW3 :: isPlanIdValid ( $ param ) ; if ( ! $ isPlanIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid plan id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['planId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Cancel a payment plan
48,512
public function getPaymentPlan ( $ param ) { $ hasError = false ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_GET ; $ this -> flushState ( ) ; $ uri = $ this -> getUriRecurringPayments ( ) . '/plans' ; ; $ isPlanIdValid = CheckoutApi_Client_Validation_GW3 :: isPlanIdValid ( $ param ) ; if ( ! $ isPlanIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid plan id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['customerId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Get payment plan
48,513
public function updateCustomerPaymentPlan ( $ param ) { $ hasError = false ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_PUT ; $ this -> flushState ( ) ; $ uri = $ this -> getUriRecurringPayments ( ) . '/customers' ; ; $ isCustomerPlanIdValid = CheckoutApi_Client_Validation_GW3 :: isCustomerPlanIdValid ( $ param ) ; if ( ! $ isCustomerPlanIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid customer plan id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['customerPlanId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Update Recurring Customer Payment Plan . Updates the specified Recurring Customer Payment Plan by setting the values of the parameters passed .
48,514
public function cancelCustomerPaymentPlan ( $ param ) { $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_DELETE ; $ this -> flushState ( ) ; $ uri = $ this -> getUriRecurringPayments ( ) . '/customers' ; $ hasError = false ; $ isCustomerPlanIdValid = CheckoutApi_Client_Validation_GW3 :: isCustomerPlanIdValid ( $ param ) ; if ( ! $ isCustomerPlanIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid customer plan id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['customerPlanId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Cancel a customer payment plan
48,515
public function getCustomerPaymentPlan ( $ param ) { $ hasError = false ; $ param [ 'method' ] = CheckoutApi_Client_Adapter_Constant :: API_GET ; $ this -> flushState ( ) ; $ uri = $ this -> getUriRecurringPayments ( ) . '/customers' ; ; $ isCustomerPlanIdValid = CheckoutApi_Client_Validation_GW3 :: isCustomerPlanIdValid ( $ param ) ; if ( ! $ isCustomerPlanIdValid ) { $ hasError = true ; $ this -> throwException ( 'Please provide a valid plan id' , array ( 'param' => $ param ) ) ; } else { $ uri = "$uri/{$param['customerPlanId']}" ; } return $ this -> request ( $ uri , $ param , ! $ hasError ) ; }
Get customer payment plan
48,516
public function request ( $ uri , array $ param , $ state ) { $ respond = CheckoutApi_Lib_Factory :: getSingletonInstance ( 'CheckoutApi_Lib_RespondObj' ) ; $ this -> setConfig ( $ param ) ; if ( ! isset ( $ param [ 'postedParam' ] ) ) { $ param [ 'postedParam' ] = array ( ) ; } $ param [ 'rawpostedParam' ] = $ param [ 'postedParam' ] ; $ param [ 'postedParam' ] = $ this -> getParser ( ) -> preparePosted ( $ param [ 'postedParam' ] ) ; $ respondArray = null ; if ( $ state ) { $ headers = $ this -> initHeader ( ) ; $ param [ 'headers' ] = $ headers ; $ adapter = $ this -> getAdapter ( $ this -> getProcessType ( ) , array ( 'uri' => $ uri , 'config' => $ param ) ) ; if ( $ adapter ) { $ adapter -> connect ( ) ; $ respondString = $ adapter -> request ( ) -> getRespond ( ) ; $ statusResponse = $ adapter -> getResourceInfo ( ) ; $ this -> getParser ( ) -> setResourceInfo ( $ statusResponse ) ; $ respond = $ this -> getParser ( ) -> parseToObj ( $ respondString ) ; if ( $ respond && isset ( $ respond [ 'errors' ] ) && $ respond -> hasErrors ( ) ) { $ exceptionStateObj = $ respond -> getExceptionState ( ) ; $ errors = $ respond -> getErrors ( ) -> toArray ( ) ; $ exceptionStateObj -> flushState ( ) ; foreach ( $ errors as $ error ) { $ this -> throwException ( $ error , $ respond -> getErrors ( ) -> toArray ( ) ) ; } } elseif ( $ respond && isset ( $ respond [ 'errorCode' ] ) && $ respond -> hasErrorCode ( ) ) { $ exceptionStateObj = $ respond -> getExceptionState ( ) ; $ this -> throwException ( $ respond -> getMessage ( ) , $ respond -> toArray ( ) ) ; } elseif ( $ respond && $ respond -> getHttpStatus ( ) != '200' ) { $ this -> throwException ( 'Gateway is temporary down' , $ param ) ; } $ adapter -> close ( ) ; } } return $ respond ; }
Build up the request to the gateway
48,517
public function getMode ( ) { if ( isset ( $ this -> _config [ 'mode' ] ) && $ this -> _config [ 'mode' ] ) { $ this -> _mode = $ this -> _config [ 'mode' ] ; } return $ this -> _mode ; }
return the mode . can be either dev or preprod or live
48,518
public function setUriCharge ( $ uri = '' , $ sufix = '' ) { $ toSetUri = $ uri ; if ( ! $ uri ) { $ toSetUri = $ this -> getUriPrefix ( ) . 'charges' ; } if ( $ sufix ) { $ toSetUri .= "/$sufix" ; } $ this -> _uriCharge = $ toSetUri ; }
A method that set it charge url
48,519
public function setUriToken ( $ uri = null ) { $ toSetUri = $ uri ; if ( ! $ uri ) { $ toSetUri = $ this -> getUriPrefix ( ) . 'tokens' ; } $ this -> _uriToken = $ toSetUri ; }
set uri token
48,520
public function setUriCustomer ( $ uri = null ) { $ toSetUri = $ uri ; if ( ! $ uri ) { $ toSetUri = $ this -> getUriPrefix ( ) . 'customers' ; } $ this -> _uriCustomer = $ toSetUri ; }
set customer uri
48,521
public function setUriRecurringPayments ( $ uri = null ) { $ toSetUri = $ uri ; if ( ! $ uri ) { $ toSetUri = $ this -> getUriPrefix ( ) . 'recurringPayments' ; } $ this -> _uriRecurringPayments = $ toSetUri ; }
set uri recurring payments
48,522
private function getUriPrefix ( ) { $ mode = strtolower ( $ this -> getMode ( ) ) ; switch ( $ mode ) { case 'live' : $ prefix = CheckoutApi_Client_Constant :: APIGW3_URI_PREFIX_LIVE . CheckoutApi_Client_Constant :: VERSION . '/' ; break ; default : $ prefix = CheckoutApi_Client_Constant :: APIGW3_URI_PREFIX_SANDBOX . CheckoutApi_Client_Constant :: VERSION . '/' ; break ; } return $ prefix ; }
return which uri prefix to be used base on mode type
48,523
private function throwException ( $ message , array $ stackTrace , $ error = true ) { $ this -> exception ( $ message , $ stackTrace , $ error ) ; }
setting exception state log
48,524
public function flushState ( ) { parent :: flushState ( ) ; if ( $ mode = $ this -> getMode ( ) ) { $ this -> setMode ( $ mode ) ; } $ this -> setUriCharge ( ) ; $ this -> setUriToken ( ) ; $ this -> setUriCustomer ( ) ; $ this -> setUriProvider ( ) ; $ this -> setUriRecurringPayments ( ) ; }
flushing all config
48,525
public function isAuthorise ( $ response ) { $ result = false ; $ hasError = $ this -> isError ( $ response ) ; $ isApprove = $ this -> isApprove ( $ response ) ; if ( ! $ hasError && $ isApprove ) { $ result = true ; } return $ result ; }
Check charge response If response is approve or has error return boolean
48,526
protected function isApprove ( $ response ) { $ result = false ; if ( $ response -> getResponseCode ( ) == CheckoutApi_Client_Constant :: RESPONSE_CODE_APPROVED || $ response -> getResponseCode ( ) == CheckoutApi_Client_Constant :: RESPONSE_CODE_APPROVED_RISK ) { $ result = true ; } return $ result ; }
Check if response is approve return boolean
48,527
public function getResponseId ( $ response ) { $ isError = $ this -> isError ( $ response ) ; if ( $ isError ) { $ result = array ( 'message' => $ response -> getMessage ( ) , 'eventId' => $ response -> getEventId ( ) ) ; return $ result ; } else { $ result = array ( 'responseMessage' => $ response -> getResponseMessage ( ) , 'id' => $ response -> getId ( ) ) ; return $ result ; } }
return eventId if charge has error . return chargeID if charge is decline
48,528
public function isFlagResponse ( $ response ) { $ result = false ; if ( $ response -> getResponseCode ( ) == CheckoutApi_Client_Constant :: RESPONSE_CODE_APPROVED_RISK ) { $ result = array ( 'responseMessage' => $ response -> getResponseMessage ( ) , ) ; } return $ result ; }
Check if response is flag return response message
48,529
public function createSinglePlan ( RequestModels \ BaseRecurringPayment $ requestModel ) { $ recurringPaymentMapper = new \ com \ checkout \ ApiServices \ RecurringPayments \ RecurringPaymentMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ recurringPaymentMapper -> requestPayloadConverter ( ) , ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ this -> _apiUrl -> getRecurringPaymentsApiUri ( ) , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ RecurringPayment ( $ processCharge ) ; return $ responseModel ; }
Creates a new payment plan
48,530
public function getAdapter ( $ adapterName , $ arguments = array ( ) ) { $ stdName = ucfirst ( $ adapterName ) ; $ classAdapterName = CheckoutApi_Client_Constant :: ADAPTER_CLASS_GROUP . $ stdName ; $ class = null ; if ( class_exists ( $ classAdapterName ) ) { $ class = CheckoutApi_Lib_Factory :: getSingletonInstance ( $ classAdapterName , $ arguments ) ; if ( isset ( $ arguments [ 'uri' ] ) ) { $ class -> setUri ( $ arguments [ 'uri' ] ) ; } if ( isset ( $ arguments [ 'config' ] ) ) { $ class -> setConfig ( $ arguments [ 'config' ] ) ; } } else { $ this -> exception ( "Not a valid Adapter" , debug_backtrace ( ) ) ; } return $ class ; }
CheckoutApi_ initialise return an adapter .
48,531
public function setHeaders ( $ headers ) { if ( ! $ this -> _parserObj ) { $ this -> initParser ( $ this -> getRespondType ( ) ) ; } $ this -> _headers = $ this -> getParser ( ) -> getHeaders ( ) ; $ this -> _headers = array_merge ( $ this -> _headers , $ headers ) ; }
set the headers array base on which paser we are using
48,532
public function parseToObj ( $ parser ) { $ respondObj = CheckoutApi_Lib_Factory :: getInstance ( 'CheckoutApi_Lib_RespondObj' ) ; if ( $ parser && is_string ( $ parser ) ) { $ encoding = mb_detect_encoding ( $ parser ) ; if ( $ encoding == "ASCII" ) { $ parser = iconv ( 'ASCII' , 'UTF-8' , $ parser ) ; } else { $ parser = mb_convert_encoding ( $ parser , "UTF-8" , $ encoding ) ; } $ jsonObj = json_decode ( $ parser , true ) ; $ jsonObj [ 'rawOutput' ] = $ parser ; $ respondObj -> setConfig ( $ jsonObj ) ; } $ respondObj -> setConfig ( $ this -> getResourceInfo ( ) ) ; return $ respondObj ; }
Convert a json to a CheckoutApi_Lib_RespondObj object
48,533
public static function getApi ( array $ arguments = array ( ) , $ _apiClass = null ) { if ( $ _apiClass ) { self :: setApiClass ( $ _apiClass ) ; } $ exceptionState = CheckoutApi_Lib_Factory :: getSingletonInstance ( 'CheckoutApi_Lib_ExceptionState' ) ; $ exceptionState -> setErrorState ( false ) ; return CheckoutApi_Lib_Factory :: getSingletonInstance ( self :: getApiClass ( ) , $ arguments ) ; }
Helper static function to get singleton instance of a gateway interface .
48,534
public function setConfig ( $ config = array ( ) ) { if ( is_array ( $ config ) ) { if ( ! empty ( $ config ) ) { foreach ( $ config as $ key => $ value ) { $ this -> _config [ $ key ] = $ value ; } } } else { throw new Exception ( "Invalid parameter" ) ; } }
A settter . it get an array and update or add new configuration value to object
48,535
public function exception ( $ errorMsg , array $ trace , $ error = true ) { $ classException = "CheckoutApi_Lib_ExceptionState" ; if ( class_exists ( $ classException ) ) { $ class = CheckoutApi_Lib_Factory :: getSingletonInstance ( $ classException ) ; } else { throw new Exception ( "Not a valid class :: CheckoutApi_Lib_ExceptionState" ) ; } $ class -> setLog ( $ errorMsg , $ trace , $ error ) ; return $ class ; }
setting and logging error message
48,536
public function chargeWithCard ( RequestModels \ CardChargeCreate $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ this -> _apiUrl -> getCardChargesApiUri ( ) , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ Charge ( $ processCharge ) ; return $ responseModel ; }
Creates a charge with full card details .
48,537
public function chargeWithCardToken ( RequestModels \ CardTokenChargeCreate $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ this -> _apiUrl -> getCardTokensApiUri ( ) , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ Charge ( $ processCharge ) ; return $ responseModel ; }
Creates a charge with cardToken .
48,538
public function chargeWithDefaultCustomerCard ( RequestModels \ BaseCharge $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ this -> _apiUrl -> getDefaultCardChargesApiUri ( ) , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ Charge ( $ processCharge ) ; return $ responseModel ; }
Creates a charge with Default Customer Card .
48,539
public function refundCardChargeRequest ( RequestModels \ ChargeRefund $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ refundUri = sprintf ( $ this -> _apiUrl -> getChargeRefundsApiUri ( ) , $ requestModel -> getChargeId ( ) ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ refundUri , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ Charge ( $ processCharge ) ; return $ responseModel ; }
refund a charge
48,540
public function voidCharge ( $ chargeId , RequestModels \ ChargeVoid $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ refundUri = sprintf ( $ this -> _apiUrl -> getVoidChargesApiUri ( ) , $ chargeId ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ refundUri , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ Charge ( $ processCharge ) ; return $ responseModel ; }
void a charge
48,541
public function CaptureCardCharge ( RequestModels \ ChargeCapture $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ refundUri = sprintf ( $ this -> _apiUrl -> getCaptureChargesApiUri ( ) , $ requestModel -> getChargeId ( ) ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: postRequest ( $ refundUri , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ Charge ( $ processCharge ) ; return $ responseModel ; }
Capture a charge
48,542
public function UpdateCardCharge ( RequestModels \ ChargeUpdate $ requestModel ) { $ chargeMapper = new ChargesMapper ( $ requestModel ) ; $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'postedParam' => $ chargeMapper -> requestPayloadConverter ( ) , ) ; $ updateUri = sprintf ( $ this -> _apiUrl -> getUpdateChargesApiUri ( ) , $ requestModel -> getChargeId ( ) ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: putRequest ( $ updateUri , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new \ com \ checkout \ ApiServices \ SharedModels \ OkResponse ( $ processCharge ) ; return $ responseModel ; }
Update a charge
48,543
public function getChargeHistory ( $ chargeId ) { $ requestPayload = array ( 'authorization' => $ this -> _apiSetting -> getSecretKey ( ) , 'mode' => $ this -> _apiSetting -> getMode ( ) , 'method' => 'GET' , ) ; $ retrieveChargeHistoryWithChargeUri = sprintf ( $ this -> _apiUrl -> getRetrieveChargeHistoryApiUri ( ) , $ chargeId ) ; $ processCharge = \ com \ checkout \ helpers \ ApiHttpClient :: getRequest ( $ retrieveChargeHistoryWithChargeUri , $ this -> _apiSetting -> getSecretKey ( ) , $ requestPayload ) ; $ responseModel = new ResponseModels \ ChargeHistory ( $ processCharge ) ; return $ responseModel ; }
retrieve a Charge History With a ChargeId
48,544
public static function isEmailValid ( $ postedParam ) { $ isEmailEmpty = true ; $ isValidEmail = false ; if ( isset ( $ postedParam [ 'email' ] ) ) { $ isEmailEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'email' ] ) ; } if ( ! $ isEmailEmpty ) { $ isValidEmail = CheckoutApi_Lib_Validator :: isValidEmail ( $ postedParam [ 'email' ] ) ; } return ! $ isEmailEmpty && $ isValidEmail ; }
A helper method to check if email has been set in the payload and if it s a valid email
48,545
public static function isCustomerIdValid ( $ postedParam ) { $ isCustomerIdEmpty = true ; $ isValidCustomerId = false ; if ( isset ( $ postedParam [ 'customerId' ] ) ) { $ isCustomerIdEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'customerId' ] ) ; } if ( ! $ isCustomerIdEmpty ) { $ isValidCustomerId = CheckoutApi_Lib_Validator :: isString ( $ postedParam [ 'customerId' ] ) ; } return ! $ isCustomerIdEmpty && $ isValidCustomerId ; }
A helper method that is use to check if payload has set a customer id .
48,546
public static function isValueValid ( $ postedParam ) { $ isValid = false ; if ( isset ( $ postedParam [ 'value' ] ) ) { $ amount = $ postedParam [ 'value' ] ; $ isAmountEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ amount ) ; if ( ! $ isAmountEmpty ) { $ isValid = true ; } } return $ isValid ; }
A helper method that is use to valid if amount is correct in a payload .
48,547
public static function isValidCurrency ( $ postedParam ) { $ isValid = false ; if ( isset ( $ postedParam [ 'currency' ] ) ) { $ currency = $ postedParam [ 'currency' ] ; $ currencyEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ currency ) ; if ( ! $ currencyEmpty ) { $ isCurrencyLen = CheckoutApi_Lib_Validator :: isLength ( $ currency , 3 ) ; if ( $ isCurrencyLen ) { $ isValid = true ; } } } return $ isValid ; }
A helper method that is use check if payload has a currency set and if length of currency value is 3
48,548
public static function isNameValid ( $ postedParam ) { $ isValid = false ; if ( isset ( $ postedParam [ 'name' ] ) ) { $ isNameEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'name' ] ) ; if ( ! $ isNameEmpty ) { $ isValid = true ; } } return $ isValid ; }
A helper method that check if a name is set in the payload
48,549
public static function isCardNumberValid ( $ param ) { $ isValid = false ; if ( isset ( $ param [ 'number' ] ) ) { $ errorIsEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ param [ 'number' ] ) ; if ( ! $ errorIsEmpty ) { $ isValid = true ; } } return $ isValid ; }
A helper method that check if card number is set in payload .
48,550
public static function isMonthValid ( $ card ) { $ isValid = false ; if ( isset ( $ card [ 'expiryMonth' ] ) ) { $ isExpiryMonthEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ card [ 'expiryMonth' ] , false ) ; if ( ! $ isExpiryMonthEmpty && CheckoutApi_Lib_Validator :: isInteger ( $ card [ 'expiryMonth' ] ) && ( $ card [ 'expiryMonth' ] > 0 && $ card [ 'expiryMonth' ] < 13 ) ) { $ isValid = true ; } } return $ isValid ; }
A helper method that check if month is properly set in payload card object
48,551
public static function isCardValid ( $ param ) { $ isValid = true ; if ( isset ( $ param [ 'card' ] ) ) { $ card = $ param [ 'card' ] ; $ isNameValid = CheckoutApi_Client_Validation_GW3 :: isNameValid ( $ card ) ; if ( ! $ isNameValid ) { $ isValid = false ; } $ isCardNumberValid = CheckoutApi_Client_Validation_GW3 :: isCardNumberValid ( $ card ) ; if ( ! $ isCardNumberValid && ! isset ( $ param [ 'card' ] [ 'number' ] ) ) { $ isValid = false ; } $ isValidMonth = CheckoutApi_Client_Validation_GW3 :: isMonthValid ( $ card ) ; if ( ! $ isValidMonth && ! isset ( $ param [ 'card' ] [ 'expiryMonth' ] ) ) { $ isValid = false ; } $ isValidYear = CheckoutApi_Client_Validation_GW3 :: isValidYear ( $ card ) ; if ( ! $ isValidYear && ! isset ( $ param [ 'card' ] [ 'expiryYear' ] ) ) { $ isValid = false ; } $ isValidCvv = CheckoutApi_Client_Validation_GW3 :: isValidCvv ( $ card ) ; if ( ! $ isValidCvv && ! isset ( $ param [ 'card' ] [ 'cvv' ] ) ) { $ isValid = false ; } return $ isValid ; } return true ; }
A helper method that check if card is properly set in payload . It check if expiry date card number cvv and name is set
48,552
public static function isGetCardIdValid ( $ param ) { $ isValid = false ; $ card = $ param [ 'cardId' ] ; if ( isset ( $ param [ 'cardId' ] ) ) { $ isValid = self :: isCardIdValid ( array ( 'card' => $ param [ 'cardId' ] ) ) ; } return $ isValid ; }
A helper method that check if card id is set in payload . The difference between isCardIdValid and isGetCardIdValid is isCardIdValid check if card id is set in postedparam where as isGetCardIdValid check if configuration pass has a card id
48,553
public static function isCardToken ( $ param ) { $ isValid = false ; if ( isset ( $ param [ 'cardToken' ] ) ) { $ isTokenEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ param [ 'cardToken' ] ) ; if ( ! $ isTokenEmpty ) { $ isValid = true ; } } return $ isValid ; }
A helper method that check that check if token is set in payload
48,554
public static function isLocalPyamentHashValid ( $ postedParam ) { $ isValid = false ; if ( isset ( $ postedParam [ 'localPayment' ] ) && ! ( CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'localPayment' ] ) ) ) { if ( isset ( $ postedParam [ 'localPayment' ] [ 'lppId' ] ) && ! ( CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'localPayment' ] [ 'lppId' ] ) ) ) { $ isValid = true ; } } return $ isValid ; }
A helper method that check if localpayment object is valid in payload . It check if lppId is set
48,555
public static function isProvider ( $ param ) { $ isValid = false ; if ( isset ( $ param [ 'providerId' ] ) && ! ( CheckoutApi_Lib_Validator :: isEmpty ( $ param [ 'providerId' ] ) ) ) { $ isValid = true ; } return $ isValid ; }
A helper method that check provider id is set in payload .
48,556
public static function isPlanIdValid ( $ postedParam ) { $ isPlanIdEmpty = true ; $ isValidPlanId = false ; if ( isset ( $ postedParam [ 'planId' ] ) ) { $ isPlanIdEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'planId' ] ) ; } if ( ! $ isPlanIdEmpty ) { $ isValidPlanId = CheckoutApi_Lib_Validator :: isString ( $ postedParam [ 'planId' ] ) ; } return ! $ isPlanIdEmpty && $ isValidPlanId ; }
A helper method that check plan id is set in payload .
48,557
public static function isCustomerPlanIdValid ( $ postedParam ) { $ isCustomerPlanIdEmpty = true ; $ isValidCustomerPlanId = false ; if ( isset ( $ postedParam [ 'customerPlanId' ] ) ) { $ isCustomerPlanIdEmpty = CheckoutApi_Lib_Validator :: isEmpty ( $ postedParam [ 'customerPlanId' ] ) ; } if ( ! $ isCustomerPlanIdEmpty ) { $ isValidCustomerPlanId = CheckoutApi_Lib_Validator :: isString ( $ postedParam [ 'customerPlanId' ] ) ; } return ! $ isCustomerPlanIdEmpty && $ isValidCustomerPlanId ; }
A helper method that check customer plan id is set in payload .
48,558
public function request ( ) { if ( ! $ this -> getResource ( ) ) { $ this -> exception ( "No curl resource was found" , debug_backtrace ( ) ) ; } $ resource = $ this -> getResource ( ) ; curl_setopt ( $ resource , CURLOPT_URL , $ this -> getUri ( ) ) ; $ headers = $ this -> getHeaders ( ) ; if ( ! empty ( $ headers ) ) { curl_setopt ( $ resource , CURLOPT_HTTPHEADER , $ headers ) ; } $ method = $ this -> getMethod ( ) ; $ curlMethod = '' ; switch ( $ method ) { case CheckoutApi_Client_Adapter_Constant :: API_POST : $ curlMethod = CheckoutApi_Client_Adapter_Constant :: API_POST ; break ; case CheckoutApi_Client_Adapter_Constant :: API_GET : $ curlMethod = CheckoutApi_Client_Adapter_Constant :: API_GET ; break ; case CheckoutApi_Client_Adapter_Constant :: API_DELETE : $ curlMethod = CheckoutApi_Client_Adapter_Constant :: API_DELETE ; break ; case CheckoutApi_Client_Adapter_Constant :: API_PUT : $ curlMethod = CheckoutApi_Client_Adapter_Constant :: API_PUT ; break ; default : $ this -> exception ( "Method currently not supported" , debug_backtrace ( ) ) ; break ; } if ( $ curlMethod != CheckoutApi_Client_Adapter_Constant :: API_GET ) { curl_setopt ( $ resource , CURLOPT_CUSTOMREQUEST , $ curlMethod ) ; } if ( $ method == CheckoutApi_Client_Adapter_Constant :: API_POST || $ method == CheckoutApi_Client_Adapter_Constant :: API_PUT ) { curl_setopt ( $ resource , CURLOPT_POSTFIELDS , $ this -> getPostedParam ( ) ) ; } curl_setopt ( $ resource , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ resource , CURLOPT_SSL_VERIFYPEER , false ) ; $ response = curl_exec ( $ resource ) ; $ http_status = curl_getinfo ( $ resource , CURLINFO_HTTP_CODE ) ; if ( $ http_status != 200 ) { $ this -> exception ( "An error has occurred while processing your transaction" , array ( 'respond_code' => $ http_status , 'curl_info' => curl_getinfo ( $ resource ) , 'respondBody' => $ response , 'postedParam' => $ this -> getPostedParam ( ) , 'rawPostedParam' => $ this -> getRawpostedParam ( ) , ) ) ; } elseif ( curl_errno ( $ resource ) ) { $ info = curl_getinfo ( $ resource ) ; $ this -> exception ( "Curl issues " , $ info ) ; } $ this -> setResource ( $ resource ) ; $ this -> setRespond ( $ response ) ; return $ this ; }
A method that do a request on provide uri and return itsel
48,559
public function connect ( ) { if ( $ this -> getResource ( ) ) { $ this -> close ( ) ; } $ resource = curl_init ( ) ; curl_setopt ( $ resource , CURLOPT_CONNECTTIMEOUT , $ this -> getTimeout ( ) ) ; $ this -> setResource ( $ resource ) ; parent :: connect ( ) ; return $ this ; }
Close all open connections and release all set variables
48,560
public function getTimeout ( ) { $ timeout = $ this -> _timeout ; if ( $ this -> getConfig ( 'timeout' ) ) { $ timeout = $ this -> getConfig ( 'timeout' ) ; } return $ timeout ; }
gateway timeout value
48,561
public function getErrorMessage ( ) { $ messages = $ this -> getMessage ( ) ; $ critical = $ this -> getCritical ( ) ; $ msgError = "" ; $ i = 0 ; foreach ( $ messages as $ message ) { if ( $ critical [ $ i ++ ] ) { $ msgError .= "{$message}\n" ; } } return $ msgError ; }
compile all errors in one line
48,562
public function setLog ( $ errorMsg , $ trace , $ state = true ) { $ this -> setErrorState ( $ state ) ; $ this -> setTrace ( $ trace ) ; $ this -> setMessage ( $ errorMsg ) ; $ this -> setCritical ( $ state ) ; }
set error state of object . we can have an error but still proceed
48,563
public function debug ( ) { $ errorToreturn = '' ; if ( $ this -> _debug && $ this -> hasError ( ) ) { $ message = $ this -> getMessage ( ) ; $ trace = $ this -> getTrace ( ) ; $ critical = $ this -> getCritical ( ) ; for ( $ i = 0 , $ count = sizeOf ( $ message ) ; $ i < $ count ; $ i ++ ) { if ( $ critical [ $ i ] ) { echo '<strong style="color:red">' ; } else { continue ; } CheckoutApi_Utility_Utilities :: dump ( $ message [ $ i ] . '==> { ' ) ; foreach ( $ trace [ $ i ] as $ errorIndex => $ errors ) { echo "<pre>" ; echo $ errorIndex . "=> " ; print_r ( $ errors ) ; echo "</pre>" ; } if ( $ critical [ $ i ] ) { echo '</strong>' ; } CheckoutApi_Utility_Utilities :: dump ( '} ' ) ; } } return $ errorToreturn ; }
CheckoutApi_ print out the error
48,564
public function get ( $ name = '' ) { $ result = '' ; if ( isset ( $ _COOKIE [ $ name ] ) ) { $ result = $ _COOKIE [ $ name ] ; } return $ result ; }
Get a cookie
48,565
public function getSecure ( $ name = '' ) { $ result = '' ; $ cookie = Craft :: $ app -> request -> cookies -> get ( $ name ) ; if ( $ cookie !== null ) { try { $ data = Craft :: $ app -> security -> validateData ( $ cookie -> value ) ; } catch ( InvalidConfigException $ e ) { Craft :: error ( 'Error getting secure cookie: ' . $ e -> getMessage ( ) , __METHOD__ ) ; $ data = false ; } catch ( Exception $ e ) { Craft :: error ( 'Error getting secure cookie: ' . $ e -> getMessage ( ) , __METHOD__ ) ; $ data = false ; } if ( $ cookie && ! empty ( $ cookie -> value ) && $ data !== false ) { $ result = unserialize ( base64_decode ( $ data ) , [ 'allowed_classes' => false ] ) ; } } return $ result ; }
Get a secure cookie
48,566
protected function parseResponse ( $ body ) { $ this -> totalNumber = ( int ) $ body -> getElementsByTagName ( 'all' ) -> item ( 0 ) -> nodeValue ; $ this -> profileCount = ( int ) $ body -> getElementsByTagName ( 'profile' ) -> length ; if ( $ this -> profileCount > 0 ) { for ( $ i = 0 ; $ i < $ this -> profileCount ; $ i ++ ) { $ profile = $ body -> getElementsByTagName ( 'profile' ) -> item ( $ i ) ; $ this -> profiles [ $ i ] [ 'customerID' ] = $ profile -> getElementsByTagName ( 'customerID' ) -> item ( 0 ) -> nodeValue ; $ this -> profiles [ $ i ] [ 'updated' ] = $ profile -> getElementsByTagName ( 'updated' ) -> item ( 0 ) -> nodeValue ; if ( $ profile -> getElementsByTagName ( 'payment' ) -> length ) { $ this -> profiles [ $ i ] [ 'payment' ] = $ profile -> getElementsByTagName ( 'payment' ) -> item ( 0 ) -> nodeValue ; $ this -> profiles [ $ i ] [ 'paymentProfiles' ] = $ this -> parsePaymentProfiles ( $ profile -> getElementsByTagName ( 'payment' ) ) ; } } } }
Parse the ListProfilesResponse message and save the data to the corresponding attributes
48,567
public function getEncryptedParams ( $ invoice_id , $ amount , $ currency = null , $ language = null , $ user_field = null , $ mode = null , $ salutation = null , $ name = null , $ street = null , $ street2 = null , $ zip = null , $ city = null , $ country = null , $ email = null , $ phone = null , $ success = null , $ error = null , $ confirmation = null , $ invoice_idVar = "TID" , $ amountVar = "AMOUNT" , $ currencyVar = "CURRENCY" , $ languageVar = "LANGUAGE" , $ user_fieldVar = "USER_FIELD" , $ modeVar = "MODE" , $ salutationVar = "SALUTATION" , $ nameVar = "NAME" , $ streetVar = "STREET" , $ street2Var = "STREET2" , $ zipVar = "ZIP" , $ cityVar = "CITY" , $ countryVar = "COUNTRY" , $ emailVar = "EMAIL" , $ phoneVar = "PHONE" , $ successVar = "SUCCESS_URL" , $ errorVar = "ERROR_URL" , $ confirmationVar = "CONFIRMATION_URL" ) { if ( ! $ this -> mpay24Sdk ) { die ( "You are not allowed to define a constructor in the child class of Mpay24flexLink!" ) ; } $ params [ $ invoice_idVar ] = $ invoice_id ; $ params [ $ amountVar ] = $ amount ; if ( $ currency == null ) { $ currency = "EUR" ; } $ params [ $ currencyVar ] = $ currency ; if ( $ language == null ) { $ language = "DE" ; } $ params [ $ languageVar ] = $ language ; $ params [ $ user_fieldVar ] = $ user_field ; if ( $ mode == null ) { $ mode = "ReadWrite" ; } $ params [ $ modeVar ] = $ mode ; $ params [ $ nameVar ] = $ name ; $ params [ $ streetVar ] = $ street ; $ params [ $ street2Var ] = $ street2 ; $ params [ $ zipVar ] = $ zip ; $ params [ $ cityVar ] = $ city ; if ( $ country == null ) { $ country = "AT" ; } $ params [ $ countryVar ] = $ country ; $ params [ $ emailVar ] = $ email ; $ params [ $ successVar ] = $ success ; $ params [ $ errorVar ] = $ error ; $ params [ $ confirmationVar ] = $ confirmation ; $ parameters = $ this -> mpay24Sdk -> flexLink ( $ params ) ; return $ parameters ; }
Encrypt the parameters you want to post to mPAY24 - see details
48,568
public function getParam ( $ name ) { if ( isset ( $ this -> transaction [ $ name ] ) ) { return $ this -> transaction [ $ name ] ; } else { return false ; } }
Get the parameter s value returned from mPAY24
48,569
protected function parseResponse ( $ body ) { $ this -> paramCount = $ body -> getElementsByTagName ( 'parameter' ) -> length ; if ( $ this -> paramCount > 0 ) { for ( $ i = 0 ; $ i < $ this -> paramCount ; $ i ++ ) { $ parameter = $ body -> getElementsByTagName ( 'parameter' ) -> item ( $ i ) ; $ name = $ parameter -> getElementsByTagName ( 'name' ) -> item ( 0 ) -> nodeValue ; $ value = $ parameter -> getElementsByTagName ( 'value' ) -> item ( 0 ) -> nodeValue ; $ this -> transaction [ $ name ] = $ value ; } } }
Parse the TransactionStatusResponse message and save the data to the corresponding attributes
48,570
public static function cleanUpArray ( array $ parameters ) { $ cleanup = [ ] ; foreach ( $ parameters as $ name => $ value ) { if ( array_key_exists ( $ name , self :: CONFIRMATION_PROPERTIES ) ) { $ cleanup [ $ name ] = $ value ; } } return $ cleanup ; }
Set the parameters of the Confirmation object
48,571
protected function parseResponse ( $ body ) { if ( $ body -> getElementsByTagName ( 'transaction' ) -> length > 0 ) { $ transaction = $ body -> getElementsByTagName ( 'transaction' ) -> item ( 0 ) ; $ this -> mpayTid = $ transaction -> getElementsByTagName ( 'mpayTID' ) -> item ( 0 ) -> nodeValue ; $ this -> tStatus = $ transaction -> getElementsByTagName ( 'tStatus' ) -> item ( 0 ) -> nodeValue ; $ this -> tid = $ transaction -> getElementsByTagName ( 'tid' ) -> item ( 0 ) -> nodeValue ; if ( $ transaction -> getElementsByTagName ( 'stateID' ) -> length > 0 ) { $ this -> stateId = $ transaction -> getElementsByTagName ( 'stateID' ) -> item ( 0 ) -> nodeValue ; } } }
Parse the Response message and save the data to the corresponding attributes
48,572
public function listPaymentMethods ( ) { $ request = new ListPaymentMethods ( $ this -> config -> getMerchantId ( ) ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new ListPaymentMethodsResponse ( $ this -> response ) ; return $ result ; }
Get all the payment methods that are available for the merchant by mPAY24
48,573
public function createTokenPayment ( $ pType , array $ additional = [ ] ) { $ request = new CreatePaymentToken ( $ this -> config -> getMerchantId ( ) ) ; $ request -> setPType ( $ pType ) ; $ request -> setAdditional ( $ additional ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new CreatePaymentTokenResponse ( $ this -> response ) ; return $ result ; }
Start a secure payment using the mPAY24 Tokenizer .
48,574
public function manualClear ( $ mpayTid , $ amount ) { $ request = new ManualClear ( $ this -> config -> getMerchantId ( ) ) ; $ request -> setMpayTid ( $ mpayTid ) ; $ request -> setAmount ( $ amount ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new ManualClearResponse ( $ this -> response ) ; return $ result ; }
Clear a transaction with an amount
48,575
public function manualCredit ( $ mpayTid , $ amount ) { $ request = new ManualCredit ( $ this -> config -> getMerchantId ( ) ) ; $ request -> setMpayTid ( $ mpayTid ) ; $ request -> setAmount ( $ amount ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new ManualCreditResponse ( $ this -> response ) ; return $ result ; }
Credit a transaction with an amount
48,576
public function manualReverse ( $ mpayTid ) { $ request = new ManualReverse ( $ this -> config -> getMerchantId ( ) ) ; $ request -> setMpayTid ( $ mpayTid ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new ManualReverseResponse ( $ this -> response ) ; return $ result ; }
Cancel a transaction
48,577
public function createCustomer ( $ type , $ customerId , $ payment = [ ] , $ additional = [ ] ) { $ request = new CreateCustomer ( $ this -> config -> getMerchantId ( ) ) ; $ request -> setPType ( $ type ) ; $ request -> setPaymentData ( $ payment ) ; $ request -> setCustomerId ( $ customerId ) ; $ request -> setAdditional ( $ additional ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new CreateCustomerResponse ( $ this -> response ) ; return $ result ; }
Create a new customer for recurring payments
48,578
public function deleteProfile ( $ customerId , $ profileId = null ) { $ request = new DeleteProfile ( $ this -> config -> getMerchantId ( ) ) ; $ request -> setCustomerId ( $ customerId ) ; $ request -> setProfileId ( $ profileId ) ; $ this -> request = $ request -> getXml ( ) ; $ this -> send ( ) ; $ result = new DeleteProfileResponse ( $ this -> response ) ; return $ result ; }
Deletes a profile .
48,579
protected function send ( ) { $ userAgent = 'mpay24-php/' . self :: VERSION ; $ ch = curl_init ( $ this -> getEtpURL ( ) ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , 'u' . $ this -> config -> getMerchantId ( ) . ':' . $ this -> config -> getSoapPassword ( ) ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , $ userAgent ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ this -> request ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; if ( $ this -> config -> isEnableCurlLog ( ) ) { $ fh = fopen ( $ this -> getMpay24CurlLogPath ( ) , 'a+' ) or $ this -> permissionError ( ) ; curl_setopt ( $ ch , CURLOPT_VERBOSE , 1 ) ; curl_setopt ( $ ch , CURLOPT_STDERR , $ fh ) ; } try { curl_setopt ( $ ch , CURLOPT_CAINFO , $ this -> config -> getCaCertPath ( ) . $ this -> config -> getCaCertFileName ( ) ) ; if ( $ this -> config -> getProxyHost ( ) ) { curl_setopt ( $ ch , CURLOPT_PROXY , $ this -> config -> getProxyHost ( ) . ':' . $ this -> config -> getProxyPort ( ) ) ; if ( $ this -> config -> getProxyUser ( ) ) { curl_setopt ( $ ch , CURLOPT_PROXYUSERPWD , $ this -> config -> getProxyUser ( ) . ':' . $ this -> config -> getProxyPass ( ) ) ; } if ( $ this -> config -> isVerifyPeer ( ) !== true ) { curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ this -> config -> isVerifyPeer ( ) ) ; } } $ this -> response = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; } catch ( \ Exception $ e ) { if ( $ this -> config -> isTestSystem ( ) ) { $ dieMSG = "Your request couldn't be sent because of the following error:" . "\n" . curl_error ( $ ch ) . "\n" . $ e -> getMessage ( ) . ' in ' . $ e -> getFile ( ) . ', line: ' . $ e -> getLine ( ) . '.' ; } else { $ dieMSG = self :: LIVE_ERROR_MSG ; } echo $ dieMSG ; } if ( isset ( $ fh ) && $ this -> config -> isEnableCurlLog ( ) ) { fclose ( $ fh ) ; } }
Create a curl request and send the created SOAP XML
48,580
protected function parseResponse ( $ body ) { $ this -> historyCount = ( int ) $ body -> getElementsByTagName ( 'historyEntry' ) -> length ; if ( $ this -> historyCount > 0 ) { for ( $ i = 0 ; $ i < $ this -> historyCount ; $ i ++ ) { $ this -> history [ $ i ] = [ ] ; $ historyEntry = $ body -> getElementsByTagName ( 'historyEntry' ) -> item ( $ i ) ; for ( $ j = 0 ; $ j < $ historyEntry -> childNodes -> length ; $ j ++ ) { $ name = $ historyEntry -> childNodes -> item ( $ j ) -> tagName ; $ value = $ historyEntry -> childNodes -> item ( $ j ) -> nodeValue ; $ this -> history [ $ i ] [ $ name ] = $ value ; } } } }
Parse the TransactionHistoryResponse message and save the data to the corresponding attributes
48,581
public function paymentPage ( $ mdxi ) { $ this -> integrityCheck ( ) ; libxml_use_internal_errors ( true ) ; if ( ! $ mdxi || ! $ mdxi instanceof Mpay24Order ) { $ this -> mpay24Sdk -> dieWithMsg ( "To be able to use the Mpay24Api you must create an Mpay24Order object (Mpay24Order.php) and fulfill it with a MDXI!" ) ; } $ mdxiXML = $ mdxi -> toXML ( ) ; $ payResult = $ this -> mpay24Sdk -> selectPayment ( $ mdxiXML ) ; $ this -> recordedLastMessageExchange ( 'PaymentPage' ) ; return $ payResult ; }
Return a redirect URL to start a payment
48,582
public function payment ( $ paymentType , $ tid , $ payment , $ additional ) { $ this -> integrityCheck ( ) ; $ payBackend2BackendResult = $ this -> mpay24Sdk -> acceptPayment ( $ paymentType , $ tid , $ payment , $ additional ) ; $ this -> recordedLastMessageExchange ( 'Payment' ) ; return $ payBackend2BackendResult ; }
Start a backend to backend payment
48,583
public function paymentHistory ( $ mpayTid ) { $ this -> integrityCheck ( ) ; $ response = $ this -> mpay24Sdk -> transactionHistory ( $ mpayTid ) ; $ this -> recordedLastMessageExchange ( 'TransactionHistory' ) ; return $ response ; }
Get all transaction s states for specified mPAYTID
48,584
public function listCustomers ( $ customerId = null , $ expiredBy = null , $ begin = null , $ size = null ) { $ this -> integrityCheck ( ) ; $ response = $ this -> mpay24Sdk -> listProfiles ( $ customerId , $ expiredBy , $ begin , $ size ) ; $ this -> recordedLastMessageExchange ( 'ListProfiles' ) ; return $ response ; }
Get all profile according to the given parameters
48,585
public function token ( $ paymentType , array $ additional = [ ] ) { $ this -> integrityCheck ( ) ; if ( $ paymentType !== 'CC' ) { die ( "The payment type '$paymentType' is not allowed! Currently allowed is only: 'CC'" ) ; } $ tokenResult = $ this -> mpay24Sdk -> createTokenPayment ( $ paymentType , $ additional ) ; $ this -> recordedLastMessageExchange ( 'CreatePaymentToken' ) ; return $ tokenResult ; }
Return a redirect URL to include in your web page
48,586
public function capture ( $ mpayTid , $ amount ) { $ this -> integrityCheck ( ) ; $ this -> validateAmount ( $ amount ) ; $ clearAmountResult = $ this -> mpay24Sdk -> manualClear ( $ mpayTid , $ amount ) ; $ this -> recordedLastMessageExchange ( 'CaptureAmount' ) ; return $ clearAmountResult ; }
Capture an amount of an authorized transaction
48,587
public function refund ( $ mpayTid , $ amount ) { $ this -> integrityCheck ( ) ; $ this -> validateAmount ( $ amount ) ; $ creditAmountResult = $ this -> mpay24Sdk -> manualCredit ( $ mpayTid , $ amount ) ; $ this -> recordedLastMessageExchange ( 'RefundAmount' ) ; return $ creditAmountResult ; }
Refund an amount of a captured transaction
48,588
public function cancel ( $ mpayTid ) { $ this -> integrityCheck ( ) ; $ cancelTransactionResult = $ this -> mpay24Sdk -> manualReverse ( $ mpayTid ) ; $ this -> recordedLastMessageExchange ( 'CancelTransaction' ) ; return $ cancelTransactionResult ; }
Cancel a authorized transaction
48,589
public function createCustomer ( $ paymentType , $ customerId , $ payment , $ additional = [ ] ) { $ this -> integrityCheck ( ) ; $ createCustomerRes = $ this -> mpay24Sdk -> createCustomer ( $ paymentType , $ customerId , $ payment , $ additional ) ; $ this -> recordedLastMessageExchange ( 'CreateCustomer' ) ; return $ createCustomerRes ; }
Create a customer for recurring payments
48,590
public function deleteProfile ( $ customerId , $ profileId = null ) { $ this -> integrityCheck ( ) ; $ response = $ this -> mpay24Sdk -> deleteProfile ( $ customerId , $ profileId ) ; $ this -> recordedLastMessageExchange ( 'DeleteProfile' ) ; return $ response ; }
Delete a profile .
48,591
protected function writeLog ( $ operation , $ info_to_log ) { $ serverName = php_uname ( 'n' ) ; if ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { $ serverName = $ _SERVER [ 'SERVER_NAME' ] ; } $ fh = fopen ( $ this -> mpay24Sdk -> getMpay24LogPath ( ) , 'a+' ) or die ( "can't open file" ) ; $ MessageDate = date ( "Y-m-d H:i:s" ) ; $ Message = $ MessageDate . " " . $ serverName . " Mpay24 : " ; $ result = $ Message . "$operation : $info_to_log\n" ; fwrite ( $ fh , $ result ) ; fclose ( $ fh ) ; }
Write a log into a file file system data base
48,592
public function subscribeCustomerToPlan ( $ planId , $ paymentToken , $ customerEmail , $ couponId = null ) { $ customer = Customer :: create ( [ 'source' => $ paymentToken , 'email' => $ customerEmail ] ) ; $ data = [ 'customer' => $ customer -> id , 'plan' => $ planId , ] ; if ( $ couponId ) { $ data [ 'coupon' ] = $ couponId ; } $ subscription = Subscription :: create ( $ data ) ; return $ customer ; }
Associate a new Customer object to an existing Plan .
48,593
public function subscribeExistingCustomerToPlan ( $ customerId , $ planId , $ parameters = [ ] ) { $ data = [ 'customer' => $ customerId , 'plan' => $ planId ] ; if ( $ parameters && is_array ( $ parameters ) ) { $ data = array_merge ( $ parameters , $ data ) ; } return Subscription :: create ( $ data ) ; }
Associate an existing Customer object to an existing Plan .
48,594
public function createCharge ( $ chargeAmount , $ chargeCurrency , $ paymentToken , $ stripeAccountId = null , $ applicationFee = 0 , $ chargeDescription = '' , $ chargeMetadata = [ ] ) { $ chargeOptions = [ 'amount' => $ chargeAmount , 'currency' => $ chargeCurrency , 'source' => $ paymentToken , 'description' => $ chargeDescription , 'metadata' => $ chargeMetadata ] ; if ( $ applicationFee && intval ( $ applicationFee ) > 0 ) { $ chargeOptions [ 'application_fee' ] = intval ( $ applicationFee ) ; } $ connectedAccountOptions = [ ] ; if ( $ stripeAccountId ) { $ connectedAccountOptions [ 'stripe_account' ] = $ stripeAccountId ; } return Charge :: create ( $ chargeOptions , $ connectedAccountOptions ) ; }
Create a new Charge from a payment token to an optional connected stripe account with an optional application fee .
48,595
public function createDestinationCharge ( $ chargeAmount , $ chargeCurrency , $ paymentToken , $ stripeAccountId , $ applicationFee , $ chargeDescription = '' , $ chargeMetadata = [ ] ) { $ chargeOptions = [ 'amount' => $ chargeAmount , 'currency' => $ chargeCurrency , 'source' => $ paymentToken , 'description' => $ chargeDescription , 'metadata' => $ chargeMetadata , 'destination' => [ 'amount' => $ chargeAmount - $ applicationFee , 'account' => $ stripeAccountId ] ] ; return Charge :: create ( $ chargeOptions ) ; }
Create a new Destination Charge from a payment token to a connected stripe account with an application fee .
48,596
public function chargeCustomer ( $ chargeAmount , $ chargeCurrency , $ customerId , $ stripeAccountId = null , $ applicationFee = 0 , $ chargeDescription = '' , $ chargeMetadata = [ ] ) { $ chargeOptions = [ 'amount' => $ chargeAmount , 'currency' => $ chargeCurrency , 'customer' => $ customerId , 'description' => $ chargeDescription , 'metadata' => $ chargeMetadata ] ; if ( $ applicationFee && intval ( $ applicationFee ) > 0 ) { $ chargeOptions [ 'application_fee' ] = intval ( $ applicationFee ) ; } $ connectedAccountOptions = [ ] ; if ( $ stripeAccountId ) { $ connectedAccountOptions [ 'stripe_account' ] = $ stripeAccountId ; } return Charge :: create ( $ chargeOptions , $ connectedAccountOptions ) ; }
Create a new Charge on an existing Customer object to an optional connected stripe account with an optional application fee
48,597
protected function build ( ) { $ operation = $ this -> buildOperation ( 'DeleteProfile' ) ; $ merchantID = $ this -> document -> createElement ( 'merchantID' , $ this -> merchantId ) ; $ operation -> appendChild ( $ merchantID ) ; $ customerId = $ this -> document -> createElement ( 'customerID' , $ this -> customerId ) ; $ operation -> appendChild ( $ customerId ) ; if ( $ this -> profileId ) { $ profileId = $ this -> document -> createElement ( 'profileID' , $ this -> profileId ) ; $ operation -> appendChild ( $ profileId ) ; } }
Build the request document body .
48,598
protected function parseResponse ( $ body ) { $ this -> all = ( int ) $ body -> getElementsByTagName ( 'paymentMethod' ) -> length ; if ( $ this -> all > 0 ) { for ( $ i = 0 ; $ i < $ this -> all ; $ i ++ ) { $ paymentMethod = $ body -> getElementsByTagName ( 'paymentMethod' ) -> item ( $ i ) ; $ this -> pMethIds [ $ i ] = $ paymentMethod -> getAttribute ( "id" ) ; $ this -> pTypes [ $ i ] = $ paymentMethod -> getElementsByTagName ( 'pType' ) -> item ( 0 ) -> nodeValue ; $ this -> brands [ $ i ] = $ paymentMethod -> getElementsByTagName ( 'brand' ) -> item ( 0 ) -> nodeValue ; $ this -> descriptions [ $ i ] = $ paymentMethod -> getElementsByTagName ( 'description' ) -> item ( 0 ) -> nodeValue ; } } }
Parse the ListPaymentMethodsResponse message and save the data to the corresponding attributes
48,599
protected function xmlEncode ( $ txt ) { $ txt = str_replace ( '<' , '&lt;' , $ txt ) ; $ txt = str_replace ( '>' , '&gt;' , $ txt ) ; $ txt = str_replace ( '&amp;apos;' , "'" , $ txt ) ; $ txt = str_replace ( '&amp;quot;' , '"' , $ txt ) ; return $ txt ; }
Encode the XML - characters in a string