Create a card object using the payment form and the optional order

@param BasePaymentForm $paymentForm
@param Order           $order

@return CreditCard
519326
public function createCard(BasePaymentForm $paymentForm, Order $order = null): CreditCard {

        $card = new CreditCard;

        if ($paymentForm instanceof CreditCardPaymentForm) {
            $this->populateCard($card, $paymentForm);
        }

        if ($order) {
            if ($billingAddress = $order->getBillingAddress()) {
                // Set top level names to the billing names
                $card->setFirstName($billingAddress->firstName);
                $card->setLastName($billingAddress->lastName);

                $card->setBillingFirstName($billingAddress->firstName);
                $card->setBillingLastName($billingAddress->lastName);
                $card->setBillingAddress1($billingAddress->address1);
                $card->setBillingAddress2($billingAddress->address2);
                $card->setBillingCity($billingAddress->city);
                $card->setBillingPostcode($billingAddress->zipCode);
                if ($billingAddress->getCountry()) {
                    $card->setBillingCountry($billingAddress->getCountry()->iso);
                }
                if ($billingAddress->getState()) {
                    $state = $billingAddress->getState()->abbreviation ?: $billingAddress->getState()->name;
                    $card->setBillingState($state);
                }
                $card->setBillingPhone($billingAddress->phone);
                $card->setBillingCompany($billingAddress->businessName);
                $card->setCompany($billingAddress->businessName);
            }

            if ($shippingAddress = $order->getShippingAddress()) {
                $card->setShippingFirstName($shippingAddress->firstName);
                $card->setShippingLastName($shippingAddress->lastName);
                $card->setShippingAddress1($shippingAddress->address1);
                $card->setShippingAddress2($shippingAddress->address2);
                $card->setShippingCity($shippingAddress->city);
                $card->setShippingPostcode($shippingAddress->zipCode);

                if ($shippingAddress->getCountry()) {
                    $card->setShippingCountry($shippingAddress->getCountry()->iso);
                }

                if ($shippingAddress->getState()) {
                    $state = $shippingAddress->getState()->abbreviation ?: $shippingAddress->getState()->name;
                    $card->setShippingState($state);
                }

                $card->setShippingPhone($shippingAddress->phone);
                $card->setShippingCompany($shippingAddress->businessName);
            }

            $card->setEmail($order->getEmail());
        }

        return $card;
    }
1100470
public function createRefundPaymentRequest($orderUuid, $amount = null)
    {
        $amountData = is_null($amount) ? [] : [
            'amount' => $amount,
        ];

        return $this->createRequest('POST', '/payment/refund', [
                'order_uuid' => $orderUuid,
            ] + $amountData);
    }
993277
public function directPayment($ip, $orderUuid, $cardUuid)
    {
        $request = $this
            ->apiRequestFactory
            ->createDirectPaymentRequest($ip, $orderUuid, $cardUuid);

        return $this->send($request);
    }
323515
protected function savePayment(PayonePaymentTransfer $paymentTransfer)
    {
        $payment = new SpyPaymentPayone();
        $payment->fromArray(($paymentTransfer->toArray()));

        if ($payment->getReference() === null) {
            $orderEntity = $payment->getSpySalesOrder();
            $payment->setReference($this->config->generatePayoneReference($paymentTransfer, $orderEntity));
        }

        $payment->save();

        return $payment;
    }
1107225
public function Create($payOut, $idempotencyKey = null)
    {
        $paymentKey = $this->GetPaymentKey($payOut);
        return $this->CreateObject('payouts_' . $paymentKey . '_create', $payOut, '\MangoPay\PayOut', null, null, $idempotencyKey);
    }
546816
public function refundPayment($orderUuid, $amount = null)
    {
        $request = $this
            ->apiRequestFactory
            ->createRefundPaymentRequest($orderUuid, $amount);

        return $this->send($request);
    }
1371487
public static function create($order)
    {
        $data = OpenPayU_Util::buildJsonFromArray($order);

        if (empty($data)) {
            throw new OpenPayU_Exception('Empty message OrderCreateRequest');
        }

        try {
            $authType = self::getAuth();
        } catch (OpenPayU_Exception $e) {
            throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
        }

        $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE;

        $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse');

        return $result;
    }
478936
protected function doPay(Order $order)
    {
        if ('TEST' == Paybox::getConfigValue('mode', false)) {
            $platformUrl = Paybox::getConfigValue('url_serveur_test', false);
        } else {
            $platformUrl = Paybox::getConfigValue('url_serveur', false);
        }

        // Be sure to have a valid platform URL, otherwise give up
        if (false === $platformUrl) {
            throw new \InvalidArgumentException(
                Translator::getInstance()->trans(
                    "The platform URL is not defined, please check Paybox module configuration.",
                    [],
                    Paybox::MODULE_DOMAIN
                )
            );
        }

        $hashAlgo = $this->getHashAlgorithm();
        $clefPrivee = Paybox::getConfigValue('clef_privee');

        $paybox_params = $this->doPayPayboxParameters($order)
            + [
                'PBX_HASH' => $hashAlgo,
                'PBX_SECRET' => $clefPrivee
            ];

        // Generate signature
        $param = '';

        foreach ($paybox_params as $key => $value) {
            $param .= "&" . $key . '=' . $value;
        }

        $param = ltrim($param, '&');

        $binkey = pack('H*', $clefPrivee);

        $paybox_params['PBX_HMAC'] = strtoupper(hash_hmac($hashAlgo, $param, $binkey));

        return $this->generateGatewayFormResponse($order, $platformUrl, $paybox_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);
    }
