當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Gateway::AddAccount方法代碼示例

本文整理匯總了PHP中Gateway::AddAccount方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gateway::AddAccount方法的具體用法?PHP Gateway::AddAccount怎麽用?PHP Gateway::AddAccount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Gateway的用法示例。


在下文中一共展示了Gateway::AddAccount方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ProcessPaymentForm

		public function ProcessPaymentForm($data = array())
		{
			$postData = $this->_Validate($data);

			if ($postData === false) {
				return false;
			}

			// Is setup in test or live mode?
			$this->_testmode = $this->GetValue("testmode") == "YES";

			// PaySimple accepts payments in cents

			$ccname 		= $postData['name'];
			$cctype 		= $postData['cctype'];

			$ccissueno 		= $postData['ccissueno'];
			$ccissuedatem 	= $postData['ccissuedatem'];
			$ccissuedatey 	= $postData['ccissuedatey'];

			$ccnum 			= $postData['ccno'];
			$ccexpm 		= $postData['ccexpm'];
			$ccexpy 		= $postData['ccexpy'];
			$cccvd 			= $postData['cccvd'];

			$billingDetails = $this->GetBillingDetails();

			$testmode = ($this->GetValue('testmode') == 'YES');
			$message = '';

			try{
				$gateway = new Gateway();
				$gateway->production = !$testmode;

				$dynamicKey = new DynamicKey($this, $gateway);

				//Create Customer
				$customer = new Customer();
				$BillingAddress = new Address();
				$BillingAddress->AddressLine1 	= $billingDetails['ordbillstreet1'] . ' ' . $billingDetails['ordbillstreet2'];
				$BillingAddress->City 			= $billingDetails['ordbillsuburb'];
				$BillingAddress->ZipCode 		= $billingDetails['ordbillzip'];
				$customer->BillingAddress 		= $BillingAddress;
				$customer->BillingCountryName 	= GetCountryISO3ById($billingDetails['ordbillcountryid']);
				$customer->ShippingAddress 		= $BillingAddress;

				$contact = new Contact();
				$contact->EMail 	= $billingDetails['ordbillemail'];
				$contact->Phone1	= $billingDetails['ordbillphone'];

				$name = new Name();
				$name->FirstName	= $billingDetails['ordbillfirstname'];
				$name->LastName		= $billingDetails['ordbilllastname'];
				$contact->Name		= $name;

				$customer->Contact = $contact;
				$customer = $gateway->AddCustomer($dynamicKey->key, $customer);

				if ($gateway->isError()) {
					$message = $gateway->getErrorMessage();
				}

				$account = new CustomerAccountDTO();
				$account->IsCreditCard 		= true;
				$account->CreditCardNo 		= $ccnum;
				$account->CCExpiry 			= "20".$ccexpy."-".$ccexpm."-01T00:00:00";
				$account->CCType 			= $cctype;
				$account->CustomerId 		= $customer;
				$account->CardName 			= $ccname;

				if (!$gateway->isError()) {
					$account = $gateway->AddAccount($dynamicKey->key, $account);
				}
				if ($gateway->isError()) {
					$message = $gateway->getErrorMessage();
				}

				if (isset($account->Id)) {

					$PSpayment = new Payment();
					if ($testmode) {
						$PSpayment->Amount = 120;
					}
					else {
						$PSpayment->Amount = $this->GetGatewayAmount();
					}
					$PSpayment->CustomerId = $customer;
					$PSpayment->FromAccountId = $account->Id;

					$PSpayment->PaymentTypeCode = "CC";
					$PSpayment->PaymentSubTypeCode = "MOTO";

					if (!$gateway->isError()) {
						$PSpayment = $gateway->MakePayment($dynamicKey->key, $PSpayment, null);
					}
					if ($gateway->isError()) {
						$message = $gateway->getErrorMessage();
					}
				}
				else {
//.........這裏部分代碼省略.........
開發者ID:hungnv0789,項目名稱:vhtm,代碼行數:101,代碼來源:module.paysimple.php


注:本文中的Gateway::AddAccount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。