Creates a charge with Default Customer Card.
@param RequestModels\BaseCharge $requestModel
@return ResponseModels\Charge
488478
public function chargeWithDefaultCustomerCard(RequestModels\BaseCharge
	                                              $requestModel)
	{

		$chargeMapper = new ChargesMapper($requestModel);

		$requestPayload = array (
			'authorization' => $this->_apiSetting->getSecretKey(),
			'mode'          => $this->_apiSetting->getMode(),
			'postedParam'   => $chargeMapper->requestPayloadConverter(),

		);
		$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getDefaultCardChargesApiUri(),
			$this->_apiSetting->getSecretKey(),$requestPayload);

		$responseModel = new ResponseModels\Charge($processCharge);


		return $responseModel;
	}
72849
public function UpdateCardCharge(RequestModels\ChargeUpdate
	                                 $requestModel)
	{

		$chargeMapper = new ChargesMapper($requestModel);

		$requestPayload = array (
			'authorization' => $this->_apiSetting->getSecretKey(),
			'mode'          => $this->_apiSetting->getMode(),
			'postedParam'   => $chargeMapper->requestPayloadConverter(),

		);
		$updateUri = sprintf ($this->_apiUrl->getUpdateChargesApiUri(),$requestModel->getChargeId());

		$processCharge = \com\checkout\helpers\ApiHttpClient::putRequest($updateUri,
			$this->_apiSetting->getSecretKey(),$requestPayload);

		$responseModel = new \com\checkout\ApiServices\SharedModels\OkResponse($processCharge);


		return $responseModel;
	}
1223862
public function defaultCard()
    {
        if (! $this->hasStripeId()) {
            return;
        }

        $customer = $this->asStripeCustomer();

        foreach ($customer->sources->data as $card) {
            if ($card->id === $customer->default_source) {
                return $card;
            }
        }
    }
896159
public function handlePutDefault(Request $request, $model)
    {
        if (empty($request->id)) {
            throw new Exception(
                'No ID provided',
                static::ERROR_SCOPE | static::ERROR_NO_ID,
                BaseResponse::HTTP_BAD_REQUEST
            );
        }

        $updates = $this->parseRequestContent($request->content, $model->getResourceType());

        $model = $model::find($request->id);
        if (is_null($model)) {
            return null;
        }

        // fetch the original attributes
        $originalAttributes = $model->getOriginal();

        // apply our updates
        $model->fill($updates);

        // ensure we can get a succesful save
        if (!$model->save()) {
            throw new Exception(
                'An unknown error occurred',
                static::ERROR_SCOPE | static::ERROR_UNKNOWN,
                BaseResponse::HTTP_INTERNAL_SERVER_ERROR
            );
        }

        // fetch the current attributes (post save)
        $newAttributes = $model->getAttributes();

        // loop through the new attributes, and ensure they are identical
        // to the original ones. if not, then we need to return the model
        foreach ($newAttributes as $attribute => $value) {
            if (! array_key_exists($attribute, $originalAttributes) || $value !== $originalAttributes[$attribute]) {
                $model->markChanged();
                break;
            }
        }

        return $model;
    }
1137777
public function charge(ChargeRequest $request)
    {
        $result = $this->request('POST', '/charges', [
            'card'     => (string) $request->getToken(),
            'amount'   => $request->getAmount() ? $request->getAmount()->getAmount() : null,
            'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null,
            'capture'  => $request->isCapture() ? 'true' : 'false',
            'products' => json_encode($request->getProducts()),
        ]);

        return $this->objectConverter->convert($result);
    }
1097176
public function createCustomer($paymentType, $customerId, $payment, $additional = [])
    {
        $this->integrityCheck();
        $createCustomerRes = $this->mpay24Sdk->createCustomer($paymentType, $customerId, $payment, $additional);
        $this->recordedLastMessageExchange('CreateCustomer');

        return $createCustomerRes;
    }
561479
public function getCardReference()
    {
        if (isset($this->data['object']) && 'customer' === $this->data['object']) {
            if (isset($this->data['default_source']) && !empty($this->data['default_source'])) {
                return $this->data['default_source'];
            }

            if (isset($this->data['default_card']) && !empty($this->data['default_card'])) {
                return $this->data['default_card'];
            }
            
            if (!empty($this->data['id'])) {
                return $this->data['id'];
            }
        }
        if (isset($this->data['object']) && 'card' === $this->data['object']) {
            if (!empty($this->data['id'])) {
                return $this->data['id'];
            }
        }
        if (isset($this->data['object']) && 'charge' === $this->data['object']) {
            if (! empty($this->data['source'])) {
                if (! empty($this->data['source']['id'])) {
                    return $this->data['source']['id'];
                }
            }
        }

        return null;
    }
