setPath() public method

A JSON pointer that references a location in the target document where the operation is performed. A string value.
public setPath ( string $path )
$path string
 /**
  * @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 $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);
 }
 /**
  * @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);
 }
Exemplo n.º 4
0
 public function update($paymentId, array $updateInfo)
 {
     $apiContext = $this->connectionService->getApiContext();
     $dispatcher = $this->connectionService->getDispatcher();
     $payment = $this->get($paymentId);
     $event = new PaymentEvent($payment);
     $dispatcher->dispatch(PaymentEvent::UPDATE_START, $event);
     $patchRequest = new PatchRequest();
     foreach ($updateInfo as $operation => $fields) {
         $patch = new Patch();
         $patch->setOp($operation);
         foreach ($fields as $key => $value) {
             $patch->setPath($key)->setValue($value);
         }
         $patchRequest->addPatch(clone $patch);
     }
     $result = $payment->update($patchRequest, $apiContext);
     $event = new PaymentEvent($payment);
     $dispatcher->dispatch($result, $event);
     return $result;
 }
Exemplo n.º 5
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);
 }
 public function update($creditCardToken, array $updateInfo)
 {
     $apiContext = $this->connectionService->getApiContext();
     $dispatcher = $this->connectionService->getDispatcher();
     $creditCard = $this->getDetails($creditCardToken);
     $creditCardEvent = new CreditCardEvent($creditCard);
     $dispatcher->dispatch(CreditCardEvent::UPDATE_START, $creditCardEvent);
     $patchRequest = new PatchRequest();
     foreach ($updateInfo as $operation => $fields) {
         $allowedOperation = Validation::updateOP($operation);
         if ($allowedOperation) {
             $patch = new Patch();
             $patch->setOp($operation);
             foreach ($fields as $key => $value) {
                 $patch->setPath($key)->setValue($value);
             }
             $patchRequest->addPatch(clone $patch);
         }
     }
     $result = $creditCard->update($patchRequest, $apiContext);
     $creditCardEvent = new CreditCardEvent($result);
     $dispatcher->dispatch(CreditCardEvent::UPDATE_END, $creditCardEvent);
     return true;
 }
Exemplo n.º 7
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.º 8
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;
 }