need to cope with cancelled/failed transactions

master
Marek Isalski 6 years ago
parent aad442c3a5
commit 889bd68900

@ -132,6 +132,9 @@ function fulcrm_shoppingcart_theme( $existing, $type, $theme, $path ) {
'fulcrm_shoppingcart_transaction_complete' => array( 'variables' => array( 'transaction' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_complete',
),
'fulcrm_shoppingcart_transaction_incomplete' => array( 'variables' => array( 'transaction' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_incomplete',
),
'fulcrm_shoppingcart_transaction_mailshots' => array( 'variables' => array( 'transaction' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_mailshots',
),
@ -377,6 +380,10 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
'#markup' => '<h3>' . check_plain( $product[ 'name' ] ) . '</h3>',
);
drupal_set_title( check_plain( $eventbookingtype[ 'event' ][ 'name' ] ) . ', ' .
check_plain( $eventbookingtype[ 'name' ] ) . ', ' .
check_plain( $product_data[ 'data' ][ 'name' ] ) );
// $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] );
if ( array_key_exists( 'name', $person ) )
@ -472,6 +479,8 @@ function fulcrm_shoppingcart_buy_generic_product_form( $form, &$form_state, $per
'#markup' => '<h3>' . check_plain( $product[ 'name' ] ) . '</h3>',
);
drupal_set_title( check_plain( $product_data[ 'data' ][ 'name' ] ) );
$form[ 'actions' ] = array( '#type' => 'actions' );
$form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
'#value' => t('Add to Cart'),
@ -769,7 +778,7 @@ function fulcrm_shoppingcart_checkout_failure( $transaction_id, $hmac ) {
}
foreach ( $hook_results as $hook_result )
return $hook_result;
return 'failure';
return theme( 'fulcrm_shoppingcart_transaction_complete', array( 'transaction' => $transaction_data[ 'data' ] ) );
}
}

@ -1,5 +1,24 @@
<div class="col col-xs-12 col-sm-12 col-md-8 col-lg-8">
<?php if ( $transaction[ 'failed' ] ): ?>
<div class="alert alert-danger" role="alert">This transaction <strong>failed</strong> on
<?php
$tz = new DateTimeZone('UTC');
$failed = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$transaction['failed'],$timezone=$tz);
if ( $failed )
print $failed->format( 'j/M/Y \@ g:ia' );
?></div>
<?php endif; ?>
<?php if ( $transaction[ 'cancelled' ] ): ?>
<div class="alert alert-warning" role="alert">This transaction was <strong>cancelled</strong> on
<?php
$tz = new DateTimeZone('UTC');
$cancelled = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$transaction['cancelled'],$timezone=$tz);
if ( $cancelled )
print $cancelled->format( 'j/M/Y \@ g:ia' );
?>.</div>
<?php endif; ?>
<table class="table">
<caption><?php print check_plain( $transaction[ 'name' ] ); ?></caption>

@ -0,0 +1,77 @@
<div class="col col-xs-12 col-sm-12 col-md-8 col-lg-8">
<?php if ( $transaction[ 'failed' ] ): ?>
<div class="alert alert-danger" role="alert">This transaction <strong>failed</strong> on
<?php
$tz = new DateTimeZone('UTC');
$failed = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$transaction['failed'],$timezone=$tz);
if ( $failed )
print $failed->format( 'j/M/Y \@ g:ia' );
?></div>
<?php endif; ?>
<?php if ( $transaction[ 'cancelled' ] ): ?>
<div class="alert alert-warning" role="alert">This transaction was <strong>cancelled</strong> on
<?php
$tz = new DateTimeZone('UTC');
$cancelled = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$transaction['cancelled'],$timezone=$tz);
if ( $cancelled )
print $cancelled->format( 'j/M/Y \@ g:ia' );
?>.</div>
<?php endif; ?>
<table class="table">
<caption><?php print check_plain( $transaction[ 'name' ] ); ?></caption>
<thead>
<tr>
<th>Item</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php if ( array_key_exists( 'lineitems', $transaction ) ) { print theme( 'fulcrm_shoppingcart_transaction_items', array( 'items' => $transaction[ 'lineitems' ] ) ); } ?>
</tbody>
<tfoot>
<tr>
<th colspan="3">
Total
</th>
<th class="text-right">
<?php $any = false; ?>
<?php if ( count( $transaction[ '_price' ][ 'total' ] ) ): ?>
<?php foreach ( $transaction[ '_price' ][ 'total' ] as $currency => $price ): ?>
<?php if ( $price[ 'gross' ] ): ?>
<?php $any = true; ?>
<div><?php print $price[ 'format_gross' ]; ?></div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( !$any ): ?>
<em>free</em>
<?php endif; ?>
</th>
</tr>
</tfoot>
</table>
</div>
<div class="col col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">Information</h3></div>
<div class="panel-body">
<p><strong>Attempted:</strong> <?php
$tz = new DateTimeZone('UTC');
$created = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$transaction['created'],$timezone=$tz);
if ( $created )
print $created->format( 'j/M/Y \@ g:ia' );
else
print '<em>pending</em>';
?></p>
</div>
</div>
</div>
Loading…
Cancel
Save