Open2b versione 7.5

payment-methods

payment-methods.compute-costs

Calculates payment costs, taxes included, for one or more amounts to pay.

Request

Admin SDK
Admin.api('commerce.payment-methods.compute-costs', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.compute-costs
{
  "amounts" : [ 34.602, 86.058, … ], // amounts that have to be paied (required) - decimal[10,3](0…)
  "taxArea" : 5, // tax area (id) for which to calculate taxes (required) - int(1…)
  "conditions" : { // return only costs for payment methods …
    "ids" : [ 3, 7, … ], // … with these identifiers - int(1…)
    "isActive" : true, // … that are active - bool
    "isDefault" : false, // … that are the default - bool
    "after" : 3 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "costs" : [ { // costs for each good and each payment method (id) - int(1…) -> decimal[8,3](0…)
      "3" : 2.061,
      "7" : 1.890,
      …
    }, … ]
  }
}

Errors

Field Type Description
taxArea NotFound Tax area <taxArea> does not exist

payment-methods.find

Returns the payment methods that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.payment-methods.find', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.find
{
  "conditions" : { // returns the payment methods …
    "ids" : [ 3, 7, … ], // … with these identifiers - int(1…)
    "isActive" : true, // … that are visible or not visible on the store - bool
    "isDefault" : false, // … that are the default payment method or not - bool
    "after" : 3 // … with identifier after this value - int(0…)
  },
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "name", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned payment methods, can contain "id", "-id", "name", "-name", "isOnDelivery",
                        // "-isOnDelivery", "isActive", "-isActive", "provider" and "-provider" - string
  "limit" : 10, // maximum number of methods to return - int(1…)
  "first" : 0 // index of the first method to return - int(0…)
}

Response

{
  "status" : "ok",
  "paymentMethods" : [ {
    "id" : 3, // identifier - int(1…)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Credit card",
      "it" : "Carta di credito"
    },
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Visa and Mastercard",
      "it" : "Visa e Mastercard"
    },
    "instructions" : { // instructions for payment - string(2) -> string(0…255)
      "en" : "Click Pay",
      "it" : "Fai clic su Paga"
    },
    "isOnDelivery" : false, // indicates if the payment is on delivery - bool
    "isActive" : true, // indicates if it is visible on shop - bool
    "isDefault" : false, // indicates if it is the default payment method - bool
    "maxAmountPayable" : 3000.000, // maximum amount that can be paied - decimal[10,3](0…)
    "percentFee" : 2.500, // percent payment fee - decimal[5,3](0…)
    "fixedFee" : 0.200, // fixed payment fee - decimal[8,3](0…)
    "minimumFee" : 0.000, // minimum fee for a payment - decimal[8,3](0…)
    "taxClass" : 7, // tax class (id) with which calculate taxes (can be null) - int(1…)
    "provider" : "PayPal", // payment provider (can be null) - string(1…20)
    "providerSettings" : { // payment provider settings (can be null) - string(1…100) -> string(0…1000)
      "business" : "orders@mydomain.com",
      "sandbox"  : "0"
    }
  }, … ]
}

payment-methods.get

Returns a payment method given its identifier.

Request

Admin SDK
Admin.api('commerce.payment-methods.get', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.get
{
  "id" : 3, // identifier (required) - int(1…)
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "name", … ] // fields to return - string
}

Response

{
  "status" : "ok",
  "paymentMethod" : { // (can be null)
    "id" : 3, // identifier - int(1…)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Credit card",
      "it" : "Carta di credito"
    },
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Visa and Mastercard",
      "it" : "Visa e Mastercard"
    },
    "instructions" : { // instructions for payment - string(2) -> string(0…255)
      "en" : "Click Pay",
      "it" : "Fai clic su Paga"
    },
    "isOnDelivery" : false, // indicates if the payment is on delivery - bool
    "isActive" : true, // indicates if it is visible on shop - bool
    "isDefault" : false, // indicates if it is the default payment method - bool
    "maxAmountPayable" : 3000.000, // maximum amount that can be paied - decimal[10,3](0…)
    "percentFee" : 2.500, // percent payment fee - decimal[5,3](0…)
    "fixedFee" : 0.200, // fixed payment fee - decimal[8,3](0…)
    "minimumFee" : 0.000, // minimum fee for a payment - decimal[8,3](0…)
    "taxClass" : 7, // tax class (id) with which calculate taxes (can be null) - int(1…)
    "provider" : "PayPal", // payment provider (can be null) - string(1…20)
    "providerSettings" : { // payment provider settings (can be null) - string(1…100) -> string(0…1000)
      "business" : "orders@mydomain.com",
      "sandbox"  : "0"
    }
  }
}

