Get invoice after payment paypal for merchant api php -
my problem want bill after paying storage ( in .pdf) on server. i've been looking @ api , create invoice know not how bill automatically.
<?php require __dir__ . '/../bootstrap.php'; use paypal\api\address; use paypal\api\billinginfo; use paypal\api\cost; use paypal\api\currency; use paypal\api\invoice; use paypal\api\invoiceaddress; use paypal\api\invoiceitem; use paypal\api\merchantinfo; use paypal\api\paymentterm; use paypal\api\phone; use paypal\api\shippinginfo; $invoice = new invoice(); invoice info $invoice ->setmerchantinfo(new merchantinfo()) ->setbillinginfo(array(new billinginfo())) ->setnote("medical invoice 16 jul, 2013 pst") ->setpaymentterm(new paymentterm()) ->setshippinginfo(new shippinginfo()); merchant info resource representing merchant information can used identify merchant $invoice->getmerchantinfo() ->setemail("jaypatel512-facilitator@hotmail.com") ->setfirstname("dennis") ->setlastname("doctor") ->setbusinessname("medical professionals, llc") ->setphone(new phone()) ->setaddress(new address()); $invoice->getmerchantinfo()->getphone() ->setcountrycode("001") ->setnationalnumber("5032141716"); address information address used creating invoice $invoice->getmerchantinfo()->getaddress() ->setline1("1234 main st.") ->setcity("portland") ->setstate("or") ->setpostalcode("97217") ->setcountrycode("us"); billing information set email address each billing $billing = $invoice->getbillinginfo(); $billing[0] ->setemail("example@example.com"); $billing[0]->setbusinessname("jay inc") ->setadditionalinfo("this billing info") ->setaddress(new invoiceaddress()); $billing[0]->getaddress() ->setline1("1234 main st.") ->setcity("portland") ->setstate("or") ->setpostalcode("97217") ->setcountrycode("us"); items list provide list of items detailed breakdown of invoice $items = array(); $items[0] = new invoiceitem(); $items[0] ->setname("sutures") ->setquantity(100) ->setunitprice(new currency()); $items[0]->getunitprice() ->setcurrency("usd") ->setvalue(5); tax item provide tax information each item. $tax = new \paypal\api\tax(); $tax->setpercent(1)->setname("local tax on sutures"); $items[0]->settax($tax); second item $items[1] = new invoiceitem(); lets add discount item. $item1discount = new cost(); $item1discount->setpercent("3"); $items[1] ->setname("injection") ->setquantity(5) ->setdiscount($item1discount) ->setunitprice(new currency()); $items[1]->getunitprice() ->setcurrency("usd") ->setvalue(5); tax item provide tax information each item. $tax2 = new \paypal\api\tax(); $tax2->setpercent(3)->setname("local tax on injection"); $items[1]->settax($tax2); $invoice->setitems($items); final discount can add final discount invoice shown below. either use "percent" or "value" when providing discount $cost = new cost(); $cost->setpercent("2"); $invoice->setdiscount($cost); $invoice->getpaymentterm() ->settermtype("net_45"); shipping information $invoice->getshippinginfo() ->setfirstname("sally") ->setlastname("patient") ->setbusinessname("not applicable") ->setphone(new phone()) ->setaddress(new invoiceaddress()); $invoice->getshippinginfo()->getphone() ->setcountrycode("001") ->setnationalnumber("5039871234"); $invoice->getshippinginfo()->getaddress() ->setline1("1234 main st.") ->setcity("portland") ->setstate("or") ->setpostalcode("97217") ->setcountrycode("us"); logo can set logo in invoice providing external url pointing logo $invoice->setlogourl('https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg'); sample purposes only. $request = clone $invoice; try { create invoice create invoice calling invoice->create() method valid apicontext (see bootstrap.php more on apicontext) $invoice->create($apicontext); } catch (exception $ex) { note: please not use resultprinter class in original code. sample resultprinter::printerror("create invoice", "invoice", null, $request, $ex); exit(1); } note: please not use resultprinter class in original code. sample resultprinter::printresult("create invoice", "invoice", $invoice->getid(), $request, $invoice); return $invoice;
if orient themselves, or link explains how find grateful
Comments
Post a Comment