eroare cod paypal express pentru open cart

Discută aici despre procesoare de plăţi, plăţi electronice, soluţii software de comerţ electronic, "shopping cart", SSL, certificate digitale, tranzacţii online securizate, PayPal, Skrill (MoneyBookers), payU(ePayment), MobilPay .

Moderatori: Zamolxe, Moderatori

ndianaz
Junior Member
Mesaje: 43
Membru din: Sâm Iun 20, 2009 5:01 pm
Localitate: Craiova
Contact:

eroare cod paypal express pentru open cart

Mesajde ndianaz » Mar Iul 03, 2012 4:41 pm

Buna! am si eu nevoie de ajutor cu codul pentru paypal express pe platforma open cart.
Am incercat sa fac un cod in functie de informatiile care le-am gasit in documentatiile lor, si nu numai. Codul este urmatorul:
<?php
class ControllerPaymentPPExpress extends Controller {
protected function index() {
$this->data['button_confirm'] = $this->language->get('button_confirm');

if (!$this->config->get('pp_express')) {
$this->data['action'] = 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';
} else {
$this->data['action'] = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=';
}

$this->load->model('checkout/order');

$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

if (!$this->config->get('pp_express')) {
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
} else {
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
}

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pp_express.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/pp_express.tpl';
} else {
$this->template = 'default/template/payment/pp_express.tpl';
}

$this->render();
}

public function send() {
if (!$this->config->get('pp_express_transaction')) {
$payment_type = 'Authorization';
} else {
$payment_type = 'Sale';
}

$this->load->model('checkout/order');

$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

$request = 'METHOD=DoExpressCheckoutPayment';
$request .= '&VERSION=51.0';
$request .= '&USER=' . urlencode($this->config->get('pp_express_username'));
$request .= '&PWD=' . urlencode($this->config->get('pp_express_password'));
$request .= '&SIGNATURE=' . urlencode($this->config->get('pp_express_signature'));
$request .= '&CUSTREF=' . (int)$order_info['order_id'];
$request .= '&PAYMENTACTION=' . $payment_type;
$request .= '&AMT=' . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false);

$request .= '&FIRSTNAME=' . urlencode($order_info['payment_firstname']);
$request .= '&LASTNAME=' . urlencode($order_info['payment_lastname']);
$request .= '&EMAIL=' . urlencode($order_info['email']);
$request .= '&PHONENUM=' . urlencode($order_info['telephone']);
$request .= '&IPADDRESS=' . urlencode($this->request->server['REMOTE_ADDR']);
$request .= '&STREET=' . urlencode($order_info['payment_address_1']);
$request .= '&CITY=' . urlencode($order_info['payment_city']);
$request .= '&STATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']);
$request .= '&ZIP=' . urlencode($order_info['payment_postcode']);
$request .= '&COUNTRYCODE=' . urlencode($order_info['payment_iso_code_2']);
$request .= '&CURRENCYCODE=' . urlencode($order_info['currency_code']);

if ($this->cart->hasShipping()) {
$request .= '&SHIPTONAME=' . urlencode($order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname']);
$request .= '&SHIPTOSTREET=' . urlencode($order_info['shipping_address_1']);
$request .= '&SHIPTOCITY=' . urlencode($order_info['shipping_city']);
$request .= '&SHIPTOSTATE=' . urlencode(($order_info['shipping_iso_code_2'] != 'US') ? $order_info['shipping_zone'] : $order_info['shipping_zone_code']);
$request .= '&SHIPTOCOUNTRYCODE=' . urlencode($order_info['shipping_iso_code_2']);
$request .= '&SHIPTOZIP=' . urlencode($order_info['shipping_postcode']);
} else {
$request .= '&SHIPTONAME=' . urlencode($order_info['payment_firstname'] . ' ' . $order_info['payment_lastname']);
$request .= '&SHIPTOSTREET=' . urlencode($order_info['payment_address_1']);
$request .= '&SHIPTOCITY=' . urlencode($order_info['payment_city']);
$request .= '&SHIPTOSTATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']);
$request .= '&SHIPTOCOUNTRYCODE=' . urlencode($order_info['payment_iso_code_2']);
$request .= '&SHIPTOZIP=' . urlencode($order_info['payment_postcode']);
}

