示例#1
0
 /**
  * @param NotificationRequestItem $notificationItem
  * @return string
  */
 public function generateNotificationSignature(NotificationRequestItem $notificationItem)
 {
     $data = $notificationItem->getSignatureString();
     echo $data . "\n";
     return $this->signData($data);
 }
示例#2
0
 /**
  * @param Request $request
  * @return Notification
  */
 public static function createFromRequest(Request $request)
 {
     $notification = new Notification();
     $parsed = Json::decode($request->getRawBody());
     $notification->setLive($parsed->live === 'true');
     $items = array();
     foreach ($parsed->notificationItems as $rawItem) {
         $item = new NotificationRequestItem($notification);
         $item->setAdditionalData(self::getNotificationRequestItemValue($rawItem, 'additionalData'));
         $item->setAmountValue(self::getNotificationRequestItemValue($rawItem, 'amount.value'));
         $item->setAmountCurrency(self::getNotificationRequestItemValue($rawItem, 'amount.currency'));
         $item->setPspReference(self::getNotificationRequestItemValue($rawItem, 'pspReference'));
         $item->setEventCode(self::getNotificationRequestItemValue($rawItem, 'eventCode'));
         $date = new DateTime(self::getNotificationRequestItemValue($rawItem, 'eventDate'));
         $item->setEventDate($date);
         $item->setMerchantAccountCode(self::getNotificationRequestItemValue($rawItem, 'merchantAccountCode'));
         $item->setOperations(self::getNotificationRequestItemValue($rawItem, 'operations'));
         $item->setMerchantReference(self::getNotificationRequestItemValue($rawItem, 'merchantReference'));
         $item->setOriginalReference(self::getNotificationRequestItemValue($rawItem, 'originalReference'));
         $item->setPaymentMethod(self::getNotificationRequestItemValue($rawItem, 'paymentMethod'));
         $item->setReason(self::getNotificationRequestItemValue($rawItem, 'reason'));
         $item->setSuccess(self::getNotificationRequestItemValue($rawItem, 'success') === 'true');
         $items[] = $item;
     }
     $notification->setNotificationItems($items);
     return $notification;
 }