Create new Transaction with a set of params.

@param array $transaction Set of params [source, amount, currency]

@return \ArrayAccess|array Result of transaction
763330
public function create(StripeTransaction $transaction)
    {
        try {
            Stripe::setApiKey($this->privateKey);

            $this->dispatcher->notifyCustomerPreCreate($transaction);

            $customer = Customer::create($transaction->getCustomerData());

            $transaction->setCustomerId($customer->id);

            $chargeData = Charge::create($transaction->getChargeData());
        } catch (Exception $e) {
            // The way to get to 'notifyPaymentOrderFail'
            return [
                'paid' => 0,
            ];
        }

        return $chargeData;
    }
220960
public function create(array $params = [])
    {
        if(!empty($params['currency'])) {
            $params['currency'] = strtoupper(trim($params['currency']));
        }

        $response = $this->merchantApi->call('post', 'transactions', [
            'form_params' => $params
        ]);
        // ensure that response contains necessary elements - identifier and sign of the newly created transaction
        if (empty($response['identifier']) || empty($response['sign'])) {
            throw new MonetivoException('Invalid ' . __FUNCTION__ . ' response: '.(string)$response, 0, $response->getHttpCode(), (string)$response);
        }

        return $response->toArray();

    }
1334055
public function createTransaction(array $params)
    {
        $this->sdk->ServiceURL = $this->getApiEndpoint('AioCheckOut');
        $this->sdk->Send['MerchantTradeDate'] = date('Y/m/d H:i:s');
        $this->sdk->Send['DeviceSource'] = $this->isMobile() ? ECPay_DeviceType::Mobile : ECPay_DeviceType::PC;
        $this->sdk->Send = array_replace(
            $this->sdk->Send,
            array_intersect_key($params, $this->sdk->Send)
        );

        /*
         * 電子發票參數
         * $sdk->Send['InvoiceMark'] = ECPay_InvoiceState::Yes;
         * $sdk->SendExtend['RelateNumber'] = $MerchantTradeNo;
         * $sdk->SendExtend['CustomerEmail'] = 'test@ecpay.com.tw';
         * $sdk->SendExtend['CustomerPhone'] = '0911222333';
         * $sdk->SendExtend['TaxType'] = TaxType::Dutiable;
         * $sdk->SendExtend['CustomerAddr'] = '台北市南港區三重路19-2號5樓D棟';
         * $sdk->SendExtend['InvoiceItems'] = array();
         * 將商品加入電子發票商品列表陣列
         * foreach ($sdk->Send['Items'] as $info) {
         *     array_push($sdk->SendExtend['InvoiceItems'],array('Name' => $info['Name'],'Count' =>
         *         $info['Quantity'],'Word' => '個','Price' => $info['Price'],'TaxType' => TaxType::Dutiable));
         * }
         * $sdk->SendExtend['InvoiceRemark'] = '測試發票備註';
         * $sdk->SendExtend['DelayDay'] = '0';
         * $sdk->SendExtend['InvType'] = InvType::General;
         */

        return $this->sdk->formToArray(
            $this->sdk->CheckOutString()
        );
    }
1211986
public function transaction(Transaction $transaction): void
	{
		if ($this->config->gaClientId) {
			$data = new ArrayHash;
			$data->transaction_id = $transaction->id;
			if ($transaction->affiliation !== null) {
				$data->affiliation = $transaction->affiliation;
			}
			if ($transaction->value !== null) {
				$data->value = $transaction->value;
			}
			if ($transaction->currency !== null) {
				$data->currency = $transaction->currency;
			}
			if ($transaction->tax !== null) {
				$data->tax = $transaction->tax;
			}
			if ($transaction->shipping !== null) {
				$data->shipping = $transaction->shipping;
			}
			$data->items = [];
			foreach ($transaction->items as $item) {
				$itemData = new ArrayHash;
				$itemData->id = $item->id;
				$itemData->name = $item->name;
				if ($item->category !== null) {
					$itemData->category = $item->category;
				}
				if ($item->quantity !== null) {
					$itemData->quantity = $item->quantity;
				}
				if ($item->price !== null) {
					$itemData->price = $item->price;
				}
				$data->items[] = $itemData;
			}

			$this->event('purchase',
				$this->config->gaClientId,
				$data);
		}
	}
