/** * Create Redirect response to complete cart. * * @param int $id * @param \Userdesk\Subscription\Contracts\Product $product * @param \Userdesk\Subscription\Contracts\Consumer $consumer * @return \Illuminate\Http\Response|null */ public function complete(int $id, SubscriptionProductContract $product, SubscriptionConsumerContract $consumer) { $params = ['mode' => '2CO', 'sid' => array_get($this->config, 'sid'), 'li_0_type' => 'product', 'li_0_name' => $product->getTitle(), 'li_0__description' => $product->getDescription(), 'li_0_price' => $product->getPrice(), 'li_0_recurrence' => $product->getFrequency() == 'month' ? '1 Month' : ($product->getFrequency() == 'year' ? '1 Year' : ''), 'li_0_duration' => $product->getFrequency() == 'year' || $product->getFrequency() == 'month' ? 'Forever' : '', 'li_0_tangible' => 'N', 'li_0_quantity' => '1', 'merchant_order_id' => $id, 'card_holder_name' => $consumer->getName(), 'street_address' => $consumer->getAddress(), 'street_address2' => '', 'city' => $consumer->getCity(), 'state' => $consumer->getState(), 'zip' => $consumer->getZip(), 'country' => $consumer->getCountry(), 'email' => $consumer->getEmail(), 'phone' => $consumer->getPhone(), 'purchase_step' => 'payment-method', 'x_receipt_link_url' => $product->getReturnUrl(), 'ipn_url' => $product->getIpnUrl(), 'submit' => 'Checkout']; if ($product->getDiscount() > 0) { $params = array_merge($params, ['li_0_startup_fee' => $product->getDiscount()]); } $url = sprintf('https://www.2checkout.com/checkout/purchase?%s', http_build_query($params)); return redirect()->away($url); }
/** * Create Redirect response to complete cart. * * @param int $id * @param \Userdesk\Subscription\Contracts\Product $product * @param \Userdesk\Subscription\Contracts\Consumer $consumer * @return \Illuminate\Http\Response|null */ public function complete(int $id, SubscriptionProductContract $product, SubscriptionConsumerContract $consumer = null) { $login = array_get($this->config, 'login'); $key = array_get($this->config, 'key'); $hash = md5(sprintf("%s^x_login^x_fp_arg_list^x_fp_sequence^x_amount^x_currency_code^%s^%s^USD^%s", $login, $id, $product->getPrice(), $key)); $frequency = $product->getFrequency(); $recurrence = $product->getRecurrence(); $params = ['x_version' => '1.0', 'x_fp_arg_list' => 'x_login^x_fp_arg_list^x_fp_sequence^x_amount^x_currency_code', 'x_currency_code' => 'USD', 'x_method' => 'CC', 'x_shipping_amount' => '0.00', 'x_subscription_type' => 'A', 'x_login' => array_get($this->config, 'login'), 'x_fp_sequence' => $id, 'x_invoice_num' => $id, 'x_ship_to_name' => $consumer->getName(), 'x_ship_to_address' => $consumer->getAddress(), 'x_ship_to_address2' => '', 'x_ship_to_city' => $consumer->getCity(), 'x_ship_to_state' => $consumer->getState(), 'x_ship_to_zip' => $consumer->getZip(), 'x_ship_to_country' => $consumer->getCountry(), 'x_ship_to_phone' => $consumer->getPhone(), 'x_email' => $consumer->getEmail(), 'x_product_sku_1' => $id, 'x_product_title_1' => $product->getTitle(), 'x_product_quantity_1' => '1', 'x_product_unitprice_1' => $product->getPrice(), 'x_product_url_1' => array_get($this->config, 'url'), 'x_amount' => $product->getPrice(), 'x_subscription_freq' => $recurrence == 'month' ? sprintf('%sM', $frequency) : ($recurrence == 'year' ? sprintf('%sY', $frequency) : ''), 'x_fp_hash' => $hash]; $url = sprintf('https://www.ccnow.com/cgi-local/transact.cgi?%s', http_build_query($params)); return redirect()->away($url); }