Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix to allow write detailed list of products pp

  • Loading branch information...
commit 70ea1a2864971078b3b67e5ca1051be174f23fa0 1 parent 5d6b089
@guillermofr authored
Showing with 78 additions and 1 deletion.
  1. +78 −1 libraries/merchant/merchant_paypal_base.php
View
79 libraries/merchant/merchant_paypal_base.php
@@ -87,12 +87,89 @@ protected function _new_request($method)
return $request;
}
+
+ /**
+ PARAMS
+ - REQUIRED
+ 'items' => array(
+ array( 'name'=>'',
+ 'desc'=>'',
+ 'amt'=>,
+ 'qty'=>
+ )
+ ),
+ 'itemamt' => '0.00', //is calculated in library
+ 'currency' => 'EUR',
+ 'return_url' => 'http://.....',
+ 'cancel_url' => 'http://.....',
+
+ - OPCIONAL
+
+ 'taxamt' => 0.00, //tax IVA
+ 'shippingamt' => 0.00 , //shipping costs
+ 'handlingamt' => 0.00, //handling costs
+ 'insuranceamt' => 0.00, //insurance costs
+ 'shipdiscamt' => 0.00, //discount amount (put it negative)
+ 'amount' => '0.00', //is calculated in library
+
+ */
+
protected function _add_request_details(&$request, $action, $prefix = '')
{
$request[$prefix.'PAYMENTACTION'] = $action;
- $request[$prefix.'AMT'] = $this->amount_dollars();
$request[$prefix.'CURRENCYCODE'] = $this->param('currency');
+ $request[$prefix.'AMT'] = $this->amount_dollars();
+ $request[$prefix.'ITEMAMT'] = $this->param('itemamt');
$request[$prefix.'DESC'] = $this->param('description');
+
+ //items
+ $items = $this->param('items');
+ if (is_array($items) == 0) {
+ return false;
+ }
+
+ //total amount
+ $amt = 0;
+ $list_prefix = 'L_PAYMENTREQUEST_0_';
+
+ $list_index = 0;
+ //add all items to request
+ foreach ($items as $item){
+ $request[$list_prefix.'NAME'.$list_index] = $item['name'];
+ $request[$list_prefix.'DESC'.$list_index] = $item['desc'];
+ $request[$list_prefix.'AMT'.$list_index] = $item['amt'];
+ $request[$list_prefix.'QTY'.$list_index] = $item['qty'];
+ $amt += $item['amt'] * $item['qty'];
+ $list_index++;
+ }
+
+ //total amount , only items
+ $request[$prefix.'ITEMAMT'] = $amt;
+
+ //tax IVA
+ $amt += $this->param('taxamt');
+ $request['PAYMENTREQUEST_0_TAXAMT'] = $this->param('taxamt');
+
+ //shipping costs
+ $amt += $this->param('shippingamt');
+ $request['PAYMENTREQUEST_0_SHIPPINGAMT'] = $this->param('shippingamt');
+
+ //handling costs
+ $amt += $this->param('handlingamt');
+ $request['PAYMENTREQUEST_0_HANDLINGAMT'] = $this->param('handlingamt');
+
+ //insurance costs
+ $amt += $this->param('insuranceamt');
+ $request['PAYMENTREQUEST_0_INSURANCEAMT'] = $this->param('insuranceamt');
+
+ //discount amount (put it negative)
+ $amt += $this->param('shipdiscamt');
+ $request['PAYMENTREQUEST_0_SHIPDISCAMT'] = $this->param('shipdiscamt');
+
+
+ //total amount with extra costs
+ $request[$prefix.'AMT'] = $amt;
+
}
/**

4 comments on commit 70ea1a2

@paroxp

Thanks guillermofr... Nice fix, helped me a lot.

@vincent-vieira

Thanks dude, that fix is making my life better.

@wakasann

Thanks

@malithgp88

this is nicely working. thanx a lot

Please sign in to comment.
Something went wrong with that request. Please try again.