173601
protected function applyTransaction(Array $transaction)
    {
        $changes = $transaction['changes'];
        $newCBDs = $transaction['newCBDs'];

        $subjectsOfChange = array();
        foreach($changes as $c)
        {
            if($c['rdf:type'][VALUE_URI]=="cs:ChangeSet")
            {
                array_push($subjectsOfChange, $c['cs:subjectOfChange']['u']);
            }
        }

        foreach($subjectsOfChange as $s)
        {
            foreach($newCBDs as $n)
            {
                if($n[_ID_KEY][_ID_RESOURCE]==$s)
                {
                    $this->updateCollection(array(_ID_KEY=>$n[_ID_KEY]), $n, array('upsert'=>true));
                    break;
                }
            }
        }
    }
744467
public static function create(array $payload): self
    {
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];
        $payment = PreCheckout::create($payload['pre_checkout']);

        return new static($senderId, $recipientId, $timestamp, $payment);
    }
90888
public function exportTransactions()
    {
        $data = [
            "from" => request()->from,
            "to" => request()->to,
            'settled' => request()->settled
        ];

        $this->setRequestOptions();
        return $this->setHttpResponse('/transaction/export', 'GET', $data)->getResponse();
    }
715972
protected function createRequest(Transaction $transaction, BasePaymentForm $form = null)
    {
        // For authorize and capture we're referring to a transaction that already took place so no card or item shenanigans.
        if (in_array($transaction->type, [TransactionRecord::TYPE_REFUND, TransactionRecord::TYPE_CAPTURE], false)) {
            $request = $this->createPaymentRequest($transaction);
        } else {
            $order = $transaction->getOrder();

            $card = null;

            if ($form) {
                $card = $this->createCard($form, $order);
            }

            $itemBag = $this->getItemBagForOrder($order);

            $request = $this->createPaymentRequest($transaction, $card, $itemBag);
            $this->populateRequest($request, $form);
        }

        return $request;
    }
225136
public function setTransactionsAttribute($transactions)
    {
        if (!is_array($transactions)) {
            throw new \InvalidArgumentException('Transactions must be an array');
        }

        foreach ($transactions as $key => $transaction) {
            if (!($transaction instanceof Transaction)) {
                $transactions[$key] = new Transaction($transaction);
            }
        }

        $this->attributes['Transactions'] = $transactions;

        return $this;
    }
635938
protected function payment(array $array)
    {
        $payment = new Payment();
        if ($array) {
            foreach ($array as $k => $v) {
                if (array_key_exists($k, $payment) && (strlen($v))) {
                    $payment->$k = $v;
                }
            }
        }
        return new \SoapVar($payment, SOAP_ENC_OBJECT, self::SOAP_PAYMENT, self::PAYLINE_NAMESPACE);
    }
421157
protected function buildParams(Transaction $transaction, array $options = array())
    {
        $credentials = $transaction->getCredentials();

        $params = array(
            'type' => $this->getNmiType($transaction),
            'username' => $credentials->getCredential('username'),
            'password' => $credentials->getCredential('password'),
        );

        if (in_array($transaction->getType()->getValue(), array(
            Transaction\TransactionType::REFUND))
        ) {
            $params = array_merge($params, array(
                'transactionid' => $transaction->getParent()->getResult()->getExternalId(),
            ));
        } else {
            $account = $transaction->getAccount();

            $names = explode(' ', $account->getName(), 2);
            $firstName = isset($names[0]) ? $names[0] : '';
            $lastName = isset($names[1]) ? $names[1] : '';

            $params = array_merge($params, array(
                'firstname' => $firstName,
                'lastname' => $lastName,
                'address' => $account->getAddress(),
                'city' => $account->getCity(),
                'state' => $account->getRegion(),
                'zip' => $account->getPostalCode(),
                'country' => $account->getCountry(),
                'ipaddress' => $account->getIpAddress(),
                'payment' => 'check',
                'sec_code' => $credentials->getCredential('secCode') ?: 'WEB',
                'account_holder_type' => in_array($account->getAccountType()->getValue(), array(
                    AccountType::PERSONAL_SAVINGS,
                    AccountType::PERSONAL_CHECKING
                )) ? 'personal' : 'business',
                'account_type' => in_array($transaction->getAccount()->getAccountType()->getValue(), array(
                    AccountType::PERSONAL_SAVINGS,
                    AccountType::BUSINESS_SAVINGS
                )) ? 'savings' : 'checking',
                'amount' => $transaction->getAmount(),
                'checkname' => $account->getName(),
                'checkaba' => $account->getRoutingNumber(),
                'checkaccount' => $account->getAccountNumber()
            ));
        }

        return $params;
    }
