Please Log in to join the conversation.
/**
* Returns single payment request parameters for gateway depending on basket (without specifying payment type)
*
* @param cbpaidPaymentBasket $paymentBasket paymentBasket object
* @return array Returns array $requestParams
*/
protected function getSinglePaymentRequstParams( $paymentBasket ) {
return array( 'amount' => sprintf( '%0.2f', $paymentBasket->mc_gross ),
'currency_code' => $paymentBasket->mc_currency,
'custom' => $paymentBasket->id
);
}
/**
* Optional function: only needed for recurring payments:
* Returns subscription request parameters for gateway depending on basket (without specifying payment type)
*
* @param cbpaidPaymentBasket $paymentBasket paymentBasket object
* @return array Returns array $requestParams
*/
protected function getSubscriptionRequstParams( $paymentBasket ) {
return $this->getSinglePaymentRequstParams( $paymentBasket );
}
/**
* Handles the gateway-specific result of payments (redirects back to this site and gateway notifications). WARNING: unchecked access !
*
* @param cbpaidPaymentBasket $paymentBasket New empty object. returning: includes the id of the payment basket of this callback (strictly verified, otherwise untouched)
* @param array $postdata _POST data for saving edited tab content as generated with getEditTab
* @param string $result result= get parameter, other than 'notify', 'success' or 'cancel'.
* @return string HTML to display if frontend, text to return to gateway if notification, FALSE if registration cancelled and ErrorMSG generated, or NULL if nothing to display
*/
protected function handleOtherResult( $paymentBasket, $postdata, $result ) {
$return = null;
if ( $result == 'payment' ) {
$paymentBasketId = (int) cbGetParam( $postdata, 'custom', 0 );
$exists = $paymentBasket->load( (int) $paymentBasketId );
if ( $exists && ( sprintf( '%.2f', $paymentBasket->mc_gross ) == cbGetParam( $postdata, 'amount' ) ) && ( $paymentBasket->mc_currency == cbGetParam( $postdata, 'currency_code' ) ) ) {
$request = 'YOUR_XML_REQUEST';
$response = null;
$status = null;
$error = $this->_httpsRequest( YOUR_XML_REQUEST_URL, $request, 45, $response, $status, 'post', 'xml', '*/*', true, 443 );
cbimport( 'cb.xml.simplexml' );
$requestdata = null;
if ( $response ) {
$xmlresponse = new CBSimpleXMLElement( $response );
if ( $xmlresponse ) {
$requestdata = $this->xmlTagValuesToArray( $xmlresponse );
}
}
if ( ( ! $error ) && ( $status == 200 ) && $requestdata ) {
$redirect = cbGetParam( $requestdata, 'YOUR_REQUEST_RESPONSE_REDIRECT_URL' );
if ( $redirect ) {
cbRedirect( $redirect );
} else {
$this->_setLogErrorMSG( 3, null, $this->getPayName() . ': merchantCheckout responded without a redirect url! Error: ' . cbGetParam( $requestdata, 'error-message' ), CBPTXT::T( 'Checkout failed.' ) . ' ' . CBPTXT::T( 'Please contact site administrator to check error log.' ) );
$return = false;
}
} else {
if ( $requestdata ) {
$this->_setLogErrorMSG( 3, null, $this->getPayName() . ': merchantCheckout failed to respond! Error: ' . cbGetParam( $requestdata, 'error-message' ), CBPTXT::T( 'Checkout failed.' ) . ' ' . CBPTXT::T( 'Please contact site administrator to check error log.' ) );
} else {
$this->_setLogErrorMSG( 3, null, $this->getPayName() . ': merchantCheckout failed to respond. Please check Merchant ID and Merchant Key settings', CBPTXT::T( 'Checkout failed.' ) . ' ' . CBPTXT::T( 'Please contact site administrator to check error log.' ) );
}
$return = false;
}
} else {
$this->_setErrorMSG( CBPTXT::T( 'Payment basket does not login.' ) );
$return = false;
}
}
return $return;
}
Please Log in to join the conversation.
$result[GenerateRequest][amount]=sprintf( '%0.2f', $paymentBasket->mc_gross );
return $result;
Please Log in to join the conversation.
<GenerateRequest>
<PxPayUserId>' . $this->getAccountParam( 'pspid' ) . '</PxPayUserId>
<PxPayKey>' . $this->getAccountParam( 'pspkey' ) . '</PxPayKey>
<AmountInput>' . sprintf( '%.2f', $paymentBasket->mc_gross ) . '</AmountInput>
<CurrencyInput>' . $paymentBasket->mc_currency . '</CurrencyInput>
<MerchantReference>' . htmlspecialchars( $paymentBasket->item_name ) . '</MerchantReference>
<EmailAddress></EmailAddress>
<TxnData1>28 Grange Rd</TxnData1>
<TxnData2>Auckland</TxnData2>
<TxnData3>NZ</TxnData3>
<TxnType>Purchase</TxnType>
<TxnId>' . $paymentBasket->id . '</TxnId>
<BillingId></BillingId>
<EnableAddBillCard>0</EnableAddBillCard>
<UrlSuccess>' . $this->getSuccessUrl( $paymentBasket ) . '</UrlSuccess>
<UrlFail>' . $this->getCancelUrl( $paymentBasket ) . '</UrlFail>
<Opt>TO=0901142221</Opt>
</GenerateRequest>
Please Log in to join the conversation.