Magento – How to capture creditcard payment using sales order REST API magento 2

magento-2.1paypal-payflow-prorest apisales-order

How to create sales order with payflow pro payment using REST api magento 2.

Order placed successfully with sales order api but payment doesn't not set using order api.

I want to pass test credit card info in order to check how payment are capture using api.

Just test with VISA Test credit card

  • Credit card number 4111111111111111
  • Expiry Month year 01/20

Payment method is payflowpro.

Request:

http://{websiteurl}/index.php/rest/V1/orders/

I am using salesOrderRepositoryV1 API for place order using api from swagger Sales Order Using Rest API.

Below is the structure of payment method in api,

"payment": {
      "account_status": "string",
      "additional_data": "string",
      "additional_information": [
        "string"
      ],
      "address_status": "string",
      "amount_authorized": 0,
      "amount_canceled": 0,
      "amount_ordered": 0,
      "amount_paid": 0,
      "amount_refunded": 0,
      "anet_trans_method": "string",
      "base_amount_authorized": 0,
      "base_amount_canceled": 0,
      "base_amount_ordered": 0,
      "base_amount_paid": 0,
      "base_amount_paid_online": 0,
      "base_amount_refunded": 0,
      "base_amount_refunded_online": 0,
      "base_shipping_amount": 0,
      "base_shipping_captured": 0,
      "base_shipping_refunded": 0,
      "cc_approval": "string",
      "cc_avs_status": "string",
      "cc_cid_status": "string",
      "cc_debug_request_body": "string",
      "cc_debug_response_body": "string",
      "cc_debug_response_serialized": "string",
      "cc_exp_month": "string",
      "cc_exp_year": "string",
      "cc_last4": "string",
      "cc_number_enc": "string",
      "cc_owner": "string",
      "cc_secure_verify": "string",
      "cc_ss_issue": "string",
      "cc_ss_start_month": "string",
      "cc_ss_start_year": "string",
      "cc_status": "string",
      "cc_status_description": "string",
      "cc_trans_id": "string",
      "cc_type": "string",
      "echeck_account_name": "string",
      "echeck_account_type": "string",
      "echeck_bank_name": "string",
      "echeck_routing_number": "string",
      "echeck_type": "string",
      "entity_id": 0,
      "last_trans_id": "string",
      "method": "string",
      "parent_id": 0,
      "po_number": "string",
      "protection_eligibility": "string",
      "quote_payment_id": 0,
      "shipping_amount": 0,
      "shipping_captured": 0,
      "shipping_refunded": 0,
      "extension_attributes": {
        "vault_payment_token": {
          "entity_id": 0,
          "customer_id": 0,
          "public_hash": "string",
          "payment_method_code": "string",
          "type": "string",
          "created_at": "string",
          "expires_at": "string",
          "gateway_token": "string",
          "token_details": "string",
          "is_active": true,
          "is_visible": true
        }
      }
    }

How to set credit card info in above structure to place order using Paypal.

How to place order using credit card data?

Best Answer

Use below tutorial for place order:

https://devdocs.magento.com/guides/v2.3/rest/tutorials/orders/order-create-order.html

You can directly use below request

POST http:///rest/default/V1/carts/mine/payment-information

for place order.

If you looking for online payment method then check this request in your browser console at payment page and pass required parameters. Generally magento suggest do not pass card detail to server instead pass token so you have to generate card token from your end pass into above rest api and for save card you have to pass public hash .

Related Topic