Я пробовал большую часть класса, которые доступны в Интернете, но когда я выполняю некоторые ошибки, найденные здесь
——————————— Отправить API счета ————— ————————
Failure
Invalid request parameter: quantity must be in the range 0.001 through 9999.999 → quantity = 0
но я установил это количество = 1, тогда почему он дал эту ошибку … я использовал следующий код
require_once('class.invoice.php');
$ppInv = new PaypalInvoiceAPI("sandbox"); //pass 'live' for actual paypal account
/**
* Populate Data
*/
$aryData['language'] = "en_US";
$aryData['merchantEmail'] = $business;
$aryData['payerEmail'] = "[email protected]";
$aryData['currencyCode'] = "USD";
//$aryData['orderId'] = "0001";
$aryData['orderId'] = strtotime('now');
$aryData['invoiceDate'] = "2014-09-19T05:38:48Z";
$aryData['dueDate'] = "2014-12-31T05:38:48Z";
$aryData['paymentTerms'] = "Net45"; //[DueOnReceipt, DueOnDateSpecified, Net10, Net15, Net30, Net45]
$aryData['discountPercent'] = "0";
$aryData['discountAmount'] = "0";
$aryData['invoiceTerms'] = "These are Inovice Terms and Conditions";
$aryData['invoiceNote'] = "These are Invoice notes";
$aryData['merchantMemo'] = "This is Merchant Memo";
$aryData['shippingAmount'] = "10.00";
$aryData['shippingTaxName'] = "S Tax Name";
$aryData['shippingTaxRate'] = "5.00";
$aryData['logoURL'] = "https://xyx.com/wp-content/uploads/2013/12/logo1.png";
$aryData['merchantFirstName'] = "Ashish";
$aryData['merchantLastName'] = "Sharma";
$aryData['merchantBusinessName'] = "Selling";
$aryData['merchantPhone'] = "";
$aryData['merchantFax'] = "";
$aryData['merchantWebsite'] = "";
$aryData['merchantCustomValue'] = "";
$aryData['merchantLine1'] = "Bhopal";
$aryData['merchantLine2'] = "Merchant Address Line 2";
$aryData['merchantCity'] = "Merchant City";
$aryData['merchantState'] = "Merchant State";
$aryData['merchantPostalCode'] = "462021";
$aryData['merchantCountryCode'] = "IN";
$aryData['billingFirstName'] = "Sam";
$aryData['billingLastName'] = "Peter";
$aryData['billingBusinessName'] = "Shiping";
$aryData['billingPhone'] = "";
$aryData['billingFax'] = "";
$aryData['billingWebsite'] = "";
$aryData['billingCustomValue'] = "";
$aryData['billingLine1'] = "Bhopal";
$aryData['billingLine2'] = "";
$aryData['billingCity'] = "";
$aryData['billingState'] = "";
$aryData['billingPostalCode'] = "462021";
$aryData['billingCountryCode'] = "IN";
$aryData['shippingFirstName'] = "Ashish";
$aryData['shippingLastName'] = "Sharma";
$aryData['shippingBusinessName'] = "Shipping Business Name";
$aryData['shippingPhone'] = "Shipping Phone";
$aryData['shippingFax'] = "Shipping Fax";
$aryData['shippingWebsite'] = "Shipping Website";
$aryData['shippingCustomValue'] = "Shipping Custom Value";
$aryData['shippingLine1'] = "India";
$aryData['shippingLine2'] = "Shipping Line 2";
$aryData['shippingCity'] = "Shipping City";
$aryData['shippingState'] = "Shipping State";
$aryData['shippingPostalCode'] = "Shipping Postal Code";
$aryData['shippingCountryCode'] = "US";
$aryItems[0]['name'] = "Individual Product";
$aryItems[0]['description'] = "Item 1 Description";
$aryItems[0]['date'] = "2014-09-20T05:38:48Z";
$aryItems[0]['quantity'] = "003";
$aryItems[0]['unitprice'] = "1";
$aryItems[0]['taxName'] = "";
$aryItems[0]['taxRate'] = "";
/**
* Create Invoice Task
*/
echo "<br /><br />---------------------------------Send Invoice API-------------------------------------<br /><br />";
$res = $ppInv->doCreateInvoice($aryData, $aryItems);
// echo "<pre>";
// print_r($res);
// echo "</pre>";
if($res['responseEnvelope.ack']== "Success")
{
echo "<br />Success Creating Invoice: '{$res['invoiceID']}'";
echo "<br /><br />---------------------------------Send Invoice API-------------------------------------<br /><br />";
$res_send = $ppInv->doSendInvoice($res['invoiceID']);
// echo "<pre>";
// print_r($res_send);
// echo "</pre>";
if($res_send['responseEnvelope.ack']== "Success")
{
echo "<br />Success Sending Invoice";
}
else
{
//Get Error String
echo $ppInv->formatErrorMessages($res_send);
}
}
else
{
//Get Error String
echo $ppInv->formatErrorMessages($res);
}?>
Это функция
function prepareCreateInvoice($aryData, $aryItems)
{
$aryCreateInvoice = array();
if(trim(@$aryData['language'])!= "")
$aryCreateInvoice['requestEnvelope.errorLanguage'] = $aryData['language']; //en_US //TODO
if(trim(@$aryData['merchantEmail'])!= "")
$aryCreateInvoice['invoice.merchantEmail'] = $aryData['merchantEmail'];
if(trim(@$aryData['payerEmail'])!= "")
$aryCreateInvoice['invoice.payerEmail'] = $aryData['payerEmail'];
if(trim(@$aryData['currencyCode'])!= "")
$aryCreateInvoice['invoice.currencyCode'] = $aryData['currencyCode']; //USD TODO
if(trim(@$aryData['orderId'])!= "")
$aryCreateInvoice['invoice.number'] = $aryData['orderId'];
if(trim(@$aryData['invoiceID'])!= "")
$aryCreateInvoice['invoiceID'] = $aryData['invoiceID'];
if(trim(@$aryData['paymentTerms'])!= "")
$aryCreateInvoice['invoice.paymentTerms'] = $aryData['paymentTerms']; //[DueOnReceipt, DueOnDateSpecified, Net10, Net15, Net30, Net45]
if(trim(@$aryData['discountPercent'])!= "")
$aryCreateInvoice['invoice.discountPercent'] = $aryData['discountPercent'];
if(trim(@$aryData['discountAmount'])!= "")
$aryCreateInvoice['invoice.discountAmount'] = $aryData['discountAmount'];
if(trim(@$aryData['invoiceTerms'])!= "")
$aryCreateInvoice['invoice.terms'] = $aryData['invoiceTerms'];
if(trim(@$aryData['invoiceNote'])!= "")
$aryCreateInvoice['invoice.note'] = $aryData['invoiceNote'];
if(trim(@$aryData['merchantMemo'])!= "")
$aryCreateInvoice['invoice.merchantMemo'] = $aryData['merchantMemo'];
if(trim(@$aryData['shippingAmount'])!= "")
$aryCreateInvoice['invoice.shippingAmount'] = $aryData['shippingAmount'];
if(trim(@$aryData['shippingTaxName'])!= "")
$aryCreateInvoice['invoice.shippingTaxName'] = $aryData['shippingTaxName'];
if(trim(@$aryData['shippingTaxRate'])!= "")
$aryCreateInvoice['invoice.shippingTaxRate'] = $aryData['shippingTaxRate'];
if(trim(@$aryData['logoURL'])!= "")
$aryCreateInvoice['invoice.logoUrl'] = $aryData['logoURL'];
if(trim(@$aryData['merchantFirstName'])!= "")
$aryCreateInvoice['invoice.merchantInfo.firstName'] = $aryData['merchantFirstName'];
if(trim(@$aryData['merchantLastName'])!= "")
$aryCreateInvoice['invoice.merchantInfo.lastName'] = $aryData['merchantLastName'];
if(trim(@$aryData['merchantBusinessName'])!= "")
$aryCreateInvoice['invoice.merchantInfo.businessName'] = $aryData['merchantBusinessName'];
if(trim(@$aryData['merchantPhone'])!= "")
$aryCreateInvoice['invoice.merchantInfo.phone'] = $aryData['merchantPhone'];
if(trim(@$aryData['merchantFax'])!= "")
$aryCreateInvoice['invoice.merchantInfo.fax'] = $aryData['merchantFax'];
if(trim(@$aryData['merchantWebsite'])!= "")
$aryCreateInvoice['invoice.merchantInfo.website'] = $aryData['merchantWebsite'];
if(trim(@$aryData['merchantCustomValue'])!= "")
$aryCreateInvoice['invoice.merchantInfo.customValue'] = $aryData['merchantCustomValue'];
if(trim(@$aryData['merchantLine1'])!= "")
$aryCreateInvoice['invoice.merchantInfo.address.line1'] = $aryData['merchantLine1'];
if(trim(@$aryData['merchantLine2'])!= "")
$aryCreateInvoice['invoice.merchantInfo.address.line2'] = $aryData['merchantLine2'];
if(trim(@$aryData['merchantCity'])!= "")
$aryCreateInvoice['invoice.merchantInfo.address.city'] = $aryData['merchantCity'];
if(trim(@$aryData['merchantState'])!= "")
$aryCreateInvoice['invoice.merchantInfo.address.state'] = $aryData['merchantState'];
if(trim(@$aryData['merchantPostalCode'])!= "")
$aryCreateInvoice['invoice.merchantInfo.address.postalCode'] = $aryData['merchantPostalCode'];
if(trim(@$aryData['merchantCountryCode'])!= "")
$aryCreateInvoice['invoice.merchantInfo.address.countryCode'] = $aryData['merchantCountryCode'];
if(trim(@$aryData['billingFirstName'])!= "")
$aryCreateInvoice['invoice.billingInfo.firstName'] = $aryData['billingFirstName'];
if(trim(@$aryData['billingLastName'])!= "")
$aryCreateInvoice['invoice.billingInfo.lastName'] = $aryData['billingLastName'];
if(trim(@$aryData['billingBusinessName'])!= "")
$aryCreateInvoice['invoice.billingInfo.businessName'] = $aryData['billingBusinessName'];
if(trim(@$aryData['billingPhone'])!= "")
$aryCreateInvoice['invoice.billingInfo.phone'] = $aryData['billingPhone'];
if(trim(@$aryData['billingFax'])!= "")
$aryCreateInvoice['invoice.billingInfo.fax'] = $aryData['billingFax'];
if(trim(@$aryData['billingWebsite'])!= "")
$aryCreateInvoice['invoice.billingInfo.website'] = $aryData['billingWebsite'];
if(trim(@$aryData['billingCustomValue'])!= "")
$aryCreateInvoice['invoice.billingInfo.customValue'] = $aryData['billingCustomValue'];
if(trim(@$aryData['billingLine1'])!= "")
$aryCreateInvoice['invoice.billingInfo.address.line1'] = $aryData['billingLine1'];
if(trim(@$aryData['billingLine2'])!= "")
$aryCreateInvoice['invoice.billingInfo.address.line2'] = $aryData['billingLine2'];
if(trim(@$aryData['billingCity'])!= "")
$aryCreateInvoice['invoice.billingInfo.address.city'] = $aryData['billingCity'];
if(trim(@$aryData['billingState'])!= "")
$aryCreateInvoice['invoice.billingInfo.address.state'] = $aryData['billingState'];
if(trim(@$aryData['billingPostalCode'])!= "")
$aryCreateInvoice['invoice.billingInfo.address.postalCode'] = $aryData['billingPostalCode'];
if(trim(@$aryData['billingCountryCode'])!= "")
$aryCreateInvoice['invoice.billingInfo.address.countryCode'] = $aryData['billingCountryCode'];
if(trim(@$aryData['shippingFirstName'])!= "")
$aryCreateInvoice['invoice.shippingInfo.firstName'] = $aryData['shippingFirstName'];
if(trim(@$aryData['shippingLastName'])!= "")
$aryCreateInvoice['invoice.shippingInfo.lastName'] = $aryData['shippingLastName'];
if(trim(@$aryData['shippingBusinessName'])!= "")
$aryCreateInvoice['invoice.shippingInfo.businessName'] = $aryData['shippingBusinessName'];
if(trim(@$aryData['shippingPhone'])!= "")
$aryCreateInvoice['invoice.shippingInfo.phone'] = $aryData['shippingPhone'];
if(trim(@$aryData['shippingFax'])!= "")
$aryCreateInvoice['invoice.shippingInfo.fax'] = $aryData['shippingFax'];
if(trim(@$aryData['shippingWebsite'])!= "")
$aryCreateInvoice['invoice.shippingInfo.website'] = $aryData['shippingWebsite'];
if(trim(@$aryData['shippingCustomValue'])!= "")
$aryCreateInvoice['invoice.shippingInfo.customValue'] = $aryData['shippingCustomValue'];if(trim(@$aryData['shippingLine1'])!= "")
$aryCreateInvoice['invoice.shippingInfo.address.line1'] = $aryData['shippingLine1'];
if(trim(@$aryData['shippingLine2'])!= "")
$aryCreateInvoice['invoice.shippingInfo.address.line2'] = $aryData['shippingLine2'];
if(trim(@$aryData['shippingCity'])!= "")
$aryCreateInvoice['invoice.shippingInfo.address.city'] = $aryData['shippingCity'];
if(trim(@$aryData['shippingState'])!= "")
$aryCreateInvoice['invoice.shippingInfo.address.state'] = $aryData['shippingState'];
if(trim(@$aryData['shippingPostalCode'])!= "")
$aryCreateInvoice['invoice.shippingInfo.address.postalCode'] = $aryData['shippingPostalCode'];
if(trim(@$aryData['shippingCountryCode'])!= "")
$aryCreateInvoice['invoice.shippingInfo.address.countryCode'] = $aryData['shippingCountryCode']; //US TODO$nLoop = count($aryItems);
for($cnt=0;$cnt<$nLoop;$cnt++)
{
if(trim(@$aryItems[$cnt]['name'])!= "")
$aryCreateInvoice["invoice.itemList.item($cnt).name"] = $this->adjustStringLength($aryItems[$cnt]['item_name']);
if(trim(@$aryItems[$cnt]['description'])!= "")
$aryCreateInvoice["invoice.itemList.item($cnt).description"]= $this->adjustStringLength($aryItems[$cnt]['item_description']);
#if(trim(@$aryData['$aryItems[$cnt]['date']'])!= "")
#$aryCreateInvoice["invoice.itemList.item($cnt).date"] = $aryItems[$cnt]['date'];
if(trim(@$aryItems[$cnt]['quantity'])!= "")
$aryCreateInvoice["invoice.itemList.item($cnt).quantity"] = $this->adjustStringLength($aryItems[$cnt]['item_quantity']);
if(trim(@$aryItems[$cnt]['unitprice'])!= "")
$aryCreateInvoice["invoice.itemList.item($cnt).unitPrice"] = $this->adjustStringLength($aryItems[$cnt]['item_unitprice']);
if(trim(@$aryItems[$cnt]['taxName'])!= "")
$aryCreateInvoice["invoice.itemList.item($cnt).taxName"] = $aryItems[$cnt]['taxName'];
if(trim(@$aryItems[$cnt]['taxRate'])!= "")
$aryCreateInvoice["invoice.itemList.item($cnt).taxRate"] = $aryItems[$cnt]['taxRate'];
}
if(trim(@$aryData['invoiceDate'])!= "")
$aryCreateInvoice['invoice.invoiceDate'] = urldecode($aryData['invoiceDate']); //2011-12-31T05:38:48Z
if(trim(@$aryData['dueDate'])!= "")
$aryCreateInvoice['invoice.dueDate'] = urldecode($aryData['dueDate']);
// $reqstr .= "&invoice.invoiceDate={$aryData['invoiceDate']}";
// $reqstr .= "&invoice.dueDate={$aryData['dueDate']}";
$request_string = http_build_query( $aryCreateInvoice );return $request_string;
}#end of prepareCreateInvoice()
Задача ещё не решена.
Других решений пока нет …