/** * Stripe Class Constructor * * @since 1.4 */ function PMProGateway_stripe($gateway = NULL) { $this->gateway = $gateway; $this->gateway_environment = pmpro_getOption("gateway_environment"); $this->loadStripeLibrary(); Stripe::setApiKey(pmpro_getOption("stripe_secretkey")); Stripe::setAPIVersion("2015-07-13"); return $this->gateway; }
/** * Stripe Class Constructor * * @since 1.4 */ function __construct($gateway = NULL) { $this->gateway = $gateway; $this->gateway_environment = pmpro_getOption("gateway_environment"); $this->dependencies(); $this->loadStripeLibrary(); Stripe::setApiKey(pmpro_getOption("stripe_secretkey")); Stripe::setAPIVersion("2015-07-13"); return $this->gateway; }
public function send_gift_manual() { global $wpdb, $ntm_mail; if (isset($_POST['send_gift'])) { $option = get_option('giftbit'); if ($option['amount'] >= $_POST['gift_amount']) { $this->fa_lead_options = get_option('fa_lead_settings'); Stripe::setApiKey($this->fa_lead_options['api_key']); Stripe::setAPIVersion("2015-07-13"); $customer_id = get_user_meta(get_blog_option(get_current_blog_id(), 'agent_id'), "pmpro_stripe_customerid"); $amount = $this->fa_lead_options['admin_fee'] * 100; $giftAmount = $this->fa_lead_options['init_gift']; $invoice_item = Stripe_InvoiceItem::create(array('customer' => $customer_id, 'amount' => $this->fa_lead_options['admin_fee'], 'currency' => 'usd', 'description' => 'One-time setup fee')); $invoice = Stripe_Invoice::create(array('customer' => $customer_id)); $result = $invoice->pay(); if (isset($result->object) && $result->object == 'invoice') { $data = array('endorser_id' => $_POST['endorser_id'], 'amout' => $_POST['gift_amount'], 'agent_id' => get_current_user_id(), 'created' => date("Y-m-d H:i:s")); $wpdb->insert($wpdb->prefix . "gift_transaction", $data); $gift_id = $wpdb->insert_id; $ntm_mail->send_gift_mail('get_manualgift_mail', $_POST['endorser_id'], $gift_id); $option['amount'] = $option['amount'] - $_POST['gift_amount']; update_option("giftbit", $option); $message = "Gift send successfully!!"; } else { $message = "Error when payment"; } } else { $message = "Error! Insufficient balance!"; } } //print_r(get_users(array('role'=>'endorser'))); ?> <script> jQuery(document).ready(function(){ jQuery("#gift_amount").change(function(){ if(jQuery("#gift_amount").val() <= jQuery("#poststuff").data('amount')) jQuery("#send_gift").show(); else { alert("Insufficient balance"); jQuery("#send_gift").hide(); } }); }); </script> <div data-amount="<?php echo get_option('giftbit')['amount']; ?> " id="poststuff" class="wrap"> <h2>Send Gift By Manual</h2> <?php if (isset($message)) { ?> <div id="message" class="updated"><p><?php echo $message; ?> </p></div> <?php } ?> <div class="postbox"> <div class="inside group"> <form name="myform" method="post" > <table id="country" class="form-table"> <tr> <th scope="row"><label for="blogname">Endorser</label></th> <td> <select class="regular-text" name="endorser_id"> <option value="">Select Endorser</option> <?php foreach (get_users(array('role' => 'endorser')) as $res) { ?> <option value="<?php _e($res->data->ID); ?> "><?php _e($res->data->user_login . ' - ' . $res->data->user_email); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th scope="row"><label for="blogname">Gift Amount</label></th> <td> <select class="regular-text" id="gift_amount" name="gift_amount"> <option value="5">5$</option> <option value="10">10$</option> <option value="25">25$</option> <option value="50">50$</option> <option value="100">100$</option> <option value="150">150$</option> <option value="200">200$</option> </select> </td> </tr> </table> <p class="submit"> <input style="display:none;" id="send_gift" name="send_gift" class="button-primary seeker_btn" value="<?php _e('Save Changes'); ?> " type="submit" /> </p> </form> </div> </div> </div> <?php }