setValue() public method

New value to apply based on the operation.
public setValue ( mixed $value )
$value mixed
 /**
  * @depends testGet
  * @param $agreement Agreement
  */
 public function testUpdate($agreement)
 {
     /** @var Patch[] $request */
     $request = $this->operation['request']['body'][0];
     $patch = new Patch();
     $patch->setOp($request['op']);
     $patch->setPath($request['path']);
     $patch->setValue($request['value']);
     $patches = array();
     $patches[] = $patch;
     $patchRequest = new PatchRequest();
     $patchRequest->setPatches($patches);
     $result = $agreement->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
     $this->assertTrue($result);
 }
 /**
  * @depends testGet
  * @param $plan Plan
  * @return Plan
  */
 public function testUpdateChangingState($plan)
 {
     /** @var Patch[] $request */
     $request = $this->operation['request']['body'][0];
     $patch = new Patch();
     $patch->setOp($request['op']);
     $patch->setPath($request['path']);
     $patch->setValue($request['value']);
     $patches = array();
     $patches[] = $patch;
     $patchRequest = new PatchRequest();
     $patchRequest->setPatches($patches);
     $result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
     $this->assertTrue($result);
     return Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall);
 }
 /**
  * @depends testGet
  * @param $webhook Webhook
  */
 public function testUpdate($webhook)
 {
     $patches = array();
     foreach ($this->operation['request']['body'] as $request) {
         /** @var Patch[] $request */
         $patch = new Patch();
         $patch->setOp($request['op']);
         $patch->setPath($request['path']);
         $patch->setValue($request['value']);
         if ($request['path'] == "/url") {
             $new_url = $request['value'] . '?rand=' . uniqid();
             $patch->setValue($new_url);
         }
         $patches[] = $patch;
     }
     $patchRequest = new PatchRequest();
     $patchRequest->setPatches($patches);
     $result = $webhook->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
     $this->assertNotNull($result);
     $found = false;
     $foundObject = null;
     foreach ($result->getEventTypes() as $eventType) {
         if ($eventType->getName() == "PAYMENT.SALE.REFUNDED") {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found);
 }
Exemplo n.º 4
0
 public function activateBillingPlan($planId, $apiContext)
 {
     $patch = new Patch();
     $patch->setOp('replace');
     $patch->setPath('/');
     $patch->setValue(array('state' => 'ACTIVE'));
     $patchRequest = new PatchRequest();
     $patchRequest->setPatches(array($patch));
     $plan = new Plan();
     $plan->setId($planId);
     return $plan->update($patchRequest, $apiContext);
 }
Exemplo n.º 5
0
 /**
  * Adding shipping address to an existing payment.
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return boolean
  */
 public function patchPayment($quote)
 {
     if (Mage::getSingleton('customer/session')->getPayPalPaymentId()) {
         $payment = Payment::get(Mage::getSingleton('customer/session')->getPayPalPaymentId(), $this->_apiContext);
         $patchRequest = new PatchRequest();
         $transactions = $payment->getTransactions();
         if (is_null($transactions[0]->getItemList()->getShippingAddress())) {
             $addressMode = 'add';
         } else {
             $addressMode = 'replace';
         }
         $shippingAddress = $this->buildShippingAddress($quote);
         $addressPatch = new Patch();
         $addressPatch->setOp($addressMode);
         $addressPatch->setPath('/transactions/0/item_list/shipping_address');
         $addressPatch->setValue($shippingAddress);
         $patchRequest->addPatch($addressPatch);
         $response = $payment->update($patchRequest, $this->_apiContext);
         return $response;
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Patches invoice number to PayPal transaction
  * (Magento order increment id)
  *
  * @param $paymentId
  * @param $invoiceNumber
  * @return bool
  */
 public function patchInvoiceNumber($paymentId, $invoiceNumber)
 {
     $payment = Payment::get($paymentId, $this->_apiContext);
     $patchRequest = new PatchRequest();
     $invoiceNumberPatch = new Patch();
     $invoiceNumberPatch->setOp('add');
     $invoiceNumberPatch->setPath('/transactions/0/invoice_number');
     $invoiceNumberPatch->setValue($invoiceNumber);
     $patchRequest->addPatch($invoiceNumberPatch);
     $response = $payment->update($patchRequest, $this->_apiContext);
     return $response;
 }