/** * Creates an Event object * @param array $hash A map of parameters; valid keys are: * <dt><code>paylod</code></dt> <dd>The raw JWS payload. </dd> <strong>required</strong> * <dt><code>url</code></dt> <dd>The URL for the webhook. If present it must match the URL registered for the webhook.</dd> * @param string $publicKey Public key. If null, the value of static Simplify::$publicKey will be used * @param string $privateKey Private key. If null, the value of static Simplify::$privateKey will be used * @return Payments_Event an Event object. */ public static function createEvent($hash, $publicKey = null, $privateKey = null) { $paymentsApi = new Simplify_PaymentsApi(); $jsonObject = $paymentsApi->jwsDecode($hash, $publicKey, $privateKey); if ($jsonObject['event'] == null) { throw new InvalidArgumentException("Incorect data in webhook event"); } return $paymentsApi->convertFromHashToObject($jsonObject['event'], self::getClazz()); }
/** * Creates an Event object * @param array $hash A map of parameters; valid keys are: * <dt><code>paylod</code></dt> <dd>The raw JWS payload. </dd> <strong>required</strong> * <dt><code>url</code></dt> <dd>The URL for the webhook. If present it must match the URL registered for the webhook.</dd> * @param $authentication Object that contains the API public and private keys. If null the values of the static * Simplify::$publicKey and Simplify::$privateKey will be used. * @return Payments_Event an Event object. * @throws InvalidArgumentException */ public static function createEvent($hash, $authentication = null) { $args = func_get_args(); $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); $paymentsApi = new Simplify_PaymentsApi(); $jsonObject = $paymentsApi->jwsDecode($hash, $authentication); if ($jsonObject['event'] == null) { throw new InvalidArgumentException("Incorect data in webhook event"); } return $paymentsApi->convertFromHashToObject($jsonObject['event'], self::getClazz()); }
/** * Retrieve a Simplify_Refund object from the API * * @param string id the id of the Refund object to retrieve * @param string publicKey Public key. If null, the value of static Simplify::$publicKey will be used * @param string privateKey Private key. If null, the value of Simplify::$privateKey will be used * @return Refund a Refund object */ public static function findRefund($id, $publicKey = null, $privateKey = null) { $val = new Simplify_Refund(); $val->id = $id; $obj = Simplify_PaymentsApi::findObject($val, $publicKey, $privateKey); return $obj; }
/** * Updates an Simplify_Invoice object. * * The properties that can be updated: * <dl style="padding-left:10px;"> * <dt><tt>status</tt></dt> <dd>New status of the invoice. [valid values: PAID] <strong>required </strong></dd></dl> * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i> * @return Invoice a Invoice object. */ public function updateInvoice($authentication = null) { $args = func_get_args(); $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); $object = Simplify_PaymentsApi::updateObject($this, $authentication); return $object; }
/** * Retrieve a Simplify_Refund object from the API * * @param string id the id of the Refund object to retrieve * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i> * @return Refund a Refund object */ public static function findRefund($id, $authentication = null) { $args = func_get_args(); $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); $val = new Simplify_Refund(); $val->id = $id; $obj = Simplify_PaymentsApi::findObject($val, $authentication); return $obj; }
/** * <p>Revokes a token from further use. * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used * @return Simplify_AccessToken * @throws InvalidArgumentException */ public function revoke($authentication = null) { $args = func_get_args(); $access_token = $this->access_token; if (empty($access_token)) { throw new InvalidArgumentException('Cannot revoke access token; access token is invalid'); } $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); $props = 'token=' . $access_token . ''; Simplify_AccessToken::sendRequest($props, "revoke", $authentication); $this->access_token = null; $this->refresh_token = null; $this->redirect_uri = null; return $this; }
/** * Updates an Simplify_InvoiceItem object. * * The properties that can be updated: * <ul> * <li>amount </li> * * <li>currency </li> * * <li>description </li> * * * </ul> * @param string publicKey Public key. If null, the value of static Simplify::$publicKey will be used * @param string privateKey Private key. If null, the value of Simplify::$privateKey will be used * @return InvoiceItem a InvoiceItem object. */ public function updateInvoiceItem($publicKey = null, $privateKey = null) { $object = Simplify_PaymentsApi::updateObject($this, $publicKey, $privateKey); return $object; }
/** * @ignore */ public static function listObject($object, $criteria = null, $authentication = null) { if ($criteria != null) { if (isset($criteria['max'])) { $object->max = $criteria['max']; } if (isset($criteria['offset'])) { $object->offset = $criteria['offset']; } if (isset($criteria['sorting'])) { $object->sorting = $criteria['sorting']; } if (isset($criteria['filter'])) { $object->filter = $criteria['filter']; } } $paymentsApi = new Simplify_PaymentsApi(); $jsonObject = $paymentsApi->execute("list", $object, $authentication); $ret = new Simplify_ResourceList(); if (array_key_exists('list', $jsonObject) & is_array($jsonObject['list'])) { foreach ($jsonObject['list'] as $obj) { array_push($ret->list, $paymentsApi->convertFromHashToObject($obj, $object->getClazz())); } $ret->total = $jsonObject['total']; } return $ret; }
/** * Updates an Simplify_Subscription object. * * The properties that can be updated: * <ul> * <li>amount </li> * * <li>coupon </li> * * <li>currency </li> * * <li>frequency </li> * * * * <li>name </li> * * <li>plan </li> * * <li>prorate <strong>(required)</strong></li> * * <li>quantity </li> * </ul> * @param string publicKey Public key. If null, the value of static Simplify::$publicKey will be used * @param string privateKey Private key. If null, the value of Simplify::$privateKey will be used * @return Subscription a Subscription object. */ public function updateSubscription($publicKey = null, $privateKey = null) { $object = Simplify_PaymentsApi::updateObject($this, $publicKey, $privateKey); return $object; }