2Checkout / 2checkout-php

2Checkout PHP Library
MIT License
83 stars 66 forks source link

Sell already created product on https://sandbox.2checkout.com/sandbox/products/list_products #28

Open denGitHub opened 7 years ago

denGitHub commented 7 years ago

Is it possible to sell the product which is created on the dashboard of 2CO account?

  1. I have a product on 2CO with "product id" 12345 with all params: tangible, recur........ Now I want to run just with this product id like "productId" =>"12345"

       $lineItems = array(
               "productId"  => "12345",
           );
         $query = array(
               "sellerId" => config('apikeys.twocheckout.seller_id'),
               "merchantOrderId" => "123465",
               "token" => $this->billing_data['token'],
               "currency" => self::CURRENCY,
               "billingAddr" => $billing_address,
               "lineItems" => array(  $lineItems    ),
       )

    And I got error 400 in response

though

  1. This example works fine.

    
          $lineItems = array(
               "productId"  => "2",
               "name"        => "Test Product",
               "quantity"    => "1",
               "tangible"    => "N",
               "startupFee" => "1.00",
               "recurrence"  => "1 Month",
               "description" => "This is a test",
               "price"=>"10.0"
           );
    
           $query = array(
               "sellerId" => config('apikeys.twocheckout.seller_id'),
               "merchantOrderId" => "123465",
               "token" => $this->billing_data['token'],
               "currency" => self::CURRENCY,
               "billingAddr" => $billing_address,
               "lineItems" => array(
                   $lineItems
               ),
           );

    It would be nice if it is possible to sell created product from dashboard. Thank you.

calebh05 commented 7 years ago

Unfortunately what you're trying to do will not work, you're omitting required attributes from the request.

Please review the documentation here, and scroll down to the lineitem attributes section. From there you'll see a list of required attributes, you would need to pass in the type, name, and price attributes to meet the minimum requirement.