コード例 #1
0
ファイル: GopayHelper.php プロジェクト: klimesf/gopay
 /**
  * Sestaveni platebniho tlacitka formou odkazu pro jednoduchou integraci
  *
  * @param float $targetGoId - identifikace prijemce - GoId pridelene GoPay
  * @param string $productName - nazev objednavky / zbozi
  * @param int $totalPrice - cena objednavky v halerich
  * @param string $currency - identifikator meny
  * @param string $orderNumber - identifikace objednavky u prijemce
  * @param string $successURL - URL, kam se ma prejit po uspesnem zaplaceni
  * @param string $failedURL - URL, kam se ma prejit po neuspesnem zaplaceni
  * @param array $paymentChannels - pole plat. metod, ktere se zobrazi na brane
  * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
  *
  * @param boolean $preAuthorization - jedna-li se o predautorizovanou platbu
  * @param boolean $recurrentPayment - jedna-li se o opakovanou platbu
  * @param date $recurrenceDateTo - do kdy se ma opakovana platba provadet
  * @param string $recurrenceCycle - frekvence opakovresultane platby - mesic/tyden/den
  * @param int $recurrencePeriod - pocet plateb v cyklu $recurrenceCycle - kolikrat v mesici/... se opakovana platba provede
  *
  * Informace o zakaznikovi
  * @param string $firstName   - Jmeno zakaznika
  * @param string $lastName    - Prijmeni
  *
  * Adresa
  * @param string $city        - Mesto
  * @param string $street      - Ulice
  * @param string $postalCode  - PSC
  * @param string $countryCode - Kod zeme. Validni kody jsou uvedeny ve tride CountryCode
  * @param string $email       - Email zakaznika
  * @param string $phoneNumber - Tel. cislo
  *
  * @param string $p1 - $p4 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
  *
  * @param string $lang - jazyk platebni brany
  *
  * @return HTML kod platebniho tlacitka
  */
 public static function createPaymentHref($targetGoId, $productName, $totalPrice, $currency, $orderNumber, $successURL, $failedURL, $preAuthorization, $recurrentPayment, $recurrenceDateTo, $recurrenceCycle, $recurrencePeriod, $paymentChannels, $defaultPaymentChannel, $secureKey, $firstName, $lastName, $city, $street, $postalCode, $countryCode, $email, $phoneNumber, $p1, $p2, $p3, $p4, $lang)
 {
     $paymentChannelsString = !empty($paymentChannels) ? join($paymentChannels, ",") : "";
     $encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentCommand((double) $targetGoId, $productName, (int) $totalPrice, $currency, $orderNumber, $failedURL, $successURL, $preAuthorization, $recurrentPayment, $recurrenceDateTo, $recurrenceCycle, $recurrencePeriod, $paymentChannelsString, $secureKey)), $secureKey);
     $params = "";
     $params .= "paymentCommand.targetGoId=" . $targetGoId;
     $params .= "&paymentCommand.productName=" . urlencode($productName);
     $params .= "&paymentCommand.totalPrice=" . $totalPrice;
     $params .= "&paymentCommand.currency=" . $currency;
     $params .= "&paymentCommand.orderNumber=" . urlencode($orderNumber);
     $params .= "&paymentCommand.successURL=" . urlencode($successURL);
     $params .= "&paymentCommand.failedURL=" . urlencode($failedURL);
     $params .= "&paymentCommand.paymentChannels=" . urlencode($paymentChannelsString);
     $params .= "&paymentCommand.defaultPaymentChannel=" . urlencode($defaultPaymentChannel);
     $params .= "&paymentCommand.encryptedSignature=" . urlencode($encryptedSignature);
     $params .= "&paymentCommand.preAuthorization=" . GopayHelper::castBoolean2String($preAuthorization);
     $params .= "&paymentCommand.recurrentPayment=" . GopayHelper::castBoolean2String($recurrentPayment);
     $params .= "&paymentCommand.recurrenceDateTo=" . urlencode($recurrenceDateTo);
     $params .= "&paymentCommand.recurrenceCycle=" . urlencode($recurrenceCycle);
     $params .= "&paymentCommand.recurrencePeriod=" . $recurrencePeriod;
     $params .= "&paymentCommand.customerData.firstName=" . urlencode($firstName);
     $params .= "&paymentCommand.customerData.lastName=" . urlencode($lastName);
     $params .= "&paymentCommand.customerData.city=" . urlencode($city);
     $params .= "&paymentCommand.customerData.street=" . urlencode($street);
     $params .= "&paymentCommand.customerData.postalCode=" . urlencode($postalCode);
     $params .= "&paymentCommand.customerData.countryCode=" . urlencode($countryCode);
     $params .= "&paymentCommand.customerData.email=" . urlencode($email);
     $params .= "&paymentCommand.customerData.phoneNumber=" . urlencode($phoneNumber);
     $params .= "&paymentCommand.p1=" . urlencode($p1);
     $params .= "&paymentCommand.p2=" . urlencode($p2);
     $params .= "&paymentCommand.p3=" . urlencode($p3);
     $params .= "&paymentCommand.p4=" . urlencode($p4);
     $params .= "&paymentCommand.lang=" . $lang;
     $ouput = "";
     $ouput .= "<a target='_blank' href='" . GopayConfig::baseIntegrationURL() . "?" . $params . "'>";
     $ouput .= " Zaplatit ";
     $ouput .= "</a>";
     return $ouput;
 }