if (!$this->config->get('pp_express_test')) {
$curl = curl_init('https://api-3t.paypal.com/nvp');
} else {
$curl = curl_init('https://api-3t.sandbox.paypal.com/nvp');
}

curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);

$response = curl_exec($curl);

curl_close($curl);

if (!$response) {
$this->log->write('DoExpressCheckoutPayment failed: ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
}

$response_data = array();

parse_str($response, $response_data);

$json = array();

if (($response_data['ACK'] == 'Success') || ($response_data['ACK'] == 'SuccessWithWarning')) {
$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id'));

$message = '';

if (isset($response_data['AVSCODE'])) {
$message .= 'AVSCODE: ' . $response_data['AVSCODE'] . "\n";
}

if (isset($response_data['CVV2MATCH'])) {
$message .= 'CVV2MATCH: ' . $response_data['CVV2MATCH'] . "\n";
}

if (isset($response_data['TRANSACTIONID'])) {
$message .= 'TRANSACTIONID: ' . $response_data['TRANSACTIONID'] . "\n";
}

$this->model_checkout_order->update($this->session->data['order_id'], $this->config->get('pp_express_order_status_id'), $message, false);

$json['success'] = $this->url->link('checkout/success');
} else {
$json['error'] = $response_data['L_LONGMESSAGE0'];
}

$this->response->setOutput(json_encode($json));
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pp_express.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/pp_express.tpl';
} else {
$this->template = 'default/template/payment/pp_express.tpl';
}
}
?>

iar codul html + javascript este urmatorul :
<form action="<?php echo $action; ?>" method="post">
<div class="buttons">
<div class="right">
<input type="submit" value="<?php echo $button_confirm; ?>" class="button" />
</div>
</div>
</form>
<script type="text/javascript"><!--
$('#button-confirm').bind('click', function() {
$.ajax({
url: 'index.php?route=payment/pp_express/send',
type: 'post',
data: $('#payment :input'),
dataType: 'json',
beforeSend: function() {
$('#button-confirm').attr('disabled', true);

$('#payment').before('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
},
success: function(json) {
if (json['error']) {
alert(json['error']);

$('#button-confirm').attr('disabled', false);
}

$('.attention').remove();

if (json['success']) {
location = json['success'];
}
}
});
});
//--></script>

Cunoaste cineva aceasta platforma si ma poate ajuta?
Ultima oară modificat Dum Iul 15, 2012 6:54 pm de către ndianaz, modificat de 2 ori în total.


www.sperantapentruanimalecraiova.com
adoptiianimale.eublog.ro

ndianaz
Junior Member
Mesaje: 43
Membru din: Sâm Iun 20, 2009 5:01 pm
Localitate: Craiova
Contact:

Mesajde ndianaz » Joi Iul 05, 2012 10:16 pm

nimeni? :( stiu ca se poate descarca de la ei si nici nu costa mult dar vroiam sa incerc sa-l fac eu... sau macar sa stiu daca e bine ce vroiam sa fac.
www.sperantapentruanimalecraiova.com

adoptiianimale.eublog.ro

ndianaz
Junior Member
Mesaje: 43
Membru din: Sâm Iun 20, 2009 5:01 pm
Localitate: Craiova
Contact:

Mesajde ndianaz » Lun Iul 16, 2012 2:09 pm

ndianaz scrie:nimeni? :( stiu ca se poate descarca de la ei si nici nu costa mult dar vroiam sa incerc sa-l fac eu... sau macar sa stiu daca e bine ce vroiam sa fac.


Chiar si contra cost. Desigur, atata timp cat costurile nu depasesc costul extensiei care o poti cumpara ce la ei.
www.sperantapentruanimalecraiova.com

adoptiianimale.eublog.ro

Avatar utilizator
vectorialpx
Senior Member
Mesaje: 4830
Membru din: Mar Mar 01, 2005 9:48 am
Localitate: Bucuresti
Contact:

Mesajde vectorialpx » Lun Iul 16, 2012 2:35 pm

Ce vrei sa faci, ce nu merge?


Înapoi la “Comert electronic”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 2 vizitatori