public static function createCheckoutRequest(Credentials $credentials, PaymentRequest $paymentRequest) { LogPagSeguro::info("PaymentService.Register(" . $paymentRequest->toString() . ") - begin"); $connectionData = new PagSeguroConnectionData($credentials, self::serviceName); try { $connection = new HttpConnection(); $connection->post(self::buildCheckoutRequestUrl($connectionData), PaymentParser::getData($paymentRequest), $connectionData->getServiceTimeout(), $connectionData->getCharset()); $httpStatus = new HttpStatus($connection->getStatus()); switch ($httpStatus->getType()) { case 'OK': $PaymentParserData = PaymentParser::readSuccessXml($connection->getResponse()); $paymentUrl = self::buildCheckoutUrl($connectionData, $PaymentParserData->getCode()); LogPagSeguro::info("PaymentService.Register(" . $paymentRequest->toString() . ") - end {1}" . $PaymentParserData->getCode()); break; case 'BAD_REQUEST': $errors = PaymentParser::readErrors($connection->getResponse()); $e = new PagSeguroServiceException($httpStatus, $errors); LogPagSeguro::error("PaymentService.Register(" . $paymentRequest->toString() . ") - error " . $e->getOneLineMessage()); throw $e; break; default: $e = new PagSeguroServiceException($httpStatus); LogPagSeguro::error("PaymentService.Register(" . $paymentRequest->toString() . ") - error " . $e->getOneLineMessage()); throw $e; break; } return isset($paymentUrl) ? $paymentUrl : false; } catch (PagSeguroServiceException $e) { throw $e; } catch (Exception $e) { LogPagSeguro::error("Exception: " . $e->getMessage()); throw $e; } }
/** * @param \AdamStipak\Webpay\PaymentRequest $request * @return array */ public function createPaymentParam(PaymentRequest $request) { // digest request $request->setMerchantNumber($this->merchantNumber); $params = $request->getParams(); $request->setDigest($this->signer->sign($params)); return $request->getParams(); }
public function pay() { $this->layout = "default"; if ($this->Auth->user()) { $user = $this->Auth->user(); $PaymentRequest = new PaymentRequest(); if ($this->request->is("post")) { $data = $this->request->data; $this->Session->write("courses", $data['course_id']); $data['regno'] = $user['Student']['reg_no']; $result = $PaymentRequest->sendRequest($data); $this->set("json", json_encode($result)); } } else { $this->set("json", json_encode("login")); } }
function testValidatesThrowsExeption() { $data = array('type' => 'MobilePayment', 'amount' => -2000, 'currency' => 'WRONG', 'transaction_id' => 'test-1234', 'usage' => 'the Usage Text', 'notification_url' => 'https://my-server.com/hypercharge/payment-notification.php'); $request = new PaymentRequest($data); try { $request->validate(); $this->fail('Exception expected!'); } catch (Errors\ValidationError $exe) { $this->assertEqual($exe->status_code, 50); $this->assertPattern('/^2 validation errors/', $exe->getMessage()); $this->assertEqual('2 affected properties: payment.amount, payment.currency', $exe->technical_message); $this->assertEqual('payment.amount', $exe->errors[0]['property']); $this->assertEqual('must have a minimum value of 1', $exe->errors[0]['message']); $this->assertEqual('payment.currency', $exe->errors[1]['property']); $this->assertPattern('/^does not have a value in the enumeration Array/', $exe->errors[1]['message']); return; } $this->fail('Errors\\ValidationError expected!'); }
function PagSeguroOneOffPay($orderInfo, $params = array()) { require_once OSEMSC_B_LIB . DS . 'PagSeguroLibrary' . DS . 'PagSeguroLibrary.php'; $pConfig = oseMscConfig::getConfig('payment', 'obj'); $account = $pConfig->pagseguro_account; $token = $pConfig->pagseguro_token; $paymentRequest = new PaymentRequest(); $payment = oseRegistry::call('payment'); $paymentOrder = $payment->getInstance('Order'); $billinginfo = $paymentOrder->getBillingInfo($orderInfo->user_id); $address = $billinginfo->addr1 . ' ' . $billinginfo->addr2; $orderInfoParams = oseJson::decode($orderInfo->params); $redirectUrl = urldecode(JROUTE::_(JURI::base() . "index.php?option=com_osemsc&view=thankyou&order_id=" . $orderInfo->order_id)); $redirectUrl = $redirectUrl ? $redirectUrl : JURI::root() . "index.php?option=com_osemsc&view=member"; $des = $this->generateDesc($orderInfo->order_id); // Sets the currency $paymentRequest->setCurrency($orderInfo->payment_currency); // Add an item for this payment request $paymentRequest->addItem($orderInfo->order_id, $des, 1, $orderInfo->payment_price); // Sets a reference code for this payment request, it is useful to identify this payment in future notifications. $paymentRequest->setReference($orderInfo->order_number); // Sets shipping information for this payment request $CODIGO_SEDEX = ShippingType::getCodeByType('SEDEX'); $paymentRequest->setShippingType($CODIGO_SEDEX); $paymentRequest->setShippingAddress('', $address, $billinginfo->telephone, null, null, $billinginfo->city, $billinginfo->state, $billinginfo->country); // Sets your customer information. $paymentRequest->setSender($billinginfo->firstname . ' ' . $billinginfo->lastname, $billinginfo->email, null, null); $redirectUrl = str_replace('https://', '', $redirectUrl); $redirectUrl = str_replace('http://', '', $redirectUrl); $paymentRequest->setRedirectUrl($redirectUrl); $result = array(); $result['payment_method'] = 'pagseguro'; try { $credentials = new AccountCredentials($account, $token); $url = $paymentRequest->register($credentials); $result['success'] = true; $result['url'] = $url; } catch (PagSeguroServiceException $e) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = $e->getMessage(); //$result['url'] = ''; } return $result; }
public function save($id) { $this->layout = "ahaguru"; if ($this->request->is("post")) { $data = $this->request->data; $user = $this->Student->findById($id); unset($data['email']); if (!$data['cancel']) { $this->Student->save($data); } $paymentinfo = $this->Session->read('paymentdata'); $paymentinfo['regno'] = $user['Student']['reg_no']; $this->layout = "default"; $PaymentRequest = new PaymentRequest(); $this->Session->write("purchasemode", "online login"); $results = $PaymentRequest->sendRequest($paymentinfo); $message = array("result" => "encrypt", "msg" => $results); // $this->redirect("/payment/response"); echo json_encode($message); } }
<?php require_once '../ebusclient/PaymentRequest.php'; $tRequest = new PaymentRequest(); echo $_POST['CommodityType']; echo $_POST['PayTypeID']; $tRequest->order["PayTypeID"] = $_POST['PayTypeID']; //设定交易类型 $tRequest->order["OrderNo"] = $_POST['OrderNo']; //设定订单编号 $tRequest->order["ExpiredDate"] = $_POST['ExpiredDate']; //设定订单保存时间 $tRequest->order["OrderAmount"] = $_POST['PaymentRequestAmount']; //设定交易金额 $tRequest->order["Fee"] = $_POST['Fee']; //设定手续费金额 $tRequest->order["CurrencyCode"] = $_POST['CurrencyCode']; //设定交易币种 $tRequest->order["ReceiverAddress"] = $_POST['ReceiverAddress']; //收货地址 $tRequest->order["InstallmentMark"] = $_POST['InstallmentMark']; //分期标识 $installmentMerk = $_POST['InstallmentMark']; $paytypeID = $_POST['PayTypeID']; if (strcmp($installmentMerk, "1") == 0 && strcmp($paytypeID, "DividedPay") == 0) { $tRequest->order["InstallmentCode"] = $_POST['InstallmentCode']; //设定分期代码 $tRequest->order["InstallmentNum"] = $_POST['InstallmentNum']; //设定分期期数 } $tRequest->order["BuyIP"] = $_POST['BuyIP']; //IP
function submit() { global $wpdb, $wpsc_cart, $wpsc_gateways; #echo '<pre>'; print_r($this->cart_data); echo '</pre>'; die('fim'); // Instantiate a new payment request $paymentRequest = new PaymentRequest(); // Sets the currency $paymentRequest->setCurrency("BRL"); $pagseguro_freight = $wpsc_cart->selected_shipping_method == $wpsc_gateways['wpsc_merchant_pagseguro']['name']; $freight = 0; if ($pagseguro_freight) { $freight = sprintf('%01.2f', $this->cart_data['cart_tax'] + $this->cart_data['base_shipping']); } foreach ($wpsc_cart->cart_items as $item) { $paymentRequest->addItem($item->product_id, $item->product_name, $item->quantity, $item->unit_price, intval(round($item->weight * 453.59237)), $freight); } // Sets a reference code for this payment request, it's useful to identify this payment in future notifications. $paymentRequest->setReference($this->cart_data['session_id']); $collected_data = array(); $checkout_form_sql = "SELECT id, unique_name FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "`"; $checkout_form = $wpdb->get_results($checkout_form_sql, ARRAY_A); // Pega a referência dos campos de formulário definido pelo usuário foreach ($checkout_form as $item) { $collected_data[$item['unique_name']] = $item['id']; } // Pega os dados do post $_client = $_POST["collected_data"]; list($prefix, $phone) = splitPhone($_client[if_isset($collected_data['billingphone'])]); $street = explode(',', $_client[if_isset($collected_data['billingaddress'])]); $street = array_slice(array_merge($street, array("", "", "", "")), 0, 4); list($address, $number, $complement, $neighborhood) = $street; // Sets your customer information. $paymentRequest->setSender($_client[if_isset($collected_data['billingfirstname'])] . ' ' . $_client[if_isset($collected_data['billinglastname'])], $_client[if_isset($collected_data['billingemail'])], $prefix, $phone); # $shipping = get_option('pagseguro_shipping_configs'); // Get the freight data if ($pagseguro_freight) { $freight_type = strtoupper($wpsc_cart->selected_shipping_option); $FREIGHT_CODE = 0; if ($freight_type == 'PAC') { $FREIGHT_CODE = ShippingType::getCodeByType('PAC'); } elseif ($freight_type == 'SEDEX') { $FREIGHT_CODE = ShippingType::getCodeByType('SEDEX'); } if ($FREIGHT_CODE > 0) { $paymentRequest->setShippingType($FREIGHT_CODE); $paymentRequest->setShippingAddress($_client[if_isset($collected_data['shippingpostcode'])], $address, $number, $complement, $neighborhood, $_client[if_isset(utf8_decode($collected_data['shippingcity']))], $_client[if_isset(utf8_decode($collected_data['shippingstate']))], $wpsc_gateways['wpsc_merchant_pagseguro']['supported_iso_codes'][$_client[if_isset($collected_data['shippingcountry'])]]); } } $extra = 0; if ($this->cart_data['has_discounts']) { $extra = $this->cart_data['cart_discount_value'] * -1; } $paymentRequest->setExtraAmount($extra); #$paymentRequest->setRedirectUrl($this->cart_data['transaction_results_url']); $paymentRequest->setRedirectUrl('http://homologacao.visie.com.br/bibliotecas/pagseguro/opencart1505/notification.php'); // Pegando as configurações definidas no admin do módulo $email = get_option('pagseguro_email'); $token = get_option("pagseguro_token"); /** * Você pode utilizar o método getData para capturar as credenciais * do usuário (email e token) * $email = PagSeguroConfig::getData('credentials', 'email'); * $token = PagSeguroConfig::getData('credentials', 'token'); */ try { /** * #### Crendenciais ##### * Se desejar, utilize as credenciais pré-definidas no arquivo de configurações * $credentials = PagSeguroConfig::getAccountCredentials(); */ $credentials = new AccountCredentials($email, $token); if ($geteway_url = $paymentRequest->register($credentials)) { $_SESSION["pagseguro_id"] = $sessionid; $wpsc_cart->empty_cart(); wp_redirect($geteway_url); exit; } } catch (PagSeguroServiceException $e) { die($e->getMessage()); } }
/** * */ public function prepareRequest(PaymentRequest $paymentRequest) { // Make sure we have a valid PaymentRequest if ($paymentRequest->validate()) { // Prepare the data so we can create a seal $data = ['amount' => $paymentRequest->amount, 'automaticResponseUrl' => $paymentRequest->automaticResponseUrl, 'captureDay' => $paymentRequest->captureDay, 'captureMode' => $paymentRequest->captureMode, 'currencyCode' => empty($paymentRequest->currencyCode) ? $this->currencyCode : $paymentRequest->currencyCode, 'customerLanguage' => empty($paymentRequest->customerLanguage) ? $this->customerLanguage : $paymentRequest->customerLanguage, 'expirationDate' => $paymentRequest->expirationDate, 'keyVersion' => $this->keyVersion, 'merchantId' => $this->merchantId, 'normalReturnUrl' => $paymentRequest->normalReturnUrl, 'orderId' => $paymentRequest->orderId, 'paymentMeanBrandList' => empty($paymentRequest->paymentMeanBrandList) ? $this->paymentMeanBrandList : $paymentRequest->paymentMeanBrandList, 'transactionReference' => $paymentRequest->transactionReference]; $this->dataField = []; foreach ($data as $key => $value) { if (!empty($value)) { $this->dataField[] = "{$key}={$value}"; } } $this->dataField = implode('|', $this->dataField); $this->seal = hash('sha256', $this->dataField . $this->secretKey); } else { throw new \yii\base\InvalidConfigException('Invalid config for PaymentRequest object, check requirements'); } }
private function generatePaymentXML(PaymentRequest $request) { $xml = null; if ($request->getReceivingMapped() == null) { $xml = "<PaymentRequest>"; $xml .= "<LocalDate>" . $request->getLocalDate() . "</LocalDate>"; $xml .= "<LocalTime>" . $request->getLocalTime() . "</LocalTime>"; $xml .= "<TransactionReference>" . $request->getTransactionReference() . "</TransactionReference>"; $xml .= "<SenderName>" . $request->getSenderName() . "</SenderName>"; $xml .= "<SenderAddress>"; $xml .= "<Line1>" . $request->getSenderAddress()->getLine1() . "</Line1>"; $xml .= "<Line2>" . $request->getSenderAddress()->getLine2() . "</Line2>"; $xml .= "<City>" . $request->getSenderAddress()->getCity() . "</City>"; $xml .= "<CountrySubdivision>" . $request->getSenderAddress()->getCountrySubdivision() . "</CountrySubdivision>"; $xml .= "<PostalCode>" . $request->getSenderAddress()->getPostalCode() . "</PostalCode>"; $xml .= "<Country>" . $request->getSenderAddress()->getCountry() . "</Country>"; $xml .= "</SenderAddress>"; $xml .= "<ReceivingCard>"; $xml .= "<AccountNumber>" . $request->getReceivingCard()->getAccountNumber() . "</AccountNumber>"; $xml .= "</ReceivingCard>"; $xml .= "<ReceivingAmount>"; $xml .= "<Value>" . $request->getReceivingAmount()->getValue() . "</Value>"; $xml .= "<Currency>" . $request->getReceivingAmount()->getCurrency() . "</Currency>"; $xml .= "</ReceivingAmount>"; $xml .= "<ICA>" . $request->getICA() . "</ICA>"; $xml .= "<ProcessorId>" . $request->getProcessorId() . "</ProcessorId>"; $xml .= "<RoutingAndTransitNumber>" . $request->getRoutingAndTransitNumber() . "</RoutingAndTransitNumber>"; $xml .= "<CardAcceptor>"; $xml .= "<Name>" . $request->getCardAcceptor()->getName() . "</Name>"; $xml .= "<City>" . $request->getCardAcceptor()->getCity() . "</City>"; $xml .= "<State>" . $request->getCardAcceptor()->getState() . "</State>"; $xml .= "<PostalCode>" . $request->getCardAcceptor()->getPostalCode() . "</PostalCode>"; $xml .= "<Country>" . $request->getCardAcceptor()->getCountry() . "</Country>"; $xml .= "</CardAcceptor>"; $xml .= "<TransactionDesc>" . $request->getTransactionDesc() . "</TransactionDesc>"; $xml .= "<MerchantId>" . $request->getMerchantId() . "</MerchantId>"; $xml .= "</PaymentRequest>"; } else { $xml = "<PaymentRequest>"; $xml .= "<LocalDate>" . $request->getLocalDate() . "</LocalDate>"; $xml .= "<LocalTime>" . $request->getLocalTime() . "</LocalTime>"; $xml .= "<TransactionReference>" . $request->getTransactionReference() . "</TransactionReference>"; $xml .= "<SenderName>" . $request->getSenderName() . "</SenderName>"; $xml .= "<SenderAddress>"; $xml .= "<Line1>" . $request->getSenderAddress()->getLine1() . "</Line1>"; $xml .= "<Line2>" . $request->getSenderAddress()->getLine2() . "</Line2>"; $xml .= "<City>" . $request->getSenderAddress()->getCity() . "</City>"; $xml .= "<CountrySubdivision>" . $request->getSenderAddress()->getCountrySubdivision() . "</CountrySubdivision>"; $xml .= "<PostalCode>" . $request->getSenderAddress()->getPostalCode() . "</PostalCode>"; $xml .= "<Country>" . $request->getSenderAddress()->getCountry() . "</Country>"; $xml .= "</SenderAddress>"; $xml .= "<ReceivingMapped>"; $xml .= "<SubscriberId>" . $request->getReceivingMapped()->getSubscriberId() . "</SubscriberId>"; $xml .= "<SubscriberType>" . $request->getReceivingMapped()->getSubscriberType() . "</SubscriberType>"; $xml .= "<SubscriberAlias>" . $request->getReceivingMapped()->getSubscriberAlias() . "</SubscriberAlias>"; $xml .= "</ReceivingMapped>"; $xml .= "<ReceivingAmount>"; $xml .= "<Value>" . $request->getReceivingAmount()->getValue() . "</Value>"; $xml .= "<Currency>" . $request->getReceivingAmount()->getCurrency() . "</Currency>"; $xml .= "</ReceivingAmount>"; $xml .= "<ICA>" . $request->getICA() . "</ICA>"; $xml .= "<ProcessorId>" . $request->getProcessorId() . "</ProcessorId>"; $xml .= "<RoutingAndTransitNumber>" . $request->getRoutingAndTransitNumber() . "</RoutingAndTransitNumber>"; $xml .= "<CardAcceptor>"; $xml .= "<Name>" . $request->getCardAcceptor()->getName() . "</Name>"; $xml .= "<City>" . $request->getCardAcceptor()->getCity() . "</City>"; $xml .= "<State>" . $request->getCardAcceptor()->getState() . "</State>"; $xml .= "<PostalCode>" . $request->getCardAcceptor()->getPostalCode() . "</PostalCode>"; $xml .= "<Country>" . $request->getCardAcceptor()->getCountry() . "</Country>"; $xml .= "</CardAcceptor>"; $xml .= "<TransactionDesc>" . $request->getTransactionDesc() . "</TransactionDesc>"; $xml .= "<MerchantId>" . $request->getMerchantId() . "</MerchantId>"; $xml .= "</PaymentRequest>"; } return $xml; }
public function hloginsuccess($id) { if ($this->request->is("post")) { $data = $this->request->data; error_log("aa" . print_r($data, true)); $this->layout = "default"; $level = $data['Student']['level']; $user = $this->Student->findByUserId($data['Student']['user_id']); unset($data['Student']['email']); $this->Student->save($data); if ($level == 1) { $course_id[0] = 42; $course_id[1] = 41; $courses = implode(',', $course_id); foreach ($course_id as $key => $value) { $cour = $this->Course->findById($value); if ($cour['Course']['discount'] == 0) { $fees += $cour['Course']['fee']; } else { $fees += $cour['Course']['discount']; } } $fees = $this->Session->read("studentfees"); $ch1 = $this->StudentCourseMap->find("first", array('conditions' => array('StudentCourseMap.student_id' => $user['Student']['id'], 'StudentCourseMap.challenge_type' => "PC1", 'StudentCourseMap.deleted' => 0))); $sesscoupon = $this->Session->read('coupon_code'); if (stripos($sesscoupon, "APC2S") === FALSE) { $sesscoupon = substr($sesscoupon, 0, 4); } else { if (stripos($sesscoupon, "APC2S") !== FALSE) { $sesscoupon = substr($sesscoupon, 0, 5); } } if (strcasecmp($sesscoupon, "APC2") == 0) { $fees = 799; } else { if (strcasecmp($sesscoupon, "APC2S") == 0) { $fees = 899; } else { if (!empty($ch1)) { $fees = 899; } } } $paymentdata['fee'] = $fees; $paymentdata['courses'] = $courses; $paymentdata['regno'] = $user['Student']['reg_no']; error_log("feeslogin" . print_r($paymentdata, true)); $this->Session->write($paymentdata); $this->Session->write("courses", $course_id); } else { if ($level == 2) { $course_id[0] = 39; $course_id[1] = 40; $courses = implode(',', $course_id); foreach ($course_id as $key => $value) { $cour = $this->Course->findById($value); if ($cour['Course']['discount'] == 0) { $fees += $cour['Course']['fee']; } else { $fees += $cour['Course']['discount']; } } $fees = $this->Session->read("studentfees"); $ch1 = $this->StudentCourseMap->find("first", array('conditions' => array('StudentCourseMap.student_id' => $user['Student']['id'], 'StudentCourseMap.challenge_type' => "PC1", 'StudentCourseMap.deleted' => 0))); $sesscoupon = $this->Session->read('coupon_code'); if (stripos($sesscoupon, "APC2S") === FALSE) { $sesscoupon = substr($sesscoupon, 0, 4); } else { if (stripos($sesscoupon, "APC2S") !== FALSE) { $sesscoupon = substr($sesscoupon, 0, 5); } } if (strcasecmp($sesscoupon, "APC2") == 0) { $fees = 799; } else { if (strcasecmp($sesscoupon, "APC2S") == 0) { $fees = 899; } else { if (!empty($ch1)) { $fees = 899; } } } $paymentdata['fee'] = $fees; $paymentdata['courses'] = $courses; $paymentdata['regno'] = $user['Student']['reg_no']; $this->Session->write($paymentdata); $this->Session->write("courses", $course_id); } } $this->Session->write("purchasemode", "hindu login purchase"); $this->Session->write('course_mapped_type', 2); $PaymentRequest = new PaymentRequest(); $results = $PaymentRequest->sendRequest($paymentdata); $message = array("result" => "encrypt", "msg" => $results, "student_id" => $user['Student']['id']); $this->set("json", json_encode($message)); // if($data['Student']['level'] == 1){ // $course_id[0] = 2; // $course_id[1] = 14; // } // else if($data['Student']['level'] == 2){ // $course_id[0] = 5; // $course_id[1] = 35; // } // foreach ($course_id as $value) { // $mapdata['course_id'] = $value; // $mapdata['student_id'] = $data['Student']['id']; // $mapdata['payment'] = 2; // $mapdata['status'] = 1; // $mapdata['course_mapped_type'] = 2; // $mapdata['deleted'] = 0; // $mapdata['comments'] = "Hindu Existing Student login"; // $con = array( // 'StudentCourseMap.course_id' => $value, // 'StudentCourseMap.student_id' => $data['Student']['id'], // 'StudentCourseMap.deleted' => 0 // ); // $mapping = $this->StudentCourseMap->find("first",array('conditions' => $con )); // if(empty($mapping)){ // $this->StudentCourseMap->saveAll($mapdata); // } // else{ // $mapdata['id'] = $mapping['StudentCourseMap']['id']; // $comments = $mapping['StudentCourseMap']['comments']; // if(strpos($comments,$mapdata['comments']) === FALSE){ // $comments .= ",".$mapdata['comments']; // $mapdata['comments'] = $comments; // $this->StudentCourseMap->saveAll($mapdata); // } // else{ // unset($mapdata['comments']); // $this->StudentCourseMap->saveAll($mapdata); // } // } // } // // $this->Session->write("purchasemode","hindu login"); // $this->redirect("/student/course/1"); } }
/** * Return all records including those that have been soft deleted * * * @return PaymentRequest */ public function all() { return PaymentRequest::withTrashed(); }
/** * Tests the population of a billing address for the Address Verification Service. */ public function testAddAddressVerificationServiceDetailsWithTssInfo() { $addressLine = "123 Fake St"; $postcode = "WB1 A42"; $country = ""; $expectedBillingCode = "142|123"; $request = new PaymentRequest(); $request->addTssInfo(new TssInfo())->addAddressVerificationServiceDetails($addressLine, $postcode, $country); $addresses = $request->getTssInfo()->getAddresses(); $this->assertEquals($expectedBillingCode, $addresses[0]->getCode()); $this->assertEquals(AddressType::BILLING, $addresses[0]->getType()); $this->assertEquals($country, $addresses[0]->getCountry()); }
/** * This method is used to render the payment button, * Take care if the button should be displayed or not. */ public function hookPayment($params) { include_once _PS_MODULE_DIR_ . 'alipay/api/loader.php'; $currency_id = $params['cart']->id_currency; $currency = new Currency((int) $currency_id); $cart = new Cart($params['cart']->id); if (!ValidateCore::isLoadedObject($cart)) { return false; } if (in_array($currency->iso_code, $this->limited_currencies) == false) { return false; } $service = Configuration::get('ALIPAY_SERVICE_PAYMENT'); $credentials = AlipayTools::getCredentials($service, false); $alipayapi = new AlipayApi($credentials); $alipayapi->setReturnUrl($this->getReturnUrl($cart->secure_key, $cart->id)); $alipayapi->setNotifyUrl($this->getNotifyUrl($cart->secure_key, $cart->id)); $alipayapi->setCharset('UTF-8'); date_default_timezone_set('Asia/Hong_Kong'); $payment_request = new PaymentRequest(); $payment_request->setCurrency($currency->iso_code); $payment_request->setPartnerTransactionId(date('YmdHis') . $cart->id); $payment_request->setGoodsDescription($this->getGoodsDescription()); $payment_request->setGoodsName($this->getGoodsName($cart->id)); $payment_request->setOrderGmtCreate(date('Y-m-d H:i:s')); $payment_request->setOrderValidTime(21600); $payment_request->setTotalFee($cart->getOrderTotal()); $alipayapi->prepareRequest($payment_request); $url = $alipayapi->createUrl(); $this->smarty->assign(array('module_dir' => $this->_path, 'alipay_payment_url' => $url)); return $this->display(__FILE__, 'views/templates/hook/payment.tpl'); }
function testAllowedTypesShouldAllHaveSchema() { $missingSchemas = array(); foreach (PaymentRequest::getAllowedTypes() as $type) { $file = JsonSchemaValidator::schemaPathFor($type); if (!file_exists($file)) { $missingSchemas[] = $type; } } $this->assertEqual(0, sizeof($missingSchemas), "missing schemas for Payment types: " . join($missingSchemas, ', ')); }