本文整理汇总了PHP中Payment::set_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::set_fields方法的具体用法?PHP Payment::set_fields怎么用?PHP Payment::set_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payment
的用法示例。
在下文中一共展示了Payment::set_fields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public function test()
{
// In Kohana, all views are loaded and treated as objects.
$this->template->content = new View('test_cc');
$this->template->metaDescription = 'A new generation of custom chocolate favors is here with our state-of-the-art My Chocolate Hearts customizers. We help you design your own personalized and custom chocolate hearts for any occasion from party to wedding, bridal and baby shower, corporate and many more. Call us toll free at 1-866-230-7730.';
$this->template->metaKeywords = 'chocolate hearts, custom chocolate hearts, personalized chocolate hearts, chocolate favors, custom chocolate favors, party favors, personalized chocolate favors, chocolate casino chips, chocolate poker chips, custom chocolate casino chips, casino party favors, wedding favors, personalized wedding favors, baby shower favors, bridal shower favors, chocolate gelt, chocolate gold hearts, chocolate party favors, chocolate candy favors, custom chocolate, custom chocolate poker chips, corporate favors';
$payment = new Payment('Authorize');
$attributes = array('card_num' => '4222222222222', 'exp_date' => '01/13', 'amount' => '2.00', 'ship_to_first_name' => 'Alexander', 'ship_to_last_name' => 'Finger', 'ship_to_address' => '600 Unicorn Park Dr.', 'ship_to_city' => 'Woburn', 'ship_to_state' => 'MA', 'ship_to_zip' => '01801', 'ship_to_country' => 'USA', 'first_name' => 'Alexander', 'last_name' => 'Finger', 'address' => '600 Unicorn Park Dr.', 'city' => 'Woburn', 'state' => 'MA', 'zip' => '01801', 'country' => 'USA', 'x_test_request' => 'TRUE');
$status = 0;
$payment->set_fields($attributes);
$finance_state = 'CHARGING';
echo "<pre>";
var_dump($payment);
echo "</pre>";
break;
if ($payment->process()) {
$finance_state = 'CHARGED';
$status = 2;
echo "<pre>";
var_dump($payment);
var_dump($finance_state);
var_dump($status);
echo "</pre>";
//$this->order->save();
//return true;
} else {
$this->order->finance_state = 'DENIED';
$this->order->status = 3;
//$this->order->save();
throw new Exception('Payment operation failed (' . $payment->getLastError() . ')');
}
// You can assign anything variable to a view by using standard OOP
// methods. In my welcome view, the $title variable will be assigned
// the value I give it here.
$this->template->title = 'My Chocolate Hearts';
}
示例2: pay
public function pay($method)
{
$payment = new Payment($method);
if ($method == 'Paypal') {
Session::instance()->delete('paypal_token');
$order = new Order_Model($this->order->id);
//$inv = uniqid('payPal_');
$inv = $this->getTransID();
$order->trans_id = $inv;
$order->save();
$attributes = array('AMT' => $this->total(), 'INVNUM' => $inv, 'SHIPTONAME' => $this->order->shipping->first_name . ' ' . $this->order->shipping->last_name, 'SHIPTOSTREET' => $this->order->shipping->address1, 'SHIPTOCITY' => $this->order->shipping->city, 'SHIPTOCOUNTRYCODE' => $this->order->shipping->country, 'SHIPTOSTATE' => $this->order->shipping->state, 'SHIPTOZIP' => $this->order->shipping->zip);
//$this->payment->GETDETAILS = FALSE;
} else {
if (!valid::credit_card($this->order->payment->card->card_num)) {
throw new Exception('Invalid credit card data');
}
$attributes = array('card_num' => $this->order->payment->card->card_num, 'exp_date' => $this->order->payment->card->exp_date, 'amount' => $this->total(), 'ship_to_first_name' => $this->order->shipping->first_name, 'ship_to_last_name' => $this->order->shipping->last_name, 'ship_to_address' => $this->order->shipping->address1, 'ship_to_city' => $this->order->shipping->city, 'ship_to_state' => $this->order->shipping->state, 'ship_to_zip' => $this->order->shipping->zip, 'ship_to_country' => $this->order->shipping->country, 'first_name' => $this->order->billing->first_name, 'last_name' => $this->order->billing->last_name, 'address' => $this->order->billing->address1, 'city' => $this->order->billing->city, 'state' => $this->order->billing->state, 'zip' => $this->order->billing->zip, 'country' => $this->order->billing->country);
}
$payment->set_fields($attributes);
$this->order->finance_state = 'CHARGING';
if ($payment->process()) {
$this->order->finance_state = 'CHARGED';
$this->order->status = 2;
//$this->order->save();
return true;
} else {
$this->order->finance_state = 'DENIED';
$this->order->status = 3;
//$this->order->save();
throw new Exception('Payment operation failed (' . $payment->getLastError() . ')');
}
}
示例3: order_status
public function order_status()
{
//-----------------------------------------------\\
// This is the LAST checkout page where the \\
// payment is placed using Authorize.net and \\
// then lets the user know the payment status \\
//-----------------------------------------------\\
$db = new Database();
$this->template->content = new View('order_status');
// Load Captcha library, you can supply the name of the config group you would like to use.
//$captcha = new Captcha;
// Ban bots (that accept session cookies) after 50 invalid responses.
// Be careful not to ban real people though! Set the threshold high enough.
//if ($captcha->invalid_count() > 49)
// exit('Bye! Stupid bot.');
$this->template->metaDescription = $this->description;
$this->template->metaKeywords = $this->keywords;
$this->template->metaTitle = $this->title;
// You can assign anything variable to a view by using standard OOP
// methods. In my welcome view, the $title variable will be assigned
// the value I give it here.
$this->template->title = $this->title;
// Captcha::valid() is a static method that can be used as a Validation rule also.
//if (Captcha::valid($this->input->post('captcha_response'))) {
// echo '<p style="color:green">Good answer!</p>';
//} else {
// $this->template->content->status = 3;
// $this->template->content->trans_status = "Your Captcha response was incorrect";
// exit();
//}
$order = ORM::factory('order')->where('id', $_POST['orderid'])->where('user_id', User_Model::logged_user()->id)->find();
$order->shipping_total = $_POST["shippingtotal"];
$order->save();
$order->refreshTotals();
$ccnum = isset($_POST["cnumber"]) ? $_POST["cnumber"] : '';
$nameoncard = isset($_POST["cname"]) ? $_POST["cname"] : '';
$cardexp = isset($_POST["expiration"]) ? $_POST["expiration"] : '';
$cardcode = isset($_POST["verification"]) ? $_POST["verification"] : '';
$this->template->content->order = $order;
$billing_info = $order->user->user_billing_info;
$shipping_info = $order->user->user_shipping_info;
$cardfname = $billing_info->firstname;
$cardlname = $billing_info->lastname;
$this->template->content->shippingName = $shipping_info->firstname . ' ' . $shipping_info->lastname;
$this->template->content->shippingAddress = trim($shipping_info->address1 . ' ' . $shipping_info->address2);
$this->template->content->shippingCity = $shipping_info->city . ', ' . $shipping_info->state . ', ' . $shipping_info->country . ' ' . $shipping_info->zip;
$this->template->content->billingName = $cardfname . ' ' . $cardlname;
$this->template->content->billingAddress = trim($billing_info->address1 . ' ' . $billing_info->address2);
$this->template->content->billingCity = $billing_info->city . ', ' . $billing_info->state . ', ' . $billing_info->country . ' ' . $billing_info->zip;
$shippingInfo = $shipping_info->firstname . ' ' . $shipping_info->lastname . '<br/>';
$shippingInfo .= trim($shipping_info->address1 . ' ' . $shipping_info->address2) . '<br />';
$shippingInfo .= $shipping_info->city . ', ' . $shipping_info->state . ' ' . $shipping_info->zip . '<br />';
$shippingInfo .= $shipping_info->country;
$billingInfo = $cardfname . ' ' . $cardlname . '<br/>';
$billingInfo .= trim($billing_info->address1 . ' ' . $billing_info->address2) . '<br />';
$billingInfo .= $billing_info->city . ', ' . $billing_info->state . ' ' . $billing_info->zip . '<br />';
$billingInfo .= $billing_info->country;
$dateTime = date('Y-m-d H:i:s');
$additionalFees = 0;
$description = '';
foreach ($order->orders_baskets as $ob) {
$additionalFees += $ob->second_side_fee;
$product_name = $ob->product->name;
if ($ob->packaging_id != 0) {
$product_name .= ' - ' . $ob->packaging->name;
}
$description .= $ob->qty . ' x ' . $product_name . ' = ' . money_format('%.2n', $ob->subtotal) . '<br/>';
}
if ($additionalFees != 0) {
$description .= 'Additional Fees: ' . money_format('%.2n', $additionalFees) . '<br/>';
}
if (!empty($order->comment)) {
$description .= 'Comment:' . $order->comment . '<br/>';
}
$total_text = 'Subtotal: ' . money_format('%.2n', $order->subtotal) . '<br/>';
$total_text .= 'Shipping:' . money_format('%.2n', $order->shipping_total) . '<br/>';
$total_text .= 'Total: ' . money_format('%.2n', $order->order_total);
switch ($_POST['payment_method']) {
case 'credit_card':
$payment = new Payment('Authorize');
$attributes = array('card_num' => $ccnum, 'exp_date' => $cardexp, 'card_code' => $cardcode, 'amount' => number_format($order->order_total, 2, '.', ''), 'ship_to_first_name' => $shipping_info->firstname, 'ship_to_last_name' => $shipping_info->lastname, 'ship_to_address' => trim($shipping_info->address1 . ' ' . $shipping_info->address2), 'ship_to_city' => $shipping_info->city, 'ship_to_state' => $shipping_info->state, 'ship_to_zip' => $shipping_info->zip, 'first_name' => $cardfname, 'last_name' => $cardlname, 'address' => trim($billing_info->address1 . ' ' . $billing_info->address2), 'city' => $billing_info->city, 'state' => $billing_info->state, 'zip' => $billing_info->zip, 'phone' => $billing_info->phone1, 'x_test_request' => 'FALSE');
$payment->set_fields($attributes);
if ($payment->process()) {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!
// if the payment was SUCCESSFUL
$this->template->content->trans_status = $payment->get_response();
$this->template->content->status = 1;
$transaction_id = $payment->get_transaction_id();
$paymentstatus = 3;
$orderstatus = 2;
} else {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!
// if the payment FAILED
$this->template->content->status = 3;
$this->template->content->trans_status = $payment->get_response();
$orderstatus = 3;
$paymentstatus = 1;
}
break;
// case 'paypal':
//.........这里部分代码省略.........