Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sync with private repo (deprecated features, internal attribution & m…

…erchant options)
  • Loading branch information...
commit e15b5a7f60ca803b116df54bea852de407883685 1 parent c04c2b2
@joshuafarr joshuafarr authored
Showing with 212 additions and 240 deletions.
  1. +26 −238 src/FirstGivingAPIClient.php
  2. +186 −2 src/FirstGivingDonation.php
View
264 src/FirstGivingAPIClient.php
@@ -37,15 +37,7 @@
require_once dirname(__FILE__) . '/FirstGivingCreditCardPayment.php';
require_once dirname(__FILE__) . '/FirstGivingRecurringCreditCardProfileRequest.php';
require_once dirname(__FILE__) . '/FirstGivingRecurringCreditCardProfileResponse.php';
-require_once dirname(__FILE__) . '/FirstGivingECheckPayment.php';
-require_once dirname(__FILE__) . '/FirstGivingIdealPaymentInquiryResponse.php';
-require_once dirname(__FILE__) . '/FirstGivingIdealRedirectResponse.php';
-require_once dirname(__FILE__) . '/FirstGivingIdealRequest.php';
require_once dirname(__FILE__) . '/FirstGivingCreditCardDonationResponse.php';
-require_once dirname(__FILE__) . '/FirstGivingPaypalExpressCheckoutRequest.php';
-require_once dirname(__FILE__) . '/FirstGivingPaypalExpressCheckoutRedirectResponse.php';
-require_once dirname(__FILE__) . '/FirstGivingPaypalExpressCheckoutPaymentResponse.php';
-require_once dirname(__FILE__) . '/FirstGivingPaypalExpressCheckoutBuyerInformation.php';
require_once dirname(__FILE__) . '/Exception/FirstGivingGeneralException.php';
require_once dirname(__FILE__) . '/Exception/FirstGivingCurlException.php';
require_once dirname(__FILE__) . '/Exception/FirstGivingInvalidInputException.php';
@@ -157,6 +149,7 @@ public function getTransactionList($page = NULL, $pageSize = NULL, $dateFrom = N
return $transactions;
}
+
/**
* Get the details of a specific transaction
*
@@ -210,120 +203,6 @@ public function getTransactionDetail($transactionId) {
return $respObj;
}
- public function getIdealBankList() {
- $restRequestObject = $this->sendApiRequest('/ideal/banks', 'GET');
-
- $xmlObject = simplexml_load_string($restRequestObject->getResponseBody());
- $banks = array();
-
- foreach ($xmlObject->firstGivingResponse->banks->bank as $bank) {
- $banks[(string) $bank->id] = (string) $bank->name;
- }
- return $banks;
- }
-
- public function getIdealPaymentInquiry($idealPaymentRequestId) {
- $restResponseObject = $this->sendApiRequest(
- '/ideal/paymentinquiry',
- 'GET',
- array(
- 'idealPaymentRequestId' => $idealPaymentRequestId
- )
- );
-
- $xmlObject = simplexml_load_string($restResponseObject->getResponseBody());
- $r = $xmlObject->firstGivingResponse;
-
- $respObj = new FirstGivingIdealPaymentInquiryResponse();
- $respObj->idealPaymentRequestId = $idealPaymentRequestId;
- $respObj->setAmount((string) $r->amount);
- $respObj->setStatus((string) $r->status);
- $respObj->setTransactionId( (string) $r->transactionId);
- $respObj->setConsumerCity( (string) $r->consumerCity);
- $respObj->setConsumerName( (string) $r->consumerName);
-
- return $respObj;
- }
-
- /**
- *
- * @param FirstGivingPaypalExpressCheckoutRequest $expressCheckoutRedirectRequest
- * $remoteAddr string IP address of the remote user's computer.
- * @return FirstGivingPaypalExpressCheckoutRedirectResponse
- */
- public function getExpressCheckoutRedirect(FirstGivingPaypalExpressCheckoutRequest $expressCheckoutRedirectRequest, $remoteAddr = null) {
-
- // If no remote addr was manually passed, set it to the remote addr reported by the web server.
- if($remoteAddr == null) {
- $remoteAddr = $_SERVER['REMOTE_ADDR'];
- }
-
- // Create an array of values to be passed to FirstGiving.
- $restApiInputValues = array();
- $restApiInputValues['amount'] = $expressCheckoutRedirectRequest->getAmount();
- $restApiInputValues['currencyCode'] = $expressCheckoutRedirectRequest->getCurrencyCode();
- $restApiInputValues['returnUrl'] = $expressCheckoutRedirectRequest->getReturnUrl();
- $restApiInputValues['cancelUrl'] = $expressCheckoutRedirectRequest->getCancelUrl();
- $restApiInputValues['fundraiserId'] = $expressCheckoutRedirectRequest->getFundraiserId();
- $restApiInputValues['charityId'] = $expressCheckoutRedirectRequest->getCharityId();
- $restApiInputValues['eventId'] = $expressCheckoutRedirectRequest->getEventId();
- $restApiInputValues['orderId'] = $expressCheckoutRedirectRequest->getOrderId();
- $restApiInputValues['description'] = $expressCheckoutRedirectRequest->getDescription();
- $restApiInputValues['remoteAddr'] = $remoteAddr;
- $restApiInputValues['reportDonationToTaxAuthority'] = ($expressCheckoutRedirectRequest->getReportDonationToTaxAuthority() == true) ? '1' : '0';
- $restApiInputValues['personalIdentificationNumber'] = ($expressCheckoutRedirectRequest->getPersonalIdentificationNumber() == null) ? '' : $expressCheckoutRedirectRequest->getPersonalIdentificationNumber();
-
- // Send the array of values to FirstGiving.
- $restResponseObject = $this->sendApiRequest('/paypal/expresscheckoutrequest', 'GET', $restApiInputValues);
-
- /* @var $firstGivingPaypalCreditCardDonationResponse FirstGivingPaypalCreditCardDonationResponse */
- $firstGivingPaypalCreditCardDonationResponse = $this->createPaypalExpressCheckoutRedirectResponseObject($restResponseObject);
-
- return $firstGivingPaypalCreditCardDonationResponse;
- }
-
-
- /**
- *
- * @param FirstGivingIdealRequest $idealRequest
- * @param <type> $remoteAddr
- * @return <type>
- */
- public function getIdealRedirect(FirstGivingIdealRequest $idealRequest, $remoteAddr = null) {
-
- // If no remote addr was manually passed, set it to the remote addr reported by the web server.
- if($remoteAddr == null) {
- $remoteAddr = $_SERVER['REMOTE_ADDR'];
- }
-
- // Send the array of values to FirstGiving.
- $restResponseObject = $this->sendApiRequest('/ideal/paymentrequest', 'GET', $idealRequest->toArray());
-
- /* @var $firstGivingIdealResponse FirstGivingPaypalCreditCardDonationResponse */
- $firstGivingIdealResponse = $this->createIdealRedirectResponseObject($restResponseObject);
-
- return $firstGivingIdealResponse;
- }
-
- /**
- * Captures a payment from the buyer identified by $expresscheckoutsessionid.
- * @param $expresscheckoutsessionid
- * @return FirstGivingPaypalExpressCheckoutPaymentResponse
- */
- public function captureExpressCheckoutPayment($expresscheckoutsessionid) {
-
- // Create an array of values to be passed to FirstGiving.
- $restApiInputValues = array();
- $restApiInputValues['expresscheckoutsession'] = $expresscheckoutsessionid;
-
- // Send the array of values to FirstGiving.
- $restResponseObject = $this->sendApiRequest('/paypal/expresscheckoutpayment', 'POST', $restApiInputValues);
-
- /* @var $firstGivingPaypalExpressCheckoutPaymentResponse FirstGivingPaypalExpressCheckoutPaymentResponse */
- $firstGivingPaypalExpressCheckoutPaymentResponse = $this->createPaypalExpressCheckoutPaymentResponpseObject($restResponseObject);
-
- return $firstGivingPaypalExpressCheckoutPaymentResponse;
- }
/**
* Create a recurring donations profile.
@@ -347,9 +226,9 @@ public function createRecurringDonationProfile(FirstGivingDonation $donationObje
$firstGivingCCProfileResponseObject = $this->createRecurringCreditCardProfileResponseObject($restResponseObject);
return $firstGivingCCProfileResponseObject;
-
}
+
/**
* Create a new card on file.
* @return FirstGivingCardOnFileResponse
@@ -391,6 +270,7 @@ public function messageWasSentFromFirstGiving($message, $signature) {
}
+
/**
* Submit a donation to FirstGiving's web API.
*
@@ -414,6 +294,7 @@ public function makeCreditCardDonation(FirstGivingDonation $donationObject, Firs
}
+
/**
* Returns the original array with nulls removed.
* @param $inputArray
@@ -428,50 +309,6 @@ private function removeNulls($inputArray) {
return $newArray;
}
- /**
- * Returns all of the information about the buyer as provided by Paypal's express checkout interface.
- * @param $expresscheckoutsessionid
- * @return FirstGivingPaypalExpressCheckoutBuyerInformation
- */
- public function getPaypalExpressCheckoutBuyerInformation($expresscheckoutsessionid) {
-
- // Send the array of values to FirstGiving.
- $restResponseObject = $this->sendApiRequest('/paypal/expresscheckoutbuyerinformation/'.$expresscheckoutsessionid, 'GET', array());
-
- /* @var $firstGivingPaypalExpressCheckoutBuyerInformation FirstGivingPaypalExpressCheckoutBuyerInformation */
- $firstGivingPaypalExpressCheckoutBuyerInformation = $this->createPaypalExpressCheckoutBuyerInformationObject($restResponseObject);
-
- return $firstGivingPaypalExpressCheckoutBuyerInformation;
- }
-
- /**
- * Loads a buyer information object.
- * @param $restResponseObject
- * @return FirstGivingPaypalExpressCheckoutBuyerInformation
- */
- public function createPaypalExpressCheckoutBuyerInformationObject($restResponseObject) {
-
- // Convert to an xml object.
- $xmlObject = simplexml_load_string($restResponseObject->getResponseBody());
-
- $buyerInfo = new FirstGivingPaypalExpressCheckoutBuyerInformation();
- $buyerInfo->setFirstName(current($xmlObject->firstGivingResponse->firstName));
- $buyerInfo->setLastName(current($xmlObject->firstGivingResponse->lastName));
- $buyerInfo->setEmail(current($xmlObject->firstGivingResponse->email));
- $buyerInfo->setCountry(current($xmlObject->firstGivingResponse->country));
- $buyerInfo->setAddress1(current($xmlObject->firstGivingResponse->address1));
- if(current($xmlObject->firstGivingResponse->address2) !== false) {
- $buyerInfo->setAddress2(current($xmlObject->firstGivingResponse->address2));
- }
- $buyerInfo->setCity(current($xmlObject->firstGivingResponse->city));
- $buyerInfo->setState(current($xmlObject->firstGivingResponse->state));
- $buyerInfo->setZip(current($xmlObject->firstGivingResponse->zip));
- $buyerInfo->setCurrencyCode(current($xmlObject->firstGivingResponse->currencyCode));
- $buyerInfo->setAmount(current($xmlObject->firstGivingResponse->amount));
-
- return $buyerInfo;
-
- }
/**
@@ -608,77 +445,6 @@ private function createSayHelloObject(RestRequest $restRequestObject) {
return $helloResponse;
}
- private function createIdealPaymentEnquiryObject(RestRequest $restRequestObject) {
-
- $response = new FirstGivingIdealPaymentEnquiryResponse();
-
- $xmlObject = simplexml_load_string($restRequestObject->getResponseBody());
-
- $rObj = $xmlObject->firstGivingResponse;
-
- $response->setAmount($rObj->amount);
- $response->setStatus($rObj->status);
- $response->setTransactionId($rObj->transactionId);
-
- return $response;
- }
-
- private function createIdealRedirectResponseObject(RestRequest $restRequestObject) {
-
- // Create the response object.
- $response = new FirstGivingIdealRedirectResponse();
-
- // Convert to an xml object.
- $xmlObject = simplexml_load_string($restRequestObject->getResponseBody());
-
- $rObj = $xmlObject->firstGivingResponse;
- $response->setRedirectUrl((string) $rObj->redirectUrl);
- $response->setNote((string) $rObj->note);
- $response->setIdealPaymentRequestId((string) $rObj->idealPaymentRequestId);
-
- return $response;
-
- }
-
- /**
- * Converts a generic REST request response into a proper FirstGiving Paypal donation response object.
- * @param RestRequest $restRequestObject
- * @return FirstGivingPaypalExpressCheckoutRedirectResponse
- */
- private function createPaypalExpressCheckoutRedirectResponseObject(RestRequest $restRequestObject) {
-
- // Create the response object.
- /* @var $response FirstGivingPaypalExpressCheckoutRedirectResponse */
- $response = new FirstGivingPaypalExpressCheckoutRedirectResponse();
-
- // Convert to an xml object.
- $xmlObject = simplexml_load_string($restRequestObject->getResponseBody());
-
- $response->setRedirectUrl(current($xmlObject->firstGivingResponse->redirectUrl));
-
- return $response;
-
- }
-
- /**
- * Converts a generic REST response into a proper FirstGiving Paypal payment response object.
- * @param RestRequest $restRequestObject
- * @return FirstGivingPaypalExpressCheckoutPaymentResponse
- */
- private function createPaypalExpressCheckoutPaymentResponpseObject(RestRequest $restRequestObject) {
-
- // Create the response object.
- /* @var $paymentResponse FirstGivingPaypalExpressCheckoutPaymentResponse */
- $paymentResponse = new FirstGivingPaypalExpressCheckoutPaymentResponse();
-
- // Convert to an xml object.
- $xmlObject = simplexml_load_string($restRequestObject->getResponseBody());
-
- $paymentResponse->setTransactionId(current($xmlObject->firstGivingResponse->transactionId));
-
- return $paymentResponse;
-
- }
/**
* Converts a generic REST request response into a proper FirstGiving credit card donation response object.
@@ -813,6 +579,28 @@ private function assembleRestApiInputValuesForCreditCardDonation(FirstGivingDona
$restApiInputValues['recurringBillingFrequency'] = $donationObject->getRecurringBillingFrequency();
$restApiInputValues['recurringBillingTerm'] = $donationObject->getRecurringBillingTerm();
+ if ($donationObject->getAttributionType() !== null) {
+ $restApiInputValues['attributionType'] = $donationObject->getAttributionType();
+ $restApiInputValues['attributionName'] = $donationObject->getAttributionName();
+ $restApiInputValues['notificationName'] = $donationObject->getNotificationName();
+ $restApiInputValues['attributionEmail'] = $donationObject->getAttributionEmail();
+ $restApiInputValues['attributionAddressLine1'] = $donationObject->getAttributionAddressLine1();
+ $restApiInputValues['attributionAddressLine2'] = $donationObject->getAttributionAddressLine2();
+ $restApiInputValues['attributionCity'] = $donationObject->getAttributionCity();
+ $restApiInputValues['attributionState'] = $donationObject->getAttributionState();
+ $restApiInputValues['attributionZip'] = $donationObject->getAttributionZip();
+ }
+ // set any internal merchant parameters
+ if ($donationObject->getMerchantId() !== null) {
+ $restApiInputValues['merchantId'] = $donationObject->getMerchantId();
+ }
+ if ($donationObject->getMerchantEmail() !== null) {
+ $restApiInputValues['merchantEmail'] = $donationObject->getMerchantEmail();
+ }
+ if ($donationObject->getMerchantName() !== null) {
+ $restApiInputValues['merchantName'] = $donationObject->getMerchantName();
+ }
+
return $restApiInputValues;
}
View
188 src/FirstGivingDonation.php
@@ -30,7 +30,7 @@
// +---------------------------------------------------------------------------+
class FirstGivingDonation {
-
+
private $charityId;
private $eventId;
private $fundraiserId;
@@ -45,7 +45,191 @@ class FirstGivingDonation {
private $recurringBillingFrequency;
private $recurringBillingTerm;
private $recurringBillingAmount;
-
+
+ // extended attribution fields (internal use only)
+ private $attributionType = null;
+ private $attributionName;
+ private $notificationName;
+ private $attributionEmail;
+ private $attributionAddressLine1;
+ private $attributionAddressLine2;
+ private $attributionCity;
+ private $attributionState;
+ private $attributionZip;
+
+ // merchant parameters (internal use only)
+ private $merchantId = null;
+ private $merchantEmail = null;
+ private $merchantName = null;
+
+ /**
+ * @return the $attributionType
+ */
+ public function getAttributionType() {
+ return $this->attributionType;
+ }
+
+ /**
+ * @param $attributionType the $attributionType to set
+ */
+ public function setAttributionType($attributionType) {
+ $this->attributionType = $attributionType;
+ }
+
+ /**
+ * @return the $attributionName
+ */
+ public function getAttributionName() {
+ return $this->attributionName;
+ }
+
+ /**
+ * @param $attributionName the $attributionName to set
+ */
+ public function setAttributionName($attributionName) {
+ $this->attributionName = $attributionName;
+ }
+
+ /**
+ * @return the $notificationName
+ */
+ public function getNotificationName() {
+ return $this->notificationName;
+ }
+
+ /**
+ * @param $notificationName the $notificationName to set
+ */
+ public function setNotificationName($notificationName) {
+ $this->notificationName = $notificationName;
+ }
+
+ /**
+ * @return the $attributionEmail
+ */
+ public function getAttributionEmail() {
+ return $this->attributionEmail;
+ }
+
+ /**
+ * @param $attributionEmail the $attributionEmail to set
+ */
+ public function setAttributionEmail($attributionEmail) {
+ $this->attributionEmail = $attributionEmail;
+ }
+
+ /**
+ * @return the $attributionAddressLine1
+ */
+ public function getAttributionAddressLine1() {
+ return $this->attributionAddressLine1;
+ }
+
+ /**
+ * @param $attributionAddressLine1 the $attributionAddressLine1 to set
+ */
+ public function setAttributionAddressLine1($attributionAddressLine1) {
+ $this->attributionAddressLine1 = $attributionAddressLine1;
+ }
+
+ /**
+ * @return the $attributionAddressLine2
+ */
+ public function getAttributionAddressLine2() {
+ return $this->attributionAddressLine2;
+ }
+
+ /**
+ * @param $attributionAddressLine2 the $attributionAddressLine2 to set
+ */
+ public function setAttributionAddressLine2($attributionAddressLine2) {
+ $this->attributionAddressLine2 = $attributionAddressLine2;
+ }
+
+ /**
+ * @return the $attributionCity
+ */
+ public function getAttributionCity() {
+ return $this->attributionCity;
+ }
+
+ /**
+ * @param $attributionCity the $attributionCity to set
+ */
+ public function setAttributionCity($attributionCity) {
+ $this->attributionCity = $attributionCity;
+ }
+
+ /**
+ * @return the $attributionState
+ */
+ public function getAttributionState() {
+ return $this->attributionState;
+ }
+
+ /**
+ * @param $attributionState the $attributionState to set
+ */
+ public function setAttributionState($attributionState) {
+ $this->attributionState = $attributionState;
+ }
+
+ /**
+ * @return the $attributionZip
+ */
+ public function getAttributionZip() {
+ return $this->attributionZip;
+ }
+
+ /**
+ * @param $attributionZip the $attributionZip to set
+ */
+ public function setAttributionZip($attributionZip) {
+ $this->attributionZip = $attributionZip;
+ }
+
+ /**
+ * @return the $merchantId
+ */
+ public function getMerchantId() {
+ return $this->merchantId;
+ }
+
+ /**
+ * @param $merchantId the $merchantId to set
+ */
+ public function setMerchantId($merchantId) {
+ $this->merchantId = $merchantId;
+ }
+
+ /**
+ * @return the $merchantName
+ */
+ public function getMerchantName() {
+ return $this->merchantName;
+ }
+
+ /**
+ * @param $merchantName the $merchantName to set
+ */
+ public function setMerchantName($merchantName) {
+ $this->merchantName = $merchantName;
+ }
+
+ /**
+ * @return the $merchantEmail
+ */
+ public function getMerchantEmail() {
+ return $this->merchantEmail;
+ }
+
+ /**
+ * @param $merchantId the $merchantEmail to set
+ */
+ public function setMerchantEmail($merchantEmail) {
+ $this->merchantEmail = $merchantEmail;
+ }
+
/**
* @return the $eventId
*/
Please sign in to comment.
Something went wrong with that request. Please try again.