/** * Get the processor's form fields. Custom controllers use this function * to add the form fields specifically to gateways. * * @return FieldList */ public function getFormFields() { $fieldList = new FieldList(); $fieldList->push(new NumericField('Amount', 'Amount', '')); $fieldList->push(new DropDownField('Currency', 'Select currency :', $this->gateway->getSupportedCurrencies())); return $fieldList; }
/** * @param $mert_id * @param Request $request * * Handle Gateway Response * * @return mixed */ private function handleTransactionResponse($mert_id, Request $request) { $data = $request->all(); $origin = $request->header('origin'); switch ($origin) { case str_contains($origin, 'gtbank'): $result = GTPay::receiveTransactionResponse($data, $mert_id); break; case str_contains($origin, 'voguepay'): $result = VoguePay::receiveTransactionResponse($data, $mert_id); break; case str_contains($origin, 'simplepay'): $result = SimplePay::receiveTransactionResponse($data, $mert_id); break; case str_contains($origin, 'cashenvoy'): $result = CashEnvoy::receiveTransactionResponse($data, $mert_id); break; case str_contains($origin, 'webpay'): $result = WebPay::receiveTransactionResponse($data, $mert_id); break; default: $result = $this->paymentGateway->receiveTransactionResponse($data, $mert_id); break; } /********************************* * $result contains all information regarding the transaction, This would be a perfect * place to leverage Events to Do Whatever eg. Send an Invoice, Notify admin of * failed transactions, confirm if total is the same so you can rest easy etc. * You could do your normal Procedural Approach As Well, If You are not so comfortable with * Events. To Use The Events, Uncomment the Call, create the method and write your implementation *********************************/ // $this->handleNextStepsUsingEvents($result); return $result; }
public function show($id = null) { $cart = $this->getCart($id); foreach ($cart->items() as $item) { if ($item->paid) { $item->destroy(); } elseif (is_a($item, 'EventSignup') && $item->is_soldout()) { $item->destroy(); } elseif (is_a($item, "EventService")) { if (!$item->event_signup->paid || !$item->service->available()) { $item->destroy(); } } } if (count($cart->items(true)) == 0) { $cart->destroy(); Site::Flash("There is nothing to pay for in this cart."); Redirect("bookings"); } $cart->check_discounts(); $terms = Content::find_by_permalink("terms"); $gateway = PaymentGateway::getActive(); $this->assign('gateway', $gateway); $this->assign('baseURI', $this->getBaseURI()); $this->assign('cart', $cart); $this->assign("terms", $terms); $this->title = "My Bookings :: Payment Options"; $this->render("cart/show.tpl"); }
/** * Get the gateway object that will be used for the given payment method. * The gateway class is automatically retrieved based on configuration * * @param String $methodName * @return PaymentGateway */ public static function get_gateway($methodName) { // Get the gateway environment setting $environment = PaymentGateway::get_environment(); // Get the custom class configuration if applicable. // If not, apply naming convention. $methodConfig = self::get_factory_config($methodName); $gatewayClassConfig = $methodConfig['gateway_classes']; if (isset($gatewayClassConfig[$environment])) { $gatewayClass = $gatewayClassConfig[$environment]; } else { switch ($environment) { case 'live': $gatewayClass = $methodName . 'Gateway_Production'; break; case 'dev': $gatewayClass = $methodName . 'Gateway_Dev'; break; case 'test': $gatewayClass = $methodName . 'Gateway_Mock'; break; } } if (class_exists($gatewayClass)) { return new $gatewayClass(); } else { throw new Exception("{$gatewayClass} class does not exists."); } }
/** * Initialize the 2CheckOut gateway * * @param none * @return void */ public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://www.2checkout.com/checkout/purchase'; $this->ipnLogFile = '2co.ipn_results.log'; }
public function index() { $gateways = PaymentGateway::find_all('', 'paymentgateways.position ASC'); $this->assign('gateways', $gateways); $this->title = 'Payment Gateways'; $this->render('paymentgateway/index.tpl'); }
public function __construct() { parent::__construct(); $this->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr'; $this->ipnLogFile = 'log.txt'; $this->addField('rm', '2'); $this->addField('cmd', '_xclick'); }
public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://checkout.globalgatewaye4.firstdata.com/payment'; $this->ipnLogFile = 'authorize.ipn_results.log'; // Populate $fields array with a few default }
public function __construct() { parent::__construct(); //$this->gatewayUrl = 'https://www.nsiapay.com/ipg_payment/RegisterOrderInfo'; //$this->gatewayUrl = 'https://pay.doku.com/ipg_payment/RegisterOrderInfo'; $this->gatewayUrl = 'https://pay.doku.com/DokuSuite/Channel'; $this->ipnLogFile = 'nsiapay.ipn_results.log'; }
/** * Initialize the worldpay gateway * * @param none * @return void */ public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://secure.worldpay.com/wcc/purchase'; $this->ipnLogFile = 'worldpay.ipn_results.log'; $this->worldpay_gateway_version = '1.0'; }
public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://secure.merchantwarrior.com'; $this->gatewayUrlQuery = 'https://api.merchantwarrior.com/post/'; $this->ipnLogFile = 'mwarrior.ipn_results.log'; }
public function __construct() { parent::__construct(); $this->setPaymentName(self::NAME); $this->setDisplayName(self::DISPLAY_NAME); $this->setPaymentImage(self::PAYMENT_IMAGE); $this->setTestMode(FALSE); $this->setTermAndConditions("Only works with verve"); $this->setViewLink('_online'); }
/** * Initialize the Paypal gateway * * @param none * @return void */ public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr'; $this->ipnLogFile = 'paypal.ipn_results.log'; // Populate $fields array with a few default $this->addField('rm', '2'); // Return method = POST $this->addField('cmd', '_xclick'); }
public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://secure.authorize.net/gateway/transact.dll'; $this->ipnLogFile = 'authorize.ipn_results.log'; // Populate $fields array with a few default $this->addField('x_Version', '3.0'); $this->addField('x_Show_Form', 'PAYMENT_FORM'); $this->addField('x_Relay_Response', 'TRUE'); }
public function __construct() { parent::__construct(); $this->requried_fields = array('interswitchProductID', 'interswitchItemID', 'site_redirect_url', 'MAC_key'); $this->setPaymentName(self::NAME); $this->setDisplayName(self::DISPLAY_NAME); $this->setPaymentImage(self::PAYMENT_IMAGE); $this->setTestMode(FALSE); $this->setTermAndConditions("Only works with visa"); $this->setViewLink('_online'); }
/** * Initialize the Paypal gateway * * @param none * @return void */ public function __construct() { parent::__construct(); // Some default values of the class $this->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr'; $this->ipnLogFile = 'protected/runtime/paypal.ipn_results.log'; // Populate $fields array with a few default $this->addField('rm', '2'); // Return method = POST $this->addField('cmd', '_ext-enter'); $this->addField('redirect_cmd', '_cart'); $this->addField('upload', '1'); }
public function getPaymentGateway() { global $logger; $logger->LogDebug(__METHOD__ . " Getting payment gateway for booking with payment gateway id: " . $this->paymentGatewayId); $paymentGateway = PaymentGateway::fetchFromDb($this->paymentGatewayId); if ($paymentGateway == null) { $logger->LogWarn("There is no payment gateway with id: " . $this->paymentGatewayId); $this->errors = PaymentGateway::$staticErrors; } else { $logger->LogDebug("Found payment gateway with id: " . $this->paymentGatewayId); } return $paymentGateway; }
public function show($id = null) { $cart = $this->load_cart($id); if (!$cart->paid) { $cart->check_discounts(); $manualGateway = null; $gateways = null; $allGateways = PaymentGateway::find_all('', 'paymentgateways.position ASC'); foreach ($allGateways as $gateway) { $gateways[$gateway->id] = $gateway->name; if ($gateway->code == 'manual') { $manualGateway = $gateway; } } $payment = new PaymentTransaction(); $payment->cart_id = $cart->id; $payment->cart = $cart; $payment->paymentgateway = $manualGateway; $payment->paymentgateway_id = $manualGateway->id; $payment->externalid = (string) $cart; $payment->amount = Money($cart->cost()); $payment->sender = $cart->user->email; $payment->status = 'ptsTaken'; $payment->processResponse = array('notes' => ''); if ($this->post) { $payment->paymentgateway_id = $this->postData('paymentgateway_id'); $payment->externalid = $this->postData('externalid'); $payment->sender = $this->postData('sender'); $payment->amount = $this->postData('amount'); $payment->processResponse = array('notes' => $this->postData('notes')); $payment->method = $gateways[$payment->paymentgateway_id]; if ($payment->save()) { Email::send_user_paymentconfirmation($payment); $cart->mark_paid($payment, 'Manually Paid'); Email::send_payment_complete(array(), "", $cart); Site::Flash('notice', 'The cart has been paid for'); Redirect("admin/carts/{$cart->id}"); } else { Site::InstantFlash('error', 'Invalid payment'); } echo '<pre>'; print_r($payment); die; } $this->assign('payment', $payment); $this->assign('gateways', $gateways); } $this->assign('cart', $cart); $this->title = "Cart :: {$cart->id}"; $this->render('cart/show.tpl'); }
/** * Generates the HTML to use on the checkout/confirmation page. * * @param PaymentGateway $gateway The payment gateway to use * @param Cart $cart The cart we're purchasing * @Param string $baseURI The base URI for the site * @return string The HTML to display */ public static function generateCheckoutHTML($gateway, $cart, $baseURI) { $url = $gateway->getSetting('endpoint'); $email = $gateway->getSetting('email'); $notifyURL = $gateway->getSetting('notificationurl'); $amount = self::formatMoney($cart->cost(true, false)); return <<<EOT <p> \tIf you have a Paypal account, you can use it to pay us. If you don't you can \tstill use Paypal to pay with your credit/debit card and you don't even need a \tPaypal account. </p> <p> \tClick on the Paypal logo below to go to the Paypal website and pay for your \tbooking. </p> <form action="{$url}" method="post" id="paypal" name="paypal"> \t<input type="hidden" name="cmd" value="_cart" /> \t<input type="hidden" name="upload" value="1" /> \t<input type="hidden" name="business" value="{$email}" /> \t<input type="hidden" name="currency_code" value="GBP" /> \t<input type="hidden" name="custom" value="cart-{$cart->id}" /> \t<input type="hidden" name="notify_url" value="{$notifyURL}" /> \t<input type="hidden" name="return" value="{$baseURI}/payments/{$cart->id}/complete" /> \t<input type="hidden" name="item_name_1" value="epic.LAN Booking - Cart {$cart->id}" /> \t<input type="hidden" name="amount_1" value="{$amount}" /> \t\t \t<h4 class="center"> \t\t<input type="image" value="PayPal" src="/images/paypal.gif" /> \t\t<br /> \t\t<a href="javascript:document.paypal.submit();">Total to pay by Paypal: £{$amount}</a> \t</h4> </form> EOT; }
/** * Initialize the eway gateway * * @param none * @return void */ public function __construct() { parent::__construct(); // Some default values of the class $eway_settings = get_option('event_espresso_eway_settings'); switch ($eway_settings['region']) { case 'NZ': $this->gatewayUrl = 'https://nz.ewaygateway.com/Request/'; break; case 'AU': $this->gatewayUrl = 'https://au.ewaygateway.com/Request/'; break; case 'UK': $this->gatewayUrl = 'https://payment.ewaygateway.com/Request/'; break; } // Populate $fields array with a few default }
/** * Send a request to the gateway to process the payment * @param {array} $data Data to be passed to the gateway * @return {PaymentGateway_Result} Payment result object */ public function process($data) { $api_key = ''; if (PaymentGateway::get_environment() == 'dev') { $api_key = Config::inst()->get('StripeGateway', 'test_api_secret'); } else { $api_key = Config::inst()->get('StripeGateway', 'api_secret'); } if (empty($api_key)) { return new PaymentGateway_Failure(403, _t('StripeGateway.NO_API_KEY', '_No api key configured, you must configure StripeGateway.api_secret for live and StripeGateway.test_api_secret for dev')); } //Set the api key in the Stripe library Stripe::setApiKey($api_key); //Create the Stripe charge try { $response = Stripe_Charge::create(array('amount' => intval($data['Amount']) * 100, 'currency' => $data['Currency'], 'card' => array('number' => implode('', $data['CardNumber']), 'exp_month' => $data['MonthExpiry'], 'exp_year' => $data['YearExpiry'], 'cvc' => $data['Cvc2'], 'name' => $data['FirstName'] . ' ' . $data['LastName'], 'address_line1' => $data['BillingAddress'], 'address_line2' => $data['BillingAddress2'], 'address_city' => $data['BillingCity'], 'address_zip' => $data['BillingZIPCode'], 'address_state' => $data['BillingState'], 'address_country' => $data['BillingCountry']), 'description' => _t('StripeGateway.PAYMENT_DESCRIPTION', '_{sitetitle} Store Sale', array('sitetitle' => class_exists('SiteConfig') ? SiteConfig::get()->first()->Title : 'SilverStripe')))); if ($response->paid) { return new PaymentGateway_Success($status); } else { if ($response->cvc_check == 'fail' || $response->address_line1_check == 'fail' || $response->address_zip_check == 'fail') { $errors = array(); if ($response->cvc_check == 'fail') { $errors[] = _t('StripeGateway.FAIL_CVC', '_The credit card\'s security code (cvc) is invalid'); } if ($response->address_line1_check == 'fail') { $errors[] = _t('StripeGateway.FAIL_ADDRESS', '_Your bank declined the charge based on your address information, please verify the information and try again'); } if ($response->address_zip_check == 'fail') { $errors[] = _t('StripeGateway.FAIL_ZIP_CODE', '_Your bank declined the charge based on your postal code/zip code, please verify it and try again'); } return new PaymentGateway_Failure(null, $errors); } else { return new PaymentGateway_Incomplete(); } } } catch (Stripe_Error $e) { return new PaymentGateway_Failure(new SS_HTTPResponse('', $e->getHttpStatus()), array($e->getCode() => $e->getMessage())); } return new PaymentGateway_Failure(); }
public function getPaymentTransaction($baseuri = null) { // Try and find a valid payment transaction for this cart $id = mysql_real_escape_string($this->id); $hash = mysql_real_escape_string($this->hash); $amount = round($this->cost(true, false) / 100, 2); $escapedAmount = mysql_real_escape_string($amount); $transaction = PaymentTransaction::find("paymenttransactions.cart_id = '{$id}' AND paymenttransactions.amount = '{$escapedAmount}' AND paymenttransactions.status IN ('ptsNew', 'ptsTaken') AND paymentgateways.enabled = 1"); if (!$transaction) { $transaction = new PaymentTransaction(); $transaction->amount = $amount; $transaction->hash = $this->hash; $transaction->cart = $this; $transaction->cart_id = $this->id; $transaction->paymentgateway = PaymentGateway::getActive(); $transaction->paymentgateway_id = $transaction->paymentgateway->id; $transaction->baseuri = $baseuri; if (!$transaction->save()) { throw new Error500('Unable to create payment transaction'); } } return $transaction; }
public function cart_payment() { $id = ""; if ($this->GetData('id')) { $id = $this->GetData('id'); } $user_id = mysql_real_escape_string(Site::CurrentUser()->id); $cart = Cart::find("carts.user_id = {$user_id} AND carts.id = {$id}"); if ($cart->paid) { Site::Flash('error', 'The cart has already been paid'); RedirectBack('bookings'); } $cart->check_discounts(); if ($cart->cost() != 0) { Site::Flash('error', 'This cart still needs to be paid for'); RedirectBack('bookings'); } if ($cart->full_cart_discount()) { $id = mysql_real_escape_string($cart->id); $redemptions = DiscountRedemption::find_all("discount_redemptions.cart_id='{$id}' and discount_redemptions.cart_item_id IS NULL"); } // Log the payment $gateway = PaymentGateway::find_by_code('discount'); $payment = new PaymentTransaction(); $payment->cart_id = $cart->id; $payment->externalid = (string) $redemptions[0]; $payment->paymentgateway_id = $gateway->id; $payment->status = 'ptsTaken'; $payment->amount = $cart->cost() / 100; $payment->sender = Site::CurrentUser()->email; $payment->save(); $cart->mark_paid($payment, 'Discount'); // Email staff about payment Email::send_payment_complete(array(), "", $cart, $redemptions); Redirect("payments/{$id}/complete"); }
public static function load_from_row($row, $recurse_limit = 1, $current_level = 0) { // When PHP 5.3.0 is in, we can shift this over too and just redefine it // if needed (eg. loading child objects) $class = __CLASS__; $object = new $class(); $fields = self::fields_array(); $fields[] = array("created_at", "datetime"); $fields[] = array("updated_at", "datetime"); $fields[] = array("deleted", "bool"); foreach ($fields as $field) { $property = $field[0]; if (isset($field[2])) { $property = $field[2]; } if (isset($row[self::table . ".{$field[0]}"])) { if ($field[1] == "datetime") { $object->{$property} = strtotime($row[self::table . ".{$field[0]}"]); } else { $object->{$property} = $row[self::table . ".{$field[0]}"]; } } else { $object->{$property} = null; } } $object->is_new = false; // Load child objects here if ($current_level < $recurse_limit) { $current_level++; $object->paymentgateway = PaymentGateway::load_from_row($row, $recurse_limit, $current_level); $object->cart = Cart::load_from_row($row, $recurse_limit, $current_level); } return $object; }
<?php // TODO: Uncomment include "access.php"; include_once "../includes/SystemConfiguration.class.php"; global $systemConfiguration; global $logger; // If we have id, then we are trying to delete if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = intval($_GET['id']); PaymentGateway::delete($id); } header("Location: payment_gateways_list.php");
public static function delete($id) { global $logger; PaymentGateway::$staticErrors = array(); if (is_numeric($id)) { // Run DELETE $sql = "DELETE FROM bsi_payment_gateway WHERE id = " . $id; if (!mysql_query($sql)) { $logger->LogError("Error: " . mysql_errno() . ". Error message: " . mysql_error()); $logger->LogError("SQL: {$sql}"); die('Error: ' . mysql_error()); } return true; } else { PaymentGateway::$staticErrors[] = "Id is not numeric"; return false; } }
/** * Initializes this gateway. */ public function init() { parent::init(); $this->_client = $this->createClient(); }
<label for="email" class="required"><?php echo BOOKING_DETAILS_EMAIL; ?> </label> <input type="text" name="email" class="input" value="<?php echo htmlentities($client->email); ?> " /> </div> <div class="clear"> <label for="paymentMethod" class="required"><?php echo BOOKING_DETAILS_PAYMENT_OPTION; ?> </label> <?php $paymentGateways = PaymentGateway::fetchFromDbNonAdminActive(); $isFirstItem = true; foreach ($paymentGateways as $paymentGateway) { echo '<input type="radio" name="payment_gateway_code" value="' . $paymentGateway->gatewayCode . '"' . ($isFirstItem ? ' checked="checked"' : '') . '/>' . $paymentGateway->gatewayName->getText($language_selected) . '<br />'; $isFirstItem = false; } ?> </div> <div class="clear"> <label class="empty required"><?php echo BOOKING_DETAILS_AGREEMENT; ?> </label> <input type="checkbox" name="agreement" id="agreement" class="checkbox" <?php echo isset($_POST['agreement']) ? 'checked="checked"' : '';
$paymentGateway = PaymentGateway::fetchFromParameters($_POST); if (!$paymentGateway->save()) { $logger->LogError("Error saving payment gateway."); foreach ($paymentGateway->errors as $error) { $logger->LogError($error); $errors[] = $error; } } else { $message = "Values were updated successfully!"; } } else { if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $logger->LogInfo("Page was called for edit of id: " . $_REQUEST['id']); $id = intval($_REQUEST['id']); $logger->LogDebug("Numeric id is: {$id}"); $paymentGateway = PaymentGateway::fetchFromDb($id); if ($paymentGateway == null) { $logger->LogError("Invalid request. No payment gateway with id: {$id} exists."); $errors[] = "Invalid request. No payment gateway with id: {$id} exists."; } } } $defaultLanguage = Language::fetchDefaultLangauge(); ?> </td> </tr> <tr> <td height="400" valign="top"> <?php if (sizeof($errors) > 0) {
<?php // Setup class include_once "includes/SystemConfiguration.class.php"; include "includes/language.php"; global $systemConfiguration; global $logger; $logger->LogInfo(__FILE__); $systemConfiguration->assertReferer(); $logger->LogInfo("Loading payment gateway for code 'pp' ..."); $paypalPaymentGateway = PaymentGateway::fetchFromDbForCode("pp"); if ($paypalPaymentGateway == null) { $logger->LogError("Payment gateway could not be found!"); header('Location: booking-failure.php?error_code=9'); } $emailSender = new EmailSender(); require_once 'paypal.class.php'; $p = new paypal_class(); $p->paypal_url = $paypalPaymentGateway->getUrl(); // 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // testing paypal url // 'https://www.paypal.com/cgi-bin/webscr'; // paypal url // setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php') $this_script = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; // if there is not action variable, set the default action of 'process' if (empty($_GET['action'])) { $_GET['action'] = 'process'; } switch ($_GET['action']) { case 'process': // Process and order... $logger->LogInfo("Procesisng request for payment to PayPal ...");