예제 #1
0
function _send_payment_request_callback()
{
    Braintree_Configuration::environment('sandbox');
    Braintree_Configuration::merchantId('4r57w2h7hgyqk52g');
    Braintree_Configuration::publicKey('4y98n9vt93pvqpgj');
    Braintree_Configuration::privateKey('32d966b730def400269d835b030fd109');
    /*$amount = 10.30;
      $card = '4111111111111111';
      $padDateMonth = '10';
      $expDateYear = '20';
      $cvv = '911';
      */
    $card_detail = explode('/', $_POST['expire_card']);
    $amount = $_POST['amount'];
    $card = $_POST['credit_card'];
    $padDateMonth = $card_detail[0];
    $expDateYear = $card_detail[1];
    $cvv = $_POST['cvv'];
    $result = Braintree_Transaction::sale(array('amount' => round(floatval($amount)), 'creditCard' => array('number' => $card, 'expirationMonth' => $padDateMonth, 'expirationYear' => $expDateYear, 'cvv' => $cvv)));
    if ($result->success == 1) {
        $trans_id = $result->transaction->_attributes['id'];
        $donatorData = array('trans_id' => $trans_id, 'team_id' => $_POST['team_id'], 'payment_type' => 'Online', 'amount' => $amount, 'donator_name' => $_POST['donator_name'], 'donator_email' => $_POST['donator_email'], 'trans_detail' => serialize($result->transaction->_attributes));
        $objDonator = new tblDonator();
        $objDonator->insert($donatorData);
        echo 1;
    } else {
        echo 0;
    }
    die;
}
<h2>Add New Donator</h2>
<div class="wrap">
  <?php 
$team_list = get_team_list();
if (isset($_POST['btnCFSDonator'])) {
    $objDonator = new tblDonator();
    $result = $objDonator->insert($_POST['cfs_donator']);
    $message = '';
    if ($result) {
        $message = 'Add new donator successfully. <a href="admin.php?page=cfs_donator">view all donators</a></a>';
    } else {
        $message = 'There is some error. Please try it again!';
    }
    echo '<div id="message" class="updated below-h2"><p>' . $message . '</p></div><br />';
}
?>
  <div class="postbox " style="padding: 10px">
      <div class="misc-pub-section ">
      <form action="" method="post">
          <table class="form-table">
                <tr>
                      <th><label for="cfs_donator[trans_id]">Transaction ID</label></th>
                      <td><input name="cfs_donator[trans_id]" id="cfs_donator[trans_id]" value="" /></td>
                </tr>
                <tr>
                      <th><label for="cfs_donator[payment_type]">Payment Method</label></th>
                      <td>
                            <select name="cfs_donator[payment_type]" id="cfs_donator[payment_type]">
                                  <option value="cash">Cash</option>
                                  <option value="check">Check</option>
                            </select>