本文整理汇总了PHP中Checkout::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Checkout::get方法的具体用法?PHP Checkout::get怎么用?PHP Checkout::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Checkout
的用法示例。
在下文中一共展示了Checkout::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
public function getData(Order $order)
{
$data = array();
$gateway = Checkout::get($order)->getSelectedPaymentMethod();
//provide valid dummy credit card data
if ($gateway === "Dummy") {
$data = array_merge(array('name' => 'Joe Bloggs', 'number' => '4242424242424242', 'cvv' => 123), $data);
}
return $data;
}
示例2: getGateway
/**
* @param Order $order
*
* @return \Omnipay\Common\AbstractGateway|\Omnipay\Braintree\Gateway
*/
protected function getGateway($order)
{
if (!isset($this->gateway)) {
$tempPayment = new Payment(['Gateway' => Checkout::get($order)->getSelectedPaymentMethod(false)]);
$service = PurchaseService::create($tempPayment);
$this->gateway = $service->oGateway();
$this->isBraintree = $this->gateway instanceof \Omnipay\Braintree\Gateway;
}
return $this->gateway;
}
示例3: submitpayment
/**
* Behaviour can be overwritten by creating a processPaymentResponse method
* on the controller owning this form. It takes a Symfony\Component\HttpFoundation\Response argument,
* and expects an SS_HTTPResponse in return.
*/
public function submitpayment($data, $form)
{
$data = $form->getData();
if ($this->getSuccessLink()) {
$data['returnUrl'] = $this->getSuccessLink();
}
$data['cancelUrl'] = $this->getFailureLink() ? $this->getFailureLink() : $this->controller->Link();
$order = $this->config->getOrder();
//final recalculation, before making payment
$order->calculate();
//handle cases where order total is 0. Note that the order will appear
//as "paid", but without a Payment record attached.
if ($order->GrandTotal() == 0 && Order::config()->allow_zero_order_total) {
if (!$this->orderProcessor->placeOrder()) {
$form->sessionMessage($this->orderProcessor->getError());
return $this->controller->redirectBack();
}
return $this->controller->redirect($this->getSuccessLink());
}
//try to place order before payment, if configured
if (Order::config()->place_before_payment) {
if (!$this->orderProcessor->placeOrder()) {
$form->sessionMessage($this->orderProcessor->getError());
return $this->controller->redirectBack();
}
$data['cancelUrl'] = $this->orderProcessor->getReturnUrl();
}
$paymentResponse = $this->orderProcessor->makePayment(Checkout::get($order)->getSelectedPaymentMethod(false), $data);
$response = null;
if ($paymentResponse) {
if ($this->controller->hasMethod('processPaymentResponse')) {
$response = $this->controller->processPaymentResponse($paymentResponse, $form);
} else {
if ($paymentResponse->isRedirect() || $paymentResponse->isSuccessful()) {
$response = $paymentResponse->redirect();
} else {
$form->sessionMessage($paymentResponse->getMessage(), 'bad');
$response = $this->controller->redirectBack();
}
}
} else {
$form->sessionMessage($this->orderProcessor->getError(), 'bad');
$response = $this->controller->redirectBack();
}
return $response;
}
示例4: setData
public function setData(Order $order, array $data)
{
if (isset($data['PaymentMethod'])) {
Checkout::get($order)->setPaymentMethod($data['PaymentMethod']);
}
}
示例5: SelectedPaymentMethod
public function SelectedPaymentMethod()
{
return Checkout::get($this->owner->Cart())->getSelectedPaymentMethod(true);
}
示例6: submitpayment
/**
* Behaviour can be overwritten by creating a processPaymentResponse method
* on the controller owning this form. It takes a Symfony\Component\HttpFoundation\Response argument,
* and expects an SS_HTTPResponse in return.
*/
public function submitpayment($data, $form)
{
$data = $form->getData();
$cancelUrl = $this->getFailureLink() ? $this->getFailureLink() : $this->controller->Link();
$order = $this->config->getOrder();
// final recalculation, before making payment
$order->calculate();
// handle cases where order total is 0. Note that the order will appear
// as "paid", but without a Payment record attached.
if ($order->GrandTotal() == 0 && Order::config()->allow_zero_order_total) {
if (!$this->orderProcessor->placeOrder()) {
$form->sessionMessage($this->orderProcessor->getError());
return $this->controller->redirectBack();
}
return $this->controller->redirect($this->getSuccessLink());
}
// try to place order before payment, if configured
if (Order::config()->place_before_payment) {
if (!$this->orderProcessor->placeOrder()) {
$form->sessionMessage($this->orderProcessor->getError());
return $this->controller->redirectBack();
}
$cancelUrl = $this->orderProcessor->getReturnUrl();
}
// if we got here from checkoutSubmit and there's a namespaced OnsitePaymentCheckoutComponent
// in there, we need to strip the inputs down to only the checkout component.
$components = $this->config->getComponents();
if ($components->first() instanceof CheckoutComponent_Namespaced) {
foreach ($components as $component) {
if ($component->Proxy() instanceof OnsitePaymentCheckoutComponent) {
$data = array_merge($data, $component->unnamespaceData($data));
}
}
}
// This is where the payment is actually attempted
$paymentResponse = $this->orderProcessor->makePayment(Checkout::get($order)->getSelectedPaymentMethod(false), $data, $this->getSuccessLink(), $cancelUrl);
$response = null;
if ($this->controller->hasMethod('processPaymentResponse')) {
$response = $this->controller->processPaymentResponse($paymentResponse, $form);
} else {
if ($paymentResponse && !$paymentResponse->isError()) {
$response = $paymentResponse->redirectOrRespond();
} else {
$form->sessionMessage($this->orderProcessor->getError(), 'bad');
$response = $this->controller->redirectBack();
}
}
return $response;
}
示例7: testSummary
public function testSummary()
{
$this->checkout->summary();
$form = $this->checkout->ConfirmationForm();
$data = array('Notes' => 'Leave it around the back', 'ReadTermsAndConditions' => 1);
$member = $this->objFromFixture("Member", "joebloggs");
$member->logIn();
//log in member before processing
Checkout::get($this->cart)->setPaymentMethod("Dummy");
//a selected payment method is required
$form->loadDataFrom($data);
$this->assertTrue($form->validate(), "Checkout data is valid");
$response = $this->post('/checkout/ConfirmationForm', $data);
$this->assertEquals('Cart', $this->cart->Status, "Order is still in cart");
$order = Order::get()->byID($this->cart->ID);
$this->assertEquals("Leave it around the back", $order->Notes);
//redirect to make payment
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(Director::baseURL() . "checkout/payment", $response->getHeader('Location'));
}
示例8: Checkout
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Checkout a guest
*
* calendar
*
* @since 2004-01-22
* @author Christian Ehret <chris@ehret.name>
*/
$smartyType = "www";
include_once "../includes/default.inc.php";
$auth->is_authenticated();
include_once 'checkoutclass.inc.php';
if ($request->GetVar('list', 'get') == 'true') {
$smarty->assign("tpl_title", "Anwesenheitsliste");
$smarty->assign('tpl_nav', 'lists');
$smarty->assign('tpl_subnav', 'checkout');
$smarty->assign('tpl_checkout', 'false');
} else {
$smarty->assign("tpl_title", "Checkout");
$smarty->assign('tpl_nav', 'calendar');
$smarty->assign('tpl_subnav', 'checkout');
$smarty->assign('tpl_checkout', 'true');
}
$checkout = new Checkout();
$smarty->assign('tpl_guests', $checkout->get());
$smarty->display('checkoutlist.tpl');