payment-methods.count

Number of payment methods that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.payment-methods.count', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.count
{
  "conditions" : { // counts the payment methods …
    "ids" : [ 3, 7, … ], // … with these identifiers - int(1…)
    "isActive" : true, // … that are visible or not visible on the store - bool
    "isDefault" : false, // … that are the default payment method or not - bool
    "after" : 3 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "count" : 4 // number of payment methods - int(0…)
}

payment-methods.create

Creates a new payment method.

Request

Admin SDK
Admin.api('commerce.payment-methods.create', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.create
{
  "paymentMethod" : { // payment method to create (required)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Credit card",
      "it" : "Carta di credito"
    },
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Visa and Mastercard",
      "it" : "Visa e Mastercard"
    },
    "instructions" : { // instructions for payment - string(2) -> string(0…255)
      "en" : "Click Pay",
      "it" : "Fai clic su Paga"
    },
    "isOnDelivery" : false, // indicates if the payment is on delivery - bool
    "isActive" : true, // indicates if it is visible on shop - boo    
    "isDefault" : false, // indicates if it is the default payment method - bool
    "maxAmountPayable" : 3000.00, // maximum amount that can be paied - decimal[10,3](0…)
    "percentFee" : 2.500, // percent payment fee - decimal[5,3](0…)
    "fixedFee" : 0.200, // fixed payment fee - decimal[8,3](0…)
    "minimumFee" : 0.000, // minimum fee for a payment - decimal[8,3](0…)
    "taxClass" : 7, // tax class (id) with which calculate taxes (can be null) - int(1…)
    "provider" : "PayPal", // payment provider - string(1…20)
    "providerSettings" : { // payment provider settings - string(1…100) -> string(0…1000)
      "business" : "orders@mydomain.com",
      "sandbox"  : "0"
    }
}

Response

{
  "status" : "ok",
  "id" : 3 // identifier of the new payment method - int(1…)
}

Errors

Field Type Description
provider NotFound Payment provider '<provider>' does not exist
providerSettings InvalidCombination 'providerSettings' is required if 'provider' is provided
providerSettings InvalidCombination 'providerSettings' is not allowed without 'provider'
providerSettings InvalidValue Provider settings are not valid: <provider errors>
taxClass NotFound Tax class <taxClass> does not exist

payment-methods.update

Updates a payment method. Any fields left out of the request will remain unchanged.

Request

Admin SDK
Admin.api('commerce.payment-methods.update', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.update
{
  "id" : 3, // identifier of the payment method to update (required) - int(1…)
  "paymentMethod" : { // payment method's fields to update (required)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Credit card",
      "it" : "Carta di credito"
    },
    "description" : { // description - string(2) -> string(0…255)
      "en" : "Visa and Mastercard",
      "it" : "Visa e Mastercard"
    },
    "instructions" : { // instructions for payment - string(2) -> string(0…255)
      "en" : "Click Pay",
      "it" : "Fai clic su Paga"
    },
    "isOnDelivery" : false, // indicates if the payment is on delivery - bool
    "isActive" : true, // indicates if it is visible on shop - boo    
    "isDefault" : false, // indicates if it is the default payment method - bool
    "maxAmountPayable" : 3000.00, // maximum amount that can be paied - decimal[10,3](0…)
    "percentFee" : 2.500, // percent payment fee - decimal[5,3](0…)
    "fixedFee" : 0.200, // fixed payment fee - decimal[8,3](0…)
    "minimumFee" : 0.000, // minimum fee for a payment - decimal[8,3](0…)
    "taxClass" : 7, // tax class (id) with which calculate taxes (can be null) - int(1…)
    "providerSettings" : { // payment provider settings - string(1…100) -> string(0…1000)
      "business" : "orders@mydomain.com",
      "sandbox"  : "0"
    }
  }
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
id NotFound Payment method <id> does not exist
isDefault Malformed 'isDefault' can not be false
providerSettings InvalidValue Payment method <id> does not have a provider
providerSettings InvalidValue Provider settings are not valid: <provider errors>

payment-methods.delete

Deletes one o more payment methods.

Request

Admin SDK
Admin.api('commerce.payment-methods.delete', request, function(response) { … });
HTTP POST
/api/v10/commerce.payment-methods.delete
{
  "ids" : [ 3, 7, … ] // identifiers of the payment methods to delete (required) - int(1…)
}

Response

{
  "status" : "ok"
}
Field Type Description
id CannotDelete Payment method <id> can not be deleted because is the default method