diff --git a/Controller/AdminController.php b/Controller/AdminController.php index 59f6819..bd42f48 100644 --- a/Controller/AdminController.php +++ b/Controller/AdminController.php @@ -89,6 +89,7 @@ public function editAction(Request $request, WebsiteFeeSubsEntity $subscriber = if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); + if (!$doMerge) { $em->persist($subscriber); } diff --git a/Controller/SubscribeController.php b/Controller/SubscribeController.php index 9de57ca..f7a6a12 100644 --- a/Controller/SubscribeController.php +++ b/Controller/SubscribeController.php @@ -21,6 +21,7 @@ namespace Paustian\WebsiteFeeModule\Controller; +use Paustian\WebsiteFeeModule\Entity\WebsiteFeeSubsEntity; use Zikula\Bundle\CoreBundle\Controller\AbstractController; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -166,7 +167,7 @@ public function subscribepaypalAction(Request $request) : Response { private function _cancelSubscription(int $uid, int $item_no) : void { $subscription = $this->_get_sub($item_no); $gid = $subscription->getWsfgroupid(); - + $e = ""; if (!$this->_modifyUser($gid, $uid, false, $e)) { //write an error to the error log; $this->_set_error("Unable to cancel subscription: $e"); @@ -176,6 +177,7 @@ private function _cancelSubscription(int $uid, int $item_no) : void { private function _addSubscription(int $uid, int $item_no) : void { $subscription = $this->_get_sub($item_no); $gid = $subscription->getWsfgroupid(); + $e = ""; if (!$this->_modifyUser($gid, $uid, true, $e)) { //write an error to the error log; $this->_set_error("Unable to add subscription: $e"); @@ -303,7 +305,7 @@ private function _enterTransaction(int $uid, //now grab the data out of the subsciption table $subscript_info = $this->_get_sub($item_number); - if ($subscript_info == null) { + if (empty($subscript_info)) { $this->_set_error("No item for the item number. Check your subscription setup to insure that your Subscription Item Number matches what you are putting in your paypal button"); return false; } @@ -314,18 +316,19 @@ private function _enterTransaction(int $uid, $this->_set_error("Incorrect reciever Email:" . $receiver_email . ", correct Email should be:" . $email); return false; } + if($subscr_type !== "subscr_cancel"){ + $payment_amt = $subscript_info->getWsfpaymentamount(); + //I added a range because Paypal was being cute and adding tax + if (($payment_gross == -1) || ((($payment_amt - 2) < $payment_gross) && (($payment_amt + 2) > $payment_gross))) { + $payment_gross = $payment_amt; + } - $payment_amt = $subscript_info->getWsfpaymentamount(); - //I added a range because Paypal was being cute and adding tax - if (($payment_gross == -1) || ((($payment_amt - 2) < $payment_gross) && (($payment_amt + 2) > $payment_gross))) { - $payment_gross = $payment_amt; - } - - // check that payment_amount/payment_currency are correct - if ($payment_gross != $payment_amt) { - //wrong amount payed - $this->_set_error("payment inccorect: " . $payment_gross . ", correct amount should be: " . $payment_amt); - return false; + // check that payment_amount/payment_currency are correct + if ($payment_gross != $payment_amt) { + //wrong amount payed + $this->_set_error("payment inccorect: " . $payment_gross . ", correct amount should be: " . $payment_amt); + return false; + } } $transaction = new WebsiteFeeTransEntity(); @@ -352,7 +355,7 @@ private function _enterTransaction(int $uid, * @param int $item_number * @return array */ - private function _get_sub(int $item_number) : array { + private function _get_sub(int $item_number) : ?WebsiteFeeSubsEntity { $em = $this->getDoctrine()->getManager(); $qb = $em->createQueryBuilder(); if (isset($item_number) && is_numeric($item_number)) { @@ -367,7 +370,7 @@ private function _get_sub(int $item_number) : array { $the_item = $query->getResult(); if (empty($the_item)) { - throw new NotFoundHttpException($this->trans('Unable to get subscriber.')); + return null; } return $the_item[0]; } diff --git a/Entity/WebsiteFeeErrorsEntity.php b/Entity/WebsiteFeeErrorsEntity.php index a277b62..c5e73f8 100644 --- a/Entity/WebsiteFeeErrorsEntity.php +++ b/Entity/WebsiteFeeErrorsEntity.php @@ -14,7 +14,7 @@ namespace Paustian\WebsiteFeeModule\Entity; -use Symfony\Component\Validator\Constraints\DateTime; +use DateTime; use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -86,7 +86,7 @@ public function getWsferroeexp() : string { return $this->wsferroeexp; } - public function getWsferrdate() : datetime { + public function getWsferrdate() : DateTime { return $this->wsferrdate; } @@ -106,7 +106,7 @@ public function setWsferroeexp(string $wsferroeexp) : void { $this->wsferroeexp = $wsferroeexp; } - public function setWsferrdate(datetime $wsferrdate) : void { + public function setWsferrdate(DateTime $wsferrdate) : void { $this->wsferrdate = $wsferrdate; } diff --git a/Entity/WebsiteFeeSubsEntity.php b/Entity/WebsiteFeeSubsEntity.php index e740681..6016931 100644 --- a/Entity/WebsiteFeeSubsEntity.php +++ b/Entity/WebsiteFeeSubsEntity.php @@ -32,7 +32,7 @@ class WebsiteFeeSubsEntity extends EntityAccess { * WebsiteFeeSubs id * * @ORM\Id - * @ORM\Column(type="integer", length=20) + * @ORM\Column(type="integer", length=11) * @ORM\GeneratedValue(strategy="AUTO") */ private $id; @@ -48,7 +48,7 @@ class WebsiteFeeSubsEntity extends EntityAccess { /** * wsfitem item number that is ordered * - * @ORM\Column(type="integer", length=20) + * @ORM\Column(type="integer", length=11) * @Assert\Type( * type="integer", * message="The value {{ value }} is not a valid {{ type }}.") @@ -67,7 +67,7 @@ class WebsiteFeeSubsEntity extends EntityAccess { private $wsfpaymentamount; /** - * WebsiteFeeSubs wsfsubsname -- the name of the subscription. + * WebsiteFeeSubs wsfemail -- the name of the subscription. * @ORM\Column(type="string", length=255) * @Assert\Email(message = "The email '{{ value }}' is not a valid email.") * @@ -117,7 +117,7 @@ public function setWsfsubsname(string $wsfsubsname) : void { $this->wsfsubsname = $wsfsubsname; } - public function setWsfitem(string $wsfitem) : void { + public function setWsfitem(int $wsfitem) : void { $this->wsfitem = $wsfitem; } diff --git a/Entity/WebsiteFeeTransEntity.php b/Entity/WebsiteFeeTransEntity.php index 52b13ca..a4a0078 100644 --- a/Entity/WebsiteFeeTransEntity.php +++ b/Entity/WebsiteFeeTransEntity.php @@ -14,7 +14,7 @@ namespace Paustian\WebsiteFeeModule\Entity; -use Symfony\Component\Validator\Constraints\DateTime; +use DateTime; use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -93,7 +93,7 @@ public function getWsfemail() : string { return $this->wsfemail; } - public function getWsfpaydate() : datetime { + public function getWsfpaydate() : DateTime { return $this->wsfpaydate; } @@ -117,7 +117,7 @@ public function setWsfemail(string $wsfemail) : void { $this->wsfemail = $wsfemail; } - public function setWsfpaydate(datetime $wsfpaydate) : void { + public function setWsfpaydate(DateTime $wsfpaydate) : void { $this->wsfpaydate = $wsfpaydate; } diff --git a/Resources/views/Admin/websitefee_admin_edit.html.twig b/Resources/views/Admin/websitefee_admin_edit.html.twig index 8b2f49d..14e0c14 100644 --- a/Resources/views/Admin/websitefee_admin_edit.html.twig +++ b/Resources/views/Admin/websitefee_admin_edit.html.twig @@ -1,28 +1,26 @@ {% form_theme form '@ZikulaFormExtension/Form/bootstrap_4_zikula_admin_layout.html.twig' %} -
{{ "Fill in the details for a subscription. This is the data PayPal will check against for adding subscriptions. The group ID is the group to which the user should be added." | trans }}
- {{ showflashes() }} - {{ form_start(form) }} - {{ form_errors(form) }} - -{{ "Fill in the details for a subscription. This is the data PayPal will check against for adding subscriptions. The group ID is the group to which the user should be added." | trans }}
+{{ showflashes() }} +{{ form_start(form) }} +{{ form_errors(form) }} + +{{ 'Welcome to the administration interface for the WebsiteFeeModule module. The only item you set up from here is ' | trans }} - {{ 'subscriptions' | trans }}. {{' The rest of the interaction is - done through an interface with paypal. Go to PayPals' | trans }} {{'button creation tool' | trans }} - {{ ' to create your button. Remember to add the custom parameter with the user id in it' | trans }}
-{{ 'Welcome to the administration interface for the WebsiteFeeModule module. The only item you set up from here is ' | trans }} + {{ 'subscriptions' | trans }}. {{' The rest of the interaction is + done through an interface with paypal. Go to PayPals' | trans }} {{'button creation tool' | trans }} + {{ ' to create your button. Remember to add the custom parameter with the user id in it' | trans }}
diff --git a/Resources/views/Admin/websitefee_admin_modify.html.twig b/Resources/views/Admin/websitefee_admin_modify.html.twig index fde413e..f4ac74c 100644 --- a/Resources/views/Admin/websitefee_admin_modify.html.twig +++ b/Resources/views/Admin/websitefee_admin_modify.html.twig @@ -1,21 +1,20 @@ -{{ 'Request' | trans }} | +{{ 'Response' | trans }} | +{{ 'Error Expression' | trans }} | +{{ 'Date' | trans }} | +{{ 'Actions' | trans }} | +|||||
---|---|---|---|---|---|---|---|---|---|
{{ 'Request' | trans }} | -{{ 'Response' | trans }} | -{{ 'Error Expression' | trans }} | -{{ 'Date' | trans }} | -{{ 'Actions' | trans }} | +{{ item.wsfrequest }} | +{{ item.wsfrespone }} | +{{ item.wsferroeexp }} | +{{ item.wsferrdate.date }} | ++ + |
{{ item.wsfrequest }} | -{{ item.wsfrespone }} | -{{ item.wsferroeexp }} | -{{ item.wsferrdate.date }} | -- - | -
{{ 'User Name' | trans }} | +{{ 'Transaction ID' | trans }} | +{{ 'Transaction Type' | trans }} | +{{ 'Email' | trans }} | +{{ 'Date' | trans }} | +{{ 'Actions' | trans }} | +||||||
---|---|---|---|---|---|---|---|---|---|---|---|
{{ 'User Name' | trans }} | -{{ 'Transaction ID' | trans }} | -{{ 'Transaction Type' | trans }} | -{{ 'Email' | trans }} | -{{ 'Date' | trans }} | -{{ 'Actions' | trans }} | +{{ item.wsfusername }} | +{{ item.wsftxid }} | +{{ item.wsfsubtype }} | +{{ item.wsfemail }} | +{{ item.wsfpaydate.date }} | ++ + |
{{ item.wsfusername }} | -{{ item.wsftxid }} | -{{ item.wsfsubtype }} | -{{ item.wsfemail }} | -{{ item.wsfpaydate.date }} | -- - | -
There is no user interface to the WebsiteFee Module.
-There is no user interface to the WebsiteFee Module.
diff --git a/Resources/views/Subscribe/websitefee_subscribe_testsubscribe.html.twig b/Resources/views/Subscribe/websitefee_subscribe_testsubscribe.html.twig index a4136e1..cdcf1db 100644 --- a/Resources/views/Subscribe/websitefee_subscribe_testsubscribe.html.twig +++ b/Resources/views/Subscribe/websitefee_subscribe_testsubscribe.html.twig @@ -1,51 +1,49 @@ {{ pageSetVar('title', 'Test data for posting') }} -{gt text='Create the groups and the subscription data for each item users can subscribe to.'}
-
-{gt text='Transactions'}
-{gt text='Errors'}
-{gt text='Create a New Subscription'}
-{gt text='Current Subscriptions'}
-
-
Dear {$u_name}
-Thank you for purchasing {$book_name}. We hope it helps you in your studies. -Just as a reminder, this is not a regular textbook; take advantage of all the features it has -to offer. Here are just a few examples to help you get started
-If you have questions, or are confused about anything, don't hesitate to use the contact form and thanks again for purchasing the text.
- -Sincerely
-Gary Roberts and Timothy Paustian