@ -84,6 +84,12 @@ function fulcrm_shoppingcart_theme( $existing, $type, $theme, $path ) {
'fulcrm_shoppingcart_transaction_item' => array( 'variables' => array( 'item' => null ), // data returned from fulcrm API
'fulcrm_shoppingcart_transaction_item' => array( 'variables' => array( 'item' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_item',
'template' => 'fulcrm_shoppingcart_transaction_item',
),
),
'fulcrm_shoppingcart_transaction_mailshots' => array( 'variables' => array( 'transaction' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_mailshots',
),
'fulcrm_shoppingcart_transaction_mailshot' => array( 'variables' => array( 'mailshot' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_mailshot',
),
);
);
}
}
@ -414,12 +420,12 @@ function fulcrm_shoppingcart_checkout() {
$transaction_data2 = fulcrm_apiv2_PATCH( $transaction_data[ 'data' ][ 'url' ],
$transaction_data2 = fulcrm_apiv2_PATCH( $transaction_data[ 'data' ][ 'url' ],
$transaction_push, $query = array( 'expand' => implode( ',', array( 'd',
$transaction_push, $query = array( 'expand' => implode( ',', array( 'd',
'lineitems',
// 'lineitems',
'lineitems.d',
// 'lineitems.d',
'lineitems.content_object',
// 'lineitems.content_object',
// XXX 'lineitems.content_object.d',
// XXX 'lineitems.content_object.d',
'paymentitems',
// 'paymentitems',
'paymentitems.d',
// 'paymentitems.d',
) ) ) );
) ) ) );
if ( $transaction_data2[ 'success' ] ) {
if ( $transaction_data2[ 'success' ] ) {
return theme( 'fulcrm_shoppingcart_transaction_checkout', array( 'transaction' => $transaction_data2[ 'data' ] ) );
return theme( 'fulcrm_shoppingcart_transaction_checkout', array( 'transaction' => $transaction_data2[ 'data' ] ) );
@ -432,9 +438,36 @@ function fulcrm_shoppingcart_checkout() {
}
}
function fulcrm_shoppingcart_checkout_success( $transaction_id, $hmac ) {
function fulcrm_shoppingcart_checkout_success( $transaction_id, $hmac ) {
return 'success';
if ( fulcrm_crypto_check_object_id_hmac( 'transaction', $transaction_id, $hmac ) ) {
$transaction_data = fulcrm_apiv2_GET( 'transaction/' . $transaction_id . '/', $query = array( 'expand' => implode( ',', array( 'd',
'lineitems',
'lineitems.d',
'lineitems.content_object',
'mailshots',
'mailshots.campaign',
'paymentitems',
'paymentitems.d',
) ) ) );
if ( $transaction_data[ 'success' ] ) {
if ( $transaction_data[ 'data' ][ 'completed' ] )
drupal_set_message( t('Thank you for your order.'), 'status' );
$rval = '';
if ( $transaction_data[ 'data' ][ 'mailshots' ] )
$rval .= theme( 'fulcrm_shoppingcart_transaction_mailshots', array( 'transaction' => $transaction_data[ 'data' ] ) );
$rval .= '<pre>' . print_r( $transaction_data[ 'data' ], 1 ) . '</pre>'; // XXX debug
return $rval;
} else {
drupal_set_message( t('Although your transaction appears to have completed successfully, there has been a problem fetching the full transaction data.'), 'error' );
}
}
}
}
function fulcrm_shoppingcart_checkout_failure( $transaction_id, $hmac ) {
function fulcrm_shoppingcart_checkout_failure( $transaction_id, $hmac ) {
return 'failure';
if ( fulcrm_crypto_check_object_id_hmac( 'transaction', $transaction_id, $hmac ) ) {
return 'failure';
}
}
}