function checkoutWithPaypal($total, $cart) { try { $paypal = new PayPal(true); } catch (Exception $e) { Logger::i()->writeLog("Caught Exception: " . $e->getMessage(), 'dev'); die; } $params = array('RETURNURL' => createURLForScript("process.php"), 'CANCELURL' => createURLForScript("cancel.php"), 'PAYMENTREQUEST_0_AMT' => floatval(number_format(floatval($total), 2)), 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR'); $params['SOLUTIONTYPE'] = "Sole"; $params['LANDINGPAGE'] = "Billing"; $k = 0; foreach ($cart as $key => $value) { $info = (array) $value; $params['L_PAYMENTREQUEST_0_NAME' . $k] = $info["name"]; $params['L_PAYMENTREQUEST_0_DESCR' . $k] = $info["description"]; $params['L_PAYMENTREQUEST_0_AMT' . $k] = floatval(number_format(floatval($info['price']), 2)); $params['L_PAYMENTREQUEST_0_QTY' . $k] = intval($info['quantity']); $k++; } $response = $paypal->doRequest("SetExpressCheckout", $params); if ($response) { Logger::i()->writeLog("Starting PayPal checkout"); return $paypal->generateURL($response['TOKEN']); } else { Logger::i()->writeLog("Could not get token, error = " . $paypal->error, 'dev'); die(Submission::createResult("Can not checkout at the moment. Please try again later.")); } }
/** * Constructor * @global object $objTemplate */ function __construct($pageContent) { $this->pageContent = $pageContent; $this->_objTpl = new \Cx\Core\Html\Sigma('.'); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl); $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE); $this->mediaPath = ASCMS_MARKET_MEDIA_PATH . '/'; $this->mediaWebPath = ASCMS_MARKET_MEDIA_WEB_PATH . '/'; //get settings $this->settings = $this->getSettings(); //check community modul $objModulManager = new \Cx\Core\ComponentManager\Controller\ComponentManager(); $arrInstalledModules = $objModulManager->getModules(); if (in_array(23, $arrInstalledModules)) { $this->communityModul = true; } else { $this->communityModul = false; } //ipn Check if (isset($_GET['act'])) { switch ($_GET['act']) { case "paypalIpnCheck": $objPaypal = new \PayPal(); $objPaypal->ipnCheck(); exit; break; default: //nothging break; } } }
function espresso_process_paypal_pro($payment_data) { extract($payment_data); global $wpdb; // Included required files. require_once 'includes/paypal.nvp.class.php'; $paypal_pro_settings = get_option('event_espresso_paypal_pro_settings'); $sandbox = $paypal_pro_settings['paypal_pro_use_sandbox']; // Setup PayPal object $PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $paypal_pro_settings['paypal_api_username'], 'APIPassword' => $paypal_pro_settings['paypal_api_password'], 'APISignature' => $paypal_pro_settings['paypal_api_signature']); $PayPal = new PayPal($PayPalConfig); // Populate data arrays with order data. $DPFields = array('paymentaction' => 'Sale', 'ipaddress' => $_SERVER['REMOTE_ADDR'], 'returnfmfdetails' => '1'); $CCDetails = array('creditcardtype' => $_POST['creditcardtype'], 'acct' => $_POST['card_num'], 'expdate' => $_POST['expmonth'] . $_POST['expyear'], 'cvv2' => $_POST['cvv'], 'startdate' => '', 'issuenumber' => ''); $PayerInfo = array('email' => $_POST['email'], 'payerid' => '', 'payerstatus' => '', 'business' => ''); $PayerName = array('salutation' => '', 'firstname' => $_POST['first_name'], 'middlename' => '', 'lastname' => $_POST['last_name'], 'suffix' => ''); $BillingAddress = array('street' => $_POST['address'], 'street2' => '', 'city' => $_POST['city'], 'state' => $_POST['state'], 'countrycode' => 'US', 'zip' => $_POST['zip'], 'phonenum' => empty($_POST['phone']) ? '' : $_POST['phone']); $ShippingAddress = array('shiptoname' => '', 'shiptostreet' => '', 'shiptostreet2' => '', 'shiptocity' => '', 'shiptostate' => '', 'shiptozip' => '', 'shiptocountrycode' => '', 'shiptophonenum' => ''); $PaymentDetails = array('amt' => $payment_data['total_cost'], 'currencycode' => $paypal_pro_settings['currency_format'], 'itemamt' => '', 'shippingamt' => '', 'handlingamt' => '', 'taxamt' => '', 'desc' => stripslashes_deep($event_name), 'custom' => '', 'invnum' => '', 'notifyurl' => ''); $OrderItems = array(); $Item = array('l_name' => stripslashes_deep($event_name), 'l_desc' => stripslashes_deep($event_name), 'l_amt' => $_POST['amount'], 'l_number' => '', 'l_qty' => '1', 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => ''); array_push($OrderItems, $Item); // Wrap all data arrays into a single, "master" array which will be passed into the class function. $PayPalRequestData = array('DPFields' => $DPFields, 'CCDetails' => $CCDetails, 'PayerName' => $PayerName, 'BillingAddress' => $BillingAddress, 'PaymentDetails' => $PaymentDetails, 'OrderItems' => $OrderItems); $PayPalResult = $PayPal->DoDirectPayment($PayPalRequestData); $payment_data['payment_status'] = 'Incomplete'; $payment_data['txn_type'] = 'PayPal Pro'; $payment_data['txn_id'] = 0; $payment_data['txn_details'] = serialize($_REQUEST); $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); $Errors = GetErrors($PayPalResult); if (!empty($PayPalResult)) { unset($PayPalResult['REQUESTDATA']['CREDITCARDTYPE']); unset($PayPalResult['REQUESTDATA']['ACCT']); unset($PayPalResult['REQUESTDATA']['EXPDATE']); unset($PayPalResult['REQUESTDATA']['CVV2']); unset($PayPalResult['RAWREQUEST']); $payment_data['txn_id'] = $PayPalResult['TRANSACTIONID']; $payment_data['txn_details'] = serialize($PayPalResult); if (!APICallSuccessful($PayPalResult['ACK'])) { DisplayErrors($Errors); } else { $payment_data['payment_status'] = 'Completed'; } } else { ?> <p><?php _e('There was no response from PayPal.', 'event_espresso'); ?> </p> <?php } add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment'); return $payment_data; }
function do_payment() { $amount = $this->input->get('amount'); $r = new PayPal(); $r->doExpressCheckout($amount, 'Da Greatest Library You Ever Seen'); $final = $r->doPayment(); if ($final['ACK'] == 'Success') { echo 'Succeed!'; } else { echo 'Error!'; } }
public function executeConnexion(sfWebRequest $request) { $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin'); $this->formIdentification = new $class(); if ($request->ismethod('post')) { $this->formIdentification->bind($request->getParameter('signin')); if ($this->formIdentification->isValid()) { $values = $this->formIdentification->getValues(); $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); $paypal = new PayPal(); $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture'); //print_r($ret); } } }
public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * Constructor * * @access public * @param array config preferences * @return void */ function __construct($DataArray) { parent::__construct($DataArray); $this->XMLNamespace = 'http://svcs.paypal.com/types/ap'; $this->DeviceID = isset($DataArray['DeviceID']) ? $DataArray['DeviceID'] : ''; $this->IPAddress = isset($DataArray['IPAddress']) ? $DataArray['IPAddress'] : $_SERVER['REMOTE_ADDR']; $this->DetailLevel = isset($DataArray['DetailLevel']) ? $DataArray['DetailLevel'] : 'ReturnAll'; $this->ErrorLanguage = isset($DataArray['ErrorLanguage']) ? $DataArray['ErrorLanguage'] : 'en_US'; $this->APISubject = isset($DataArray['APISubject']) ? $DataArray['APISubject'] : ''; $this->DeveloperAccountEmail = isset($DataArray['DeveloperAccountEmail']) ? $DataArray['DeveloperAccountEmail'] : ''; if ($this->Sandbox) { // Sandbox Credentials $this->ApplicationID = isset($DataArray['ApplicationID']) ? $DataArray['ApplicationID'] : ''; $this->APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : ''; $this->APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : ''; $this->APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : ''; $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://svcs.sandbox.paypal.com/'; } elseif ($this->BetaSandbox) { // Beta Sandbox Credentials $this->ApplicationID = isset($DataArray['ApplicationID']) ? $DataArray['ApplicationID'] : ''; $this->APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : ''; $this->APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : ''; $this->APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : ''; $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://svcs.beta-sandbox.paypal.com/'; } else { // Live Credentials $this->ApplicationID = isset($DataArray['ApplicationID']) ? $DataArray['ApplicationID'] : ''; $this->APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : ''; $this->APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : ''; $this->APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : ''; $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://svcs.paypal.com/'; } }
public function process($sProvider = '') { switch ($sProvider) { case 'paypal': $oPayPal = new PayPal($this->config->values['module.setting']['sandbox.enable']); if ($oPayPal->valid() && $this->httpRequest->postExists('item_number')) { if ($this->oUserModel->updateMembership($this->httpRequest->post('item_number'), $this->iProfileId, $this->httpRequest->post('amount'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->log($oPayPal, t('PayPal payment was made, the following information:')); $this->_bStatus = true; // Status is OK } } unset($oPayPal); break; case '2co': $o2CO = new TwoCO($this->config->values['module.setting']['sandbox.enable']); $sVendorId = $this->config->values['module.setting']['2co.vendor_id']; $sSecretWord = $this->config->values['module.setting']['2co.secret_word']; if ($o2CO->valid($sVendorId, $sSecretWord) && $this->httpRequest->postExists('sale_id')) { if ($this->oUserModel->updateMembership($this->httpRequest->post('sale_id'), $this->iProfileId, $this->httpRequest->post('price'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->log($o2CO, t('2CheckOut payment was made, the following information:')); $this->_bStatus = true; // Status is OK } } unset($o2CO); break; case 'ccbill': // In developing... // Contact us at <*****@*****.**> if you want to help us develop the payment system CCBill break; default: $this->displayPageNotFound(t('Provinder Not Found!')); } // Set the page titles $this->sTitle = $this->_bStatus ? t('Thank you!') : t('Error occurred!'); $this->view->page_title = $this->sTitle; $this->view->h2_title = $this->sTitle; if ($this->_bStatus) { $this->updateAffCom(); } // Set the valid page $sPage = $this->_bStatus ? 'success' : 'error'; $this->manualTplInclude($sPage . $this->view->getTplExt()); // Output $this->output(); }
static function create_from_post($postfields, $payment_id = false) { $infoarray = $_POST; $set = array(); $set['info'] = PayPal::post2string(); if (isset($infoarray['txn_id'])) { $set['txn_id'] = $infoarray['txn_id']; } }
public function getAuthorisation() { global $cookie; // Getting cart informations $cart = new Cart((int) $cookie->id_cart); if (!Validate::isLoadedObject($cart)) { $this->_logs[] = $this->l('Not a valid cart'); } $currency = new Currency((int) $cart->id_currency); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $returnURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/express/submit.php'; $cancelURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php'; $paymentAmount = (double) $cart->getOrderTotal(); $currencyCodeType = strval($currency->iso_code); $paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType); if ($this->_pp_integral) { $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } else { $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login'; } $request .= '&LOCALECODE=' . strtoupper($this->getCountryCode()); if ($this->_header) { $request .= '&HDRIMG=' . urlencode($this->_header); } // Customer informations $customer = new Customer((int) $cart->id_customer); $request .= '&EMAIL=' . urlencode($customer->email); //customer // address of delivery $address = new Address((int) $cart->id_address_delivery); $country = new Country((int) $address->id_country); if ($address->id_state) { $state = new State((int) $address->id_state); } $request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname); $request .= '&SHIPTOSTREET=' . urlencode($address->address1); $request .= '&SHIPTOSTREET2=' . urlencode($address->address2); $request .= '&SHIPTOCITY=' . urlencode($address->city); $request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code); $request .= '&SHIPTOZIP=' . urlencode($address->postcode); $request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code); $request .= '&SHIPTOPHONENUM=' . urlencode($address->phone); // Calling PayPal API include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
/** * Constructor * * @access public * @param array config preferences * @return void */ function __construct($DataArray) { parent::__construct($DataArray); $this->AccessKey = isset($DataArray['AccessKey']) ? $DataArray['AccessKey'] : ''; $this->ClientSecret = isset($DataArray['ClientSecret']) && $DataArray['ClientSecret'] != '' ? $DataArray['ClientSecret'] : ''; if ($this->Sandbox) { $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://api.financing-mint.paypal.com/finapi/v1/publishers/'; } else { $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://api.financing.paypal.com/finapi/v1/publishers/'; } }
public function done(Request $request) { $id = $request->get('paymentId'); $payer_id = $request->get('PayerID'); $payment = PayPal::getById($id, $this->_apiContext); $paymentExecution = PayPal::PaymentExecution(); $paymentExecution->setPayerId($payer_id); $executePayment = $payment->execute($paymentExecution, $this->_apiContext); // Clear the shopping cart, write to database, send notifications, etc. $request->session()->pull('likes', []); return view('Main/index'); }
public function getDone(Request $request) { $id = $request->get('paymentId'); $token = $request->get('token'); $payer_id = $request->get('PayerID'); $payment = PayPal::getById($id, $this->_apiContext); $paymentExecution = PayPal::PaymentExecution(); $paymentExecution->setPayerId($payer_id); $executePayment = $payment->execute($paymentExecution, $this->_apiContext); \Cart::clear(); return view('frontend.checkout.done')->with('categories', Category::all())->with('pay', $executePayment); }
static function logit($payment_id = false) { $set = array(); $set['info'] = PayPal::post2string($_POST); $separate_fields = array('txn_id', 'txn_type'); foreach ($separate_fields as $fieldname) { if (isset($_POST[$fieldname])) { $set[$fieldname] = $_POST[$fieldname]; } } $ppt = new PayPalTxn(false); return $ppt->add($set); }
public function initContent() { if (!$this->context->customer->isLogged() || empty($this->context->cart)) { Tools::redirect('index.php'); } parent::initContent(); $this->paypal = new PayPal(); $this->context = Context::getContext(); $this->id_module = (int) Tools::getValue('id_module'); $currency = new Currency((int) $this->context->cart->id_currency); $this->context->smarty->assign(array('form_action' => PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $this->paypal->name . '/express_checkout/payment.php', 'total' => Tools::displayPrice($this->context->cart->getOrderTotal(true), $currency), 'logos' => $this->paypal->paypal_logos->getLogos(), 'use_mobile' => (bool) $this->paypal->useMobile())); $this->setTemplate('order-summary.tpl'); }
public function getDone(Request $request) { $id = $request->get('paymentId'); $token = $request->get('token'); $payer_id = $request->get('PayerID'); $payment = PayPal::getById($id, $this->_apiContext); $paymentExecution = PayPal::PaymentExecution(); $paymentExecution->setPayerId($payer_id); $executePayment = $payment->execute($paymentExecution, $this->_apiContext); // Clear the shopping cart, write to database, send notifications, etc. // Thank the user for the purchase return view('register'); }
public function Handle_GetPaymentMethod($order) { $method = array(); $method['Title'] = 'PayPal'; $method['Description'] = 'Pay with your PayPal account'; $method['ThumbnailUrl'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/icon.png'; // config the handling module in the mobile engine $method['Module'] = 'WebPaymentActivity'; $params = array(); // new paypal module (3.4.5) if (defined('WPS') && defined('HSS') && defined('ECS')) { $paypal_method = (int) Configuration::get('PAYPAL_PAYMENT_METHOD'); if ($paypal_method == WPS || $paypal_method == ECS) { $cancel_url = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/express_checkout/cancel.php'; $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/express_checkout/payment.php?express_checkout=payment_cart¤t_shop_url=' . urlencode($cancel_url) . '&'; $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl(); $params['CancelTrigger'] = $cancel_url; } } // old paypal module (2.8.6) if (defined('_PAYPAL_INTEGRAL_EVOLUTION_') && defined('_PAYPAL_INTEGRAL_EVOLUTION_') && defined('_PAYPAL_INTEGRAL_EVOLUTION_')) { if (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_EVOLUTION_) { // integral_evolution/paypal.tpl $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/integral_evolution/redirect.php'; $params['CompleteTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__ . 'order-confirmation.php'; $params['CancelTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__; } elseif (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_ or Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_OPTION_PLUS_) { if ($this->_isPayPalAPIAvailable()) { // payment/payment.tpl $params['Url'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/payment/submit.php'; $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'order-confirmation.php'; $params['CancelTrigger'] = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order'; // either order.php or order-opc.php $params['RedirectTrigger'] = array('Trigger' => CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/payment/submit.php', 'Redirect' => CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/payment/error.php'); } else { // standard/paypal.tpl $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/standard/redirect.php'; $params['CompleteTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__ . 'order-confirmation.php'; $params['CancelTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__; } } } // very old paypal (2.0 and below) if (empty($params)) { $params['Url'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/old/hookpayment.php'; $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'order-confirmation.php'; $params['CancelTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl(); } $method['ModuleParameters'] = $params; return $method; }
/** * Constructor * * @access public * @param mixed[] $DataArray Array structure providing config data * @return void */ function __construct($DataArray) { parent::__construct($DataArray); $this->APIVendor = isset($DataArray['APIVendor']) ? $DataArray['APIVendor'] : ''; $this->APIPartner = isset($DataArray['APIPartner']) ? $DataArray['APIPartner'] : ''; $this->Verbosity = isset($DataArray['Verbosity']) ? $DataArray['Verbosity'] : 'HIGH'; if ($this->Sandbox) { $this->APIEndPoint = 'https://pilot-payflowpro.paypal.com'; } else { $this->APIEndPoint = 'https://payflowpro.paypal.com'; } $this->NVPCredentials = 'BUTTONSOURCE[' . strlen($this->APIButtonSource) . ']=' . $this->APIButtonSource . '&VERBOSITY[' . strlen($this->Verbosity) . ']=' . $this->Verbosity . '&USER[' . strlen($this->APIUsername) . ']=' . $this->APIUsername . '&VENDOR[' . strlen($this->APIVendor) . ']=' . $this->APIVendor . '&PARTNER[' . strlen($this->APIPartner) . ']=' . $this->APIPartner . '&PWD[' . strlen($this->APIPassword) . ']=' . $this->APIPassword; $this->TransactionStateCodes = array('1' => 'Error', '6' => 'Settlement Pending', '7' => 'Settlement in Progress', '8' => 'Settlement Completed Successfully', '11' => 'Settlement Failed', '14' => 'Settlement Incomplete'); }
public function __construct() { $this->config = parse_ini_file(__DOCROOT__ . '/config.ini', true); PayPal::$database_connect = mysql_connect($this->config['database']['host'], $this->config['database']['user'], $this->config['database']['password']); if (!PayPal::$database_connect) { echo "Unable to connect to DB: " . mysql_error(PayPal::$database_connect); exit; } mysql_query("SET NAMES 'UTF8'", PayPal::$database_connect); if (!mysql_select_db($this->config['database']['name'], PayPal::$database_connect)) { echo "Unable to select mydbname: " . mysql_error(PayPal::$database_connect); exit; } }
/** * Done */ public function done(Request $request) { //je recupere les informations de retour de Paypal $id = $request->get('paymentId'); $token = $request->get('token'); $payer_id = $request->get('PayerID'); $payment = PayPal::getById($id, $this->_apiContext); $paymentExecution = PayPal::PaymentExecution(); //execution du paiment a partir du Payer //Requete à Paypal: débit du montant de a transaction au Payer $paymentExecution->setPayerId($payer_id); $executePayment = $payment->execute($paymentExecution, $this->_apiContext); // Clear the shopping cart, $request->session()->pull('likes', []); // Write database // Thank the user for the purchase return view('Cart/success'); }
function displayConfirm() { global $cookie, $smarty, $ppPayment, $cart; if (!$cookie->isLogged(true)) { header('location:../../../'); exit; die('Not logged'); } unset($cookie->paypal_token); if ($cart->id_currency != $ppPayment->getCurrency((int) $cart->id_currency)->id) { $cart->id_currency = (int) $ppPayment->getCurrency((int) $cart->id_currency)->id; $cookie->id_currency = (int) $cart->id_currency; $cart->update(); Tools::redirect('modules/' . $ppPayment->name . '/payment/submit.php'); } // Display all and exit include _PS_ROOT_DIR_ . '/header.php'; $smarty->assign(array('logo' => $ppPayment->getLogo(), 'cust_currency' => $cart->id_currency, 'currency' => $ppPayment->getCurrency((int) $cart->id_currency), 'total' => $cart->getOrderTotal(true, PayPal::BOTH), 'this_path_ssl' => PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $ppPayment->name . '/', 'mode' => 'payment/')); echo $ppPayment->display('paypal.php', 'confirm.tpl'); include _PS_ROOT_DIR_ . '/footer.php'; die; }
/** * Returns the PayPal public certificate filename. * * @param string The environment to get the certificate for. * @return mixed The path and file of the certificate file, or a PayPal error object on failure. */ function getPayPalCertificateFile($environment) { $package_root = PayPal::getPackageRoot(); $cert = $package_root . '/cert/' . strtolower($environment) . '.paypal.com.pem'; if (@(include "{$package_root}/conf/paypal-sdk.php")) { if (isset($__PP_CONFIG['paypal_cert_file']) && !empty($__PP_CONFIG['paypal_cert_file'])) { $cert = $__PP_CONFIG['paypal_cert_file'][$environment]; } } if (!file_exists($cert)) { return PayPal::raiseError("Could not file Paypal public Certificate file '{$cert}'"); } return $cert; }
/** * Get information describing all types provided by the SDK. * @static */ function getTypeList() { $root_dir = PayPal::getPackageRoot(); $types = "{$root_dir}/Type/*.php"; $files = glob($types); if (count($files) < 2) { return PayPal::raiseError("Types not found in package! (Looked for '{$types}')"); } $retval = array(); foreach ($files as $type_files) { $retval[] = basename(substr($type_files, 0, strpos($type_files, '.'))); } return $retval; }
<?php include 'ppsdk_include_path.inc'; require_once 'PayPal.php'; require_once 'PayPal/Profile/API.php'; require_once 'PayPal/Profile/Handler.php'; require_once 'PayPal/Profile/Handler/Array.php'; require_once 'request_base.php'; $trans_search =& PayPal::getType('TransactionSearchRequestType'); $trans_search->setStartDate(date('Y-m-d') . 'T00:00:00-0700'); $response = $caller->TransactionSearch($trans_search); $ack = $response->getAck(); echo "RESULT: {$ack}\n"; var_dump($response); ?>
$logger->_log('Profile from session: ' . print_r($profile, true)); } // Build our request from $_POST $grppd_request =& PayPal::getType('GetRecurringPaymentsProfileDetailsRequestType'); if (PayPal::isError($crpp_request)) { $logger->_log('Error in request: ' . print_r($grppd_request, true)); } else { $logger->_log('Create request: ' . print_r($grppd_request, true)); } $logger->_log('Initial request: ' . print_r($grppd_request, true)); /** * Get posted request values */ $profileID = $_POST['profileID']; $grppd_request->setProfileID($profileID); $caller =& PayPal::getCallerServices($profile); // Execute SOAP request $response = $caller->GetRecurringPaymentsProfileDetails($grppd_request); $ack = $response->getAck(); $logger->_log('Ack=' . $ack); switch ($ack) { case ACK_SUCCESS: case ACK_SUCCESS_WITH_WARNING: // Good to break out; break; default: $_SESSION['response'] =& $response; $logger->_log('GetRecurringPaymentsProfileDetails failed: ' . print_r($response, true)); $location = "../ApiError.php?HomeLink=RecurringPayments/RecurringPayments.php&HomeLinkName=RecurringPaymentsHome"; header("Location: {$location}"); }
<?php require_once './paypal/paypal.php'; require_once './paypal/httprequest.php'; //Use this form for production server $r = new PayPal(true); //Use this form for sandbox tests // $r = new PayPal(); $amount = (double) $_POST['amount']; $ret = $r->doExpressCheckout($amount, 'Donation to the Processing Foundation'); //An error occured. The auxiliary information is in the $ret array echo 'Error:'; print_r($ret);
Tools::redirectLink(__PS_BASE_URI__ . '/modules/paypal/express_checkout/submit.php?' . $query); } else { $controller = new FrontController(); $controller->init(); Tools::redirect(Context::getContext()->link->getModuleLink('paypal', 'submit', $values)); } } } else { // If Cart changed, no need to keep the paypal data unset(Context::getContext()->cookie->{PaypalExpressCheckout::$COOKIE_NAME}); $ppec->logs[] = $ppec->l('Cart changed since the last checkout express, please make a new Paypal checkout payment'); } } if (_PS_VERSION_ < '1.5') { $display = new BWDisplay(); } else { $display = new FrontController(); } // Display payment confirmation if ($ppec->ready && Tools::getValue('get_confirmation')) { if (_PS_VERSION_ < '1.5') { $currency = new Currency((int) $ppec->getContext()->cart->id_currency); $ppec->getContext()->smarty->assign(array('form_action' => PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $ppec->name . '/express_checkout/submit.php', 'total' => Tools::displayPrice($ppec->getContext()->cart->getOrderTotal(true), $currency), 'logos' => $ppec->paypal_logos->getLogos(), 'use_mobile' => (bool) $ppec->getContext()->getMobileDevice())); $display->setTemplate(_PS_MODULE_DIR_ . 'paypal/views/templates/front/order-summary.tpl'); } } else { $ppec->getContext()->smarty->assign(array('message' => $ppec->l('Error occurred:'), 'logs' => $ppec->logs, 'use_mobile' => $ppec->getContext()->getMobileDevice())); $display->setTemplate(_PS_MODULE_DIR_ . 'paypal/views/templates/front/error.tpl'); } $display->run(); }
<?php // Include required library files. require_once '../includes/config.php'; require_once '../includes/paypal.class.php'; // Create PayPal object. $PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature); $PayPal = new PayPal($PayPalConfig); // Prepare request arrays $DVFields = array('authorizationid' => '', 'note' => '', 'msgsubid' => ''); $PayPalRequestData = array('DVFields' => $DVFields); // Pass data into class for processing with PayPal and load the response array into $PayPalResult $PayPalResult = $PayPal->DoVoid($PayPalRequestData); // Write the contents of the response array to the screen for demo purposes. echo '<pre />'; print_r($PayPalResult);
function &DoAuthorization($DoAuthorizationReq) { $start = $this->_getMicroseconds(); // Handle type objects. if (is_a($DoAuthorizationReq, 'XSDType')) { $DoAuthorizationReq->setVersion(PAYPAL_WSDL_VERSION); $DoAuthorizationReq = $DoAuthorizationReq->getSoapValue('DoAuthorizationRequest', 'urn:ebay:api:PayPalAPI'); } // Make sure we can find a valid WSDL endpoint for this method. $res = $this->setEndpoint('PayPalAPIAA', PAYPAL_WSDL_VERSION); if (PayPal::isError($res)) { $this->_logTransaction('DoAuthorization', $this->_getElapsed($start), $res); return $res; } // DoAuthorizationReq is a ComplexType, refer to the WSDL for more info. $DoAuthorizationReq_attr['xmlns'] = 'urn:ebay:api:PayPalAPI'; $DoAuthorizationReq =& new SOAP_Value('DoAuthorizationReq', false, $DoAuthorizationReq, $DoAuthorizationReq_attr); $result = $this->call('DoAuthorization', $v = array("DoAuthorizationReq" => $DoAuthorizationReq), array('namespace' => 'urn:ebay:api:PayPalAPI', 'soapaction' => '', 'style' => 'document', 'use' => 'literal')); $response = $this->getResponseObject($result, 'DoAuthorizationResponseType'); $this->_logTransaction('DoAuthorization', $this->_getElapsed($start), $response); return $response; }
/** * Factory for creating instances of the EWPProfile. Used when * providing an existing Profile ID to load from * * @param string The Profile ID of this instance * @param object A valid Profile Handler instance * @return object A new instance of EWPProfile for the given ID or a PayPal error object on failure */ function getInstance($id, &$handler) { $classname = __CLASS__; $inst = new $classname($id, $handler); $result = $inst->_load(); if (PayPal::isError($result)) { return $result; } return $inst; }