474512
protected function checkPaymentTransactionStatus(PaymentTransaction $paymentTransaction)
    {
        if (!$paymentTransaction->isFinished())
        {
            throw new ValidationException('Only finished payment transaction can be used for create-card-ref-id');
        }

        if (!$paymentTransaction->getPayment()->isPaid())
        {
            throw new ValidationException("Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first");
        }
    }
250685
public function createPaymentById($orderId)
    {
        $query = $this->getFactory()->createPaymentPayoneQuery();
        $query->findByFkSalesOrder($orderId);

        return $query;
    }
3059
public function makePayment(array $data, SummaryForm $form)
    {
        // If the summary is changed and email receivers are set
        if (isset($data['Summary']) && is_array($data['Summary'])) {
            foreach ($data['Summary'] as $attendeeID => $fields) {
                $attendee = $form->reservation->Attendees()->find('ID', $attendeeID);
                foreach ($fields as $field => $value) {
                    $attendee->setField($field, $value);
                }
                $attendee->write();
            }
        }

        $form->saveInto($form->reservation);
        // If comments are added
        //if (isset($data['Comments'])) {
        //    $form->reservation->Comments = $data['Comments'];
        //}

        // Hook trough where optional extra field data can be saved on the reservation
        $this->extend('updateReservationBeforePayment', $form->reservation, $data, $form);

        // Check if there is a payment to process otherwise continue with manual processing
        $gateway = $form->reservation->Total > 0
            ? $data['Gateway']
            : 'Manual';

        $form->reservation->changeState('PENDING');
        $form->reservation->Gateway = $gateway;
        $form->reservation->write();

        $paymentProcessor = PaymentProcessor::create($this->reservation);
        $paymentProcessor
            ->createPayment($gateway)
            ->setSuccessUrl($this->getController()->Link($this->nextStep))
            ->setFailureUrl($this->getController()->Link())
            ->write();

        $paymentProcessor->setGateWayData(array(
            'transactionId' => $this->reservation->ReservationCode
        ));

        $response = $paymentProcessor->createServiceFactory();
        $this->extend('beforeNextStep', $data, $form, $response);
        return $response->redirectOrRespond();
    }
928502
public function buildPayment()
    {
        $return = null;

        // Setter forms request payment from request parameters.
        $requestOrderPayment = $this->prepareRequestOrderPayment();

        // Create order payment from database to check if it match created from request.
        $orderPayment = $this->loadOrderPayment($requestOrderPayment->getTransactionId());

        // Only need validate if there is order in database.
        // If request payment do not have matching payment with order return null.
        if ($orderPayment->getOrderId()) {
            // Validator change request payment by adding information if it is valid.
            $orderPayment = $this->addPaymentValidationInformation($requestOrderPayment, $orderPayment);
            $orderPayment = $this->changePaymentStatusInfo($requestOrderPayment, $orderPayment);
            $orderPayment->save();
            $return = $orderPayment;
        } else {
            //IPN request might be for a transaction that does not yet exist in the shop database.
            $paymentCreator = $this->getPaymentCreator();
            $return = $paymentCreator->handleOrderPayment($requestOrderPayment);
        }

        return $return;
    }
1324163
public function payment(CieloPayment $cieloPayment, CieloOrder $cieloOrder, CieloCustomer $cieloCustomer = null)
    {
        $sale = new Sale($cieloOrder->getId());

        $payment = $sale->payment($cieloPayment->getValue(), $cieloPayment->getInstallments());

        $creditCard = $cieloPayment->getCreditCard();

        $payment->setType(Payment::PAYMENTTYPE_CREDITCARD);
        $paymentCard = $payment->creditCard($creditCard->getSecurityCode(), $creditCard->getBrand());

        if ($creditCard->getToken()) {
            $paymentCard->setCardToken($creditCard->getToken());
        } else {
            $paymentCard->setExpirationDate($creditCard->getExpirationDate())
                        ->setCardNumber($creditCard->getCardNumber())
                        ->setHolder($creditCard->getHolder());
        }

        if ($cieloCustomer) {
            $customer = $sale->customer($cieloCustomer->getName());
        }

        try {
            $sale = (new CieloEcommerce($this->merchant, $this->environment))->createSale($sale);

            $paymentData = $sale->getPayment()->jsonSerialize();
            $paymentStatus = $sale->getPayment()->getStatus();
            $paymentMessage = $sale->getPayment()->getReturnMessage();
        } catch (CieloRequestException $e) {
            $error = $e->getCieloError();
            throw new ResourceErrorException($error->getMessage(), $error->getCode());
        }

        return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData);
    }
1372091
public function createPayment($data, $filters = [])
    {
        return $this->client->orderPayments->createFor($this, $data, $filters);
    }
432235
public function createFor(Order $order, array $data, array $filters = [])
    {
        return $this->createForId($order->id, $data, $filters);
    }
1249372
private function addPayment($order, $payment)
    {
        if ($this->compareStore($payment) && $this->hasOrder($order) && $this->compareStatus($order, $payment)){
            array_push($this->_arrayPayments, $this->build($payment, $order));
            return true;
        }
        return false;
    }