setCategory() public method

Valid Values: ["DIGITAL", "PHYSICAL"]
Deprecation: Not publicly available
public setCategory ( string $category )
$category string
Example #1
0
 private function createPayment($details)
 {
     $payment = new Payment();
     $payer = new Payer();
     $payer->payment_method = "paypal";
     $amount = new Amount();
     $amount->currency = $details['PAYMENTREQUEST_CURRENCYCODE'];
     $amount->total = $details['PAYMENTREQUEST_AMT'];
     $transaction = new Transaction();
     $transaction->amount = $amount;
     $transaction->description = $details['PAYMENTREQUEST_DESCRIPTION'];
     $itemList = new ItemList();
     foreach ($details['PAYMENTREQUEST_ITEMS'] as $itemInfo) {
         $item = new Item();
         $item->setQuantity($itemInfo['quantity']);
         $item->setName($itemInfo['name']);
         $item->setDescription($itemInfo['description']);
         $item->setPrice($itemInfo['price']);
         $item->setCategory($itemInfo['category']);
         $item->setCurrency($itemInfo['currency']);
         $item->setTax($itemInfo['tax']);
         $item->setSku($itemInfo['sku']);
         $itemList->addItem($item);
     }
     $addressInfo = $details['PAYMENTREQUEST_SHIPPING_ADDRESS'];
     $shippingAddress = new ShippingAddress();
     $shippingAddress->setRecipientName($addressInfo['recipient_name']);
     $shippingAddress->setLine1($addressInfo['line1']);
     $shippingAddress->setPostalCode($addressInfo['postal_code']);
     $shippingAddress->setCity($addressInfo['city']);
     $shippingAddress->setCountryCode($addressInfo['country_code']);
     $itemList->setShippingAddress($shippingAddress);
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->return_url = $details['RETURN_URL'];
     $redirectUrls->cancel_url = $details['CANCEL_URL'];
     $payment->intent = "sale";
     $payment->payer = $payer;
     $payment->redirect_urls = $redirectUrls;
     $payment->transactions = [$transaction];
     if (false == isset($details['response']) && false == isset($details['response']['state']) && isset($payment->payer->payment_method) && 'paypal' == $payment->payer->payment_method) {
         $paymentResponse = $payment->create($this->api);
         $details->replace(['response' => $paymentResponse->toArray()]);
         foreach ($paymentResponse->links as $link) {
             if ($link->rel == 'approval_url') {
                 $details->replace(['approval_url' => $link->href]);
             }
         }
     }
 }