375993
public function create()
    {
        $instance = self::createCreditCardPayment($this);
        $this->setId($instance->getId());
        return $instance;
    }
1200351
public Charge create(Charge charge) throws BaseException {

		logger.debug("Enter ChargeService::create");
		
		// prepare API url
		String apiUrl = requestContext.getBaseUrl() + "charges".replaceAll("\\{format\\}", "json");
		logger.info("apiUrl - " + apiUrl);
		
		// assign TypeReference for deserialization
		TypeReference<Charge> typeReference = new TypeReference<Charge>() {
		};

		// prepare service request
		Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(charge)
				.typeReference(typeReference).context(requestContext).build();

		// make API call
		Response response = sendRequest(request);

		// retrieve response
		Charge chargeResponse = (Charge) response.getResponseObject();

		// set additional attributes
		prepareResponse(request, response, chargeResponse);
		return chargeResponse;
	}
413671
private function createDeleteForm(BrandModel $brandModel)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('ecommerce_brandmodel_delete', array('id' => $brandModel->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
210131
public function asRequestModel() : RequestModel
    {
        if ($this->requestModel === null) {
            $this->requestModel = RequestModel::fromRequest($this);
        }
        return $this->requestModel;
    }
133608
public function setCardExpMonth($sCardExpMonth)
    {
        //  Validate
        if (is_numeric($sCardExpMonth)) {

            $iMonth = (int) $sCardExpMonth;
            if ($iMonth < 1 || $iMonth > 12) {

                throw new ChargeRequestException(
                    '"' . $sCardExpMonth . '" is an invalid expiry month; must be in the range 1-12.',
                    1
                );

            } else {
                $this->oCard->exp->month = $iMonth < 10 ? '0' . $iMonth : (string) $iMonth;
                return $this;
            }

        } else {
            throw new ChargeRequestException(
                '"' . $sCardExpMonth . '" is an invalid expiry month; must be numeric.',
                1
            );
        }
    }
598092
public function actionRecharge()
    {
        $model = new Recharge();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            $payment = new Payment([
                'currency' => $model->currency,
                'money' => $model->money,
                'name' => Yii::t('coin', 'Coin Recharge'),
                'gateway' => $model->gateway,
                'trade_type' => Payment::TYPE_NATIVE,
                'model_id' => $model->id,
                'model' => get_class($model),
                'return_url' => Url::to(['/coin/coin/index'], true),
            ]);
            if ($payment->save()) {
                $model->link('payment', $payment);
                return $this->redirect(['/payment/default/pay', 'id' => $payment->id]);
            }
        }
        return $this->render('recharge', [
            'model' => $model,
        ]);
    }
62058
public function createAccountAction(Request $request)
    {
        $selfRegistration = $this
            ->get('claroline.config.platform_config_handler')
            ->getParameter('allow_self_registration');
        if ($selfRegistration) {
            $session = $request->getSession();
            $service = $session->get('claroline.oauth.resource_owner');
            $translator = $this->get('translator');
            $translator->setLocale($request->getLocale());

            return $this->get('claroline.oauth.manager')->createNewAccount($request, $translator, $service);
        }

        return $this->redirectToRoute('claco_oauth_check_connexion');
    }
1295380
public function updateCard( CustomerVault\Card $card )
    {
        $card->setRequiredFields(array(
            'profileID',
            'id'
        ));
        $card->checkRequiredFields();
        $card->setRequiredFields(array());
        $card->setOptionalFields(array(
            'cardExpiry',
            'nickName',
            'merchantRefNum',
            'holderName',
            'billingAddressId',
            'defaultCardIndicator',
        ));

        $request = new Request(array(
            'method' => Request::PUT,
            'uri' => $this->prepareURI("/profiles/" . $card->profileID . "/cards/" . $card->id),
            'body' => $card
        ));
        $response = $this->client->processRequest($request);
        $response['profileID'] = $card->profileID;

        return new CustomerVault\Card($response);
    }
290366
public function importCard(RawSignedModel $rawSignedModel)
    {
        $card = $this->parseRawCard($rawSignedModel);

        if (!$this->cardVerifier->verifyCard($card)) {
            throw new CardVerificationException('Validation errors have been detected');
        }

        return $card;
    }
1033738
public function setCardNumber($sCardNumber)
    {
        //  Validate
        if (preg_match('/[^\d ]/', $sCardNumber)) {
            throw new ChargeRequestException('Invalid card number; can only contain digits and spaces.', 1);

        }
        $this->oCard->number = $sCardNumber;
        return $this;
    }