public function remove($removeWithSubscriptions = false) { if (!$this->id) { throw new LaraMillException('Offer ID is needed to remove offer.', 403); } $offer = new \Paymill\Models\Request\Offer(); $offer->setId($this->id)->setRemoveWithSubscriptions($removeWithSubscriptions); return $this->request->delete($offer); }
content="text/html; charset=utf-8"/> <?php // // Please download the Paymill PHP Wrapper using composer. // If you don't already use Composer, // then you probably should read the installation guide http://getcomposer.org/download/. // //Change the following constants define('PAYMILL_API_KEY', 'YOUR_API_KEY'); define('CUSTOMER_EMAIL', 'SOME_TEST_EMAIL'); require 'vendor/autoload.php'; if (isset($_POST['paymillToken'])) { $service = new Paymill\Request(PAYMILL_API_KEY); $client = new Paymill\Models\Request\Client(); $payment = new Paymill\Models\Request\Payment(); $offer = new Paymill\Models\Request\Offer(); $subscription = new Paymill\Models\Request\Subscription(); try { $client->setEmail(CUSTOMER_EMAIL); $client->setDescription('This is a Testuser.'); $clientResponse = $service->create($client); $payment->setClient($clientResponse->getId()); $payment->setToken($_POST['paymillToken']); $paymentResponse = $service->create($payment); $offer->setAmount($_POST['amount'])->setCurrency($_POST['currency'])->setInterval($_POST['interval'])->setName($_POST['offer-name']); $offerResponse = $service->create($offer); $subscription->setClient($clientResponse->getId()); $subscription->setPayment($paymentResponse->getId()); $subscription->setOffer($offerResponse->getId()); $subscriptionResponse = $service->create($subscription); $title = "<h1>We appreciate your order!</h1>";
/** * Edit offer amount. * * @param int $offerId * @param EditOfferAmountRequest $request * @return */ public function editOfferAmount($offerId, EditOfferAmountRequest $request) { $response = new AjaxResponse(); $offerModel = Offer::where('id', $offerId)->first(); // Make sure offer exists if (!$offerModel) { $response->setFailMessage(trans('offers.offer_not_found')); return response($response->get(), 404)->header('Content-Type', 'application/json'); } // Create paymill request $paymillRequest = new \Paymill\Request(env('PAYMILL_API_KEY')); // Create new paymill offer object and set new amount $offer = new \Paymill\Models\Request\Offer(); $offer->setId($offerModel->paymill_offer_id)->setAmount($request->get('offer_amount')); // Save on paymill $paymillResponse = $paymillRequest->update($offer); // Update offer amount in database $offerModel->amount = $request->get('offer_amount'); $offerModel->save(); // Return json response $response->setSuccessMessage(trans('offers.offer_amount_updated')); $response->addExtraFields(['offer' => Offer::countAssociatedSubscriptions()->where('offers.id', $offerId)->first()]); return response($response->get())->header('Content-Type', 'application/json'); }