1179757
public function create($amount, $payment, $options = [])
    {
        $params = [];

        $params = $this->addPaymentMethod($params, $payment, $options);
        $params = $this->addOrder($params, $amount, $options);
        $params = $this->addCustomer($params, $options);

        return $this->gateway->commit('post', $this->gateway->buildUrlFromString('charges'), $params);
    }
771970
public function create($params = array())
    {
        $arr = array(
            "bank_name" => $params["bank_name"],
            "branch_name" => $params["branch_name"],
            "bank_account_type" => $params["bank_account_type"],
            "number" => $params["number"],
            "name" => $params["name"]
        );
        $rawResponse = $this->client->request('post', 'api/bank_accounts', $arr);
        return $rawResponse;
    }
534516
protected function doTransact(Transaction $transaction, array $options = array())
    {
        $this->validateTransaction($transaction);
        $params = $this->buildParams($transaction, $options);

        $result = $transaction->getResult();
        $result->setTransactor($this);

        $postUrl = $options['post_url'];
        $client = $this->getClient();

        $request = $client->post($postUrl)
            ->addPostFields($params);

        try {
            $response = $request->send();

            $data = Transaction\TransactionType::QUERY !== $transaction->getType()->getValue()
                ? json_decode($response->getBody(true))
                : $this->normalizeQueryResponse($response->getBody(true));
        } catch (BadResponseException $e) {
            $data = new \stdClass();
            $data->CommandStatus = 'Error';
            $data->Description = 'Client Error';
            $data->ErrorInformation = 'An error occurred while contacting the PaymentsXpress system';
            $data->Exception = $e->getMessage();
        }

        if ('Approved' !== $data->CommandStatus) {
            $result->setStatus(new Result\ResultStatus('Declined' !== $data->CommandStatus ? Result\ResultStatus::ERROR : Result\ResultStatus::DECLINED));
            $result->setMessage(!empty($data->ErrorInformation) ? $data->Description . ': ' . $data->ErrorInformation : $data->Description);

            if (!empty($data->TransAct_ReferenceID)) {
                $result->setExternalId($data->TransAct_ReferenceID);
            }
        } else {
            if (Transaction\TransactionType::QUERY === $transaction->getType()->getValue()) {
                $this->handleQueryResponse($transaction, $data);
            } else {
                $result->setStatus(new Result\ResultStatus(Result\ResultStatus::PENDING));
            }

            $result->setExternalId($data->TransAct_ReferenceID);
        }

        $result->setData('request', $params);
        $result->setData('response', $data);

        return $result;
    }
1246552
public function rollback( $transaction )
    {
        $status = $this->getStatus( $transaction);
        if( count($status) !== 1 ) {
            throw new \LogicException("You can't rollback more than 1 transaction");
        }

        list( $transaction, $transactionStatus ) = each( $status );

        // rollback things which were attempted
        foreach( $transactionStatus as $key => $taskStatus ) {
            if( $taskStatus === self::SUCCESS ) {
                $this->status[$transaction][$key] = self::ROLLEDBACK;
            }
        }

    }
1153187
public function addTransaction(Transaction $transaction)
    {
        $transaction->setAdvert($this);
        $this->transactions->add($transaction);

        return $this;
    }
1331526
public function handleType(int $assetOffset, Transaction $transaction): Transaction
    {
        $deserializer = $this->deserializers[$transaction->type];

        return (new $deserializer($this->buffer, $assetOffset, $transaction))->deserialize();
    }