/
my-card.php
61 lines (57 loc) · 2 KB
/
my-card.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<h3><?php _e( 'Cards', 'omise' ); ?></h3>
<div id="omise_card_panel">
<table>
<tr>
<th><?php _e( 'Name', 'omise' ); ?></th>
<th><?php _e( 'Number', 'omise' ); ?></th>
<th><?php _e( 'Created date', 'omise' ); ?></th>
<th><?php _e( 'Action', 'omise' ); ?></th>
</tr>
<tbody>
<?php if ( isset( $viewData['existingCards']['data'] ) ): ?>
<?php foreach( $viewData['existingCards']['data'] as $card ): ?>
<?php
$nonce = wp_create_nonce( 'omise_delete_card_' . $card['id'] );
$created_date = date_i18n( get_option( 'date_format' ), strtotime($card['created']));
?>
<tr>
<td><?= $card['name'] ?></td>
<td>XXXX XXXX XXXX <?= $card['last_digits'] ?></td>
<td><?= $created_date ?></td>
<td>
<button
class='button delete_card'
data-card-id=<?= $card['id'] ?>
data-delete-card-nonce=<?= $nonce ?>
>
<?php _e( 'Delete', 'omise' ); ?>
</button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<h4><?php _e( 'Add new card', 'omise' ); ?></h4>
<form name="omise_cc_form" id="omise_cc_form">
<?php wp_nonce_field('omise_add_card','omise_add_card_nonce'); ?>
<?php if($viewData['secure_form_enabled']): ?>
<div id="omise-card" style="width:100%; max-width: 400px;"></div>
<?php else: ?>
<fieldset>
<?php require_once( __DIR__ . '/../payment/form-creditcard.php' ); ?>
<div class="clear"></div>
</fieldset>
<?php endif; ?>
</form>
<button id="omise_add_new_card" class="button"><?php _e( 'Save card', 'omise' ); ?></button>
</div>
<?php if($viewData['secure_form_enabled']): ?>
<script>
window.CARD_FORM_THEME = "<?php echo $viewData['cardFormTheme'] ?>";
window.FORM_DESIGN = JSON.parse(`<?php echo json_encode($viewData['formDesign']) ?>`);
window.CARD_BRAND_ICONS = JSON.parse(`<?php echo json_encode($viewData['cardIcons']) ?>`);
window.LOCALE = `<?php echo get_locale(); ?>`;
window.OMISE_CUSTOM_FONT_OTHER = 'Other';
</script>
<?php endif; ?>