/** * @group integration */ public function testOperations() { try { $authId = AuthorizationTest::authorize(); $auth = Authorization::get($authId); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captr = new Capture(); $captr->setId($authId); $captr->setAmount($amount); $capt = $auth->capture($captr); $captureId = $capt->getId(); $this->assertNotNull($captureId); $refund = new Refund(); $refund->setId($captureId); $refund->setAmount($amount); $capture = Capture::get($captureId); $this->assertNotNull($capture->getId()); $retund = $capture->refund($refund); $this->assertNotNull($retund->getId()); } catch (PayPalConnectionException $ex) { $this->markTestSkipped('Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()); } }
public static function createCapture() { $capture = new Capture(); $capture->setAuthorization_id(self::$authorization_id); $capture->setCreate_time(self::$create_time); $capture->setDescription(self::$description); $capture->setId(self::$id); $capture->setParent_payment(self::$parent_payment); $capture->setState(self::$state); return $capture; }
public function testOperations() { $authId = AuthorizationTest::authorize(); $auth = Authorization::get($authId); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captr = new Capture(); $captr->setId($authId); $captr->setAmount($amount); $capt = $auth->capture($captr); $captureId = $capt->getId(); $this->assertNotNull($captureId); $refund = new Refund(); $refund->setId($captureId); $refund->setAmount($amount); $capture = Capture::get($captureId); $this->assertNotNull($capture->getId()); $retund = $capture->refund($refund); $this->assertNotNull($retund->getId()); }
use PayPal\Api\Capture; use PayPal\Api\Amount; use PayPal\Api\Authorization; // ### Create a mock Capture try { // create a mock authorization to get authorization Id // createAuthorization is defined in common.php $authId = createAuthorization($apiContext); // Lookup the authorization $authorization = Authorization::get($authId, $apiContext); ### Capture $amt = new Amount(); $amt->setCurrency("USD")->setTotal("1.00"); // Create a capture $captureInfo = new Capture(); $captureInfo->setId($authId)->setAmount($amt); $capture = $authorization->capture($captureInfo, $apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } // ### Retrieve Capture details // You can look up a capture by invoking the Capture::get method // with a valid ApiContext (See bootstrap.php for more on `ApiContext`) try { $capture = Capture::get($capture->getId(), $apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1);
public function testOperations() { $authId = self::authorize(); $auth = Authorization::get($authId); $this->assertNotNull($auth->getId()); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captur = new Capture(); $captur->setId($authId); $captur->setAmount($amount); $capt = $auth->capture($captur); $this->assertNotNull($capt->getId()); $authId = self::authorize(); $auth = Authorization::get($authId); $void = $auth->void(); $this->assertNotNull($void->getId()); }
use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\CreditCard; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; use PayPal\Api\Authorization; // create payment to get authorization Id $authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); $amt->setTotal("1.00"); ### Capture $captur = new Capture(); $captur->setId($authId); $captur->setAmount($amt); // get the authorization $authorization = Authorization::get($authId, $apiContext); // ### Capture Payment // Capture Payment by posting to the APIService // using a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the status; try { $capt = $authorization->capture($captur, $apiContext); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } // ### Get Capture
/** * @group integration */ public function testOperations() { try { $authId = self::authorize(); $auth = Authorization::get($authId); $this->assertNotNull($auth->getId()); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captur = new Capture(); $captur->setId($authId); $captur->setAmount($amount); $capt = $auth->capture($captur); $this->assertNotNull($capt->getId()); $authId = self::authorize(); $auth = Authorization::get($authId); $void = $auth->void(); $this->assertNotNull($void->getId()); $auth->setId(null); try { $auth->void(); } catch (\InvalidArgumentException $ex) { $this->assertEquals($ex->getMessage(), "Id cannot be null"); } } catch (PayPalConnectionException $ex) { $this->markTestSkipped('Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()); } }
public function testOperations() { $authId = self::authorize(); $auth = Authorization::get($authId); $this->assertNotNull($auth->getId()); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captur = new Capture(); $captur->setId($authId); $captur->setAmount($amount); $capt = $auth->capture($captur); $this->assertNotNull($capt->getId()); $authId = self::authorize(); $auth = Authorization::get($authId); $void = $auth->void(); $this->assertNotNull($void->getId()); $auth->setId(null); try { $auth->void(); } catch (\InvalidArgumentException $ex) { $this->assertEquals($ex->getMessage(), "Id cannot be null"); } }
public function createCapture($authId, Amount $amount) { $capture = new Capture(); $capture->setId($authId)->setAmount($amount); return $capture; }