Ejemplo n.º 1
0
 /**
  * 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());
 }
Ejemplo n.º 2
0
 /**
  * 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());
 }