当前位置: 首页>>代码示例>>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;未经允许,请勿转载。