我正在开发一个电子商务mobiloe应用程序,仅使用magento 2 rest apis。这是使REST API调用订单放置的流程。无法在magento 2 rest中使用paypal进行下单
1.Create a cart
API - >{{url}}/index.php/rest/V1/carts/mine
该API将返回唯一车ID
2.Add products to cart
API - >{{url}}/index.php/rest/V1/carts/mine/items
体 - >
{
"cart_item": {
"quote_id": cartId,
"sku": skuName,
"qty": 1
}
}
3. Estimate Shipping Methods
网址 - >{{url}}/index.php/rest/V1/carts/mine/estimate-shipping-methods
体 - >
{
"address": {
"region": "Trivandrum",
"region_id": 12,
"region_code": "CA",
"country_id": "IN",
"street": [
"Amstor house",
"Eramam"
],
"telephone": "5656565454",
"postcode": "670390",
"city": "Kazhakuttam",
"firstname": "Peter",
"lastname": "K",
"same_as_billing": 0,
"save_in_address_book": 0
}
}
这将返回根据送货地址的所有可能的运输方式在我的情况下,结果是
[
{
"carrier_code": "freeshipping",
"method_code": "freeshipping",
"carrier_title": "Free Shipping",
"method_title": "Free",
"amount": 0,
"base_amount": 0,
"available": true,
"error_message": "",
"price_excl_tax": 0,
"price_incl_tax": 0
}
]
4)Save shipping information
网址 - >{{url}}/index.php/rest/V1/carts/mine/shipping-information
体数据 - >
{
"addressInformation": {
"shipping_address": {
"region": "Trivandrum",
"region_id": 12,
"region_code": "CA",
"country_id": "IN",
"street": [
"Amstor house",
"Eramam"
],
"telephone": "5656565454",
"postcode": "670390",
"city": "Kazhakuttam",
"firstname": "Peter",
"lastname": "K",
},
"billing_address": {
"region": "Trivandrum",
"region_id": 12,
"region_code": "CA",
"country_id": "IN",
"street": [
"Amstor house",
"Eramam"
],
"telephone": "5656565454",
"postcode": "670390",
"city": "Kazhakuttam",
"firstname": "Peter",
"lastname": "K",
},
"shipping_method_code": "freeshipping",
"shipping_carrier_code": "freeshipping"
}
}
这将返回所有可能的付款方式。在这里,我使用paypal_express
付款。
5. Payment using paypal plugin
在这里,我将支付使用paypal cordova plugin量。还配置了IPN [{{URL}} /贝宝/ IPN /]在PayPal帐户
此API将返回以下数据,
{
"client": {
"environment": "sandbox",
"paypal_sdk_version": "2.14.4",
"platform": "Android",
"product_name": "PayPal-Android-SDK"
},
"response": {
"create_time": "2016-11-19T05:25:46Z",
"id": "PAY-5VS11410F5341972MLAX6ETA",
"intent": "sale",
"state": "approved"
},
"response_type": "payment"
}
5.Save payment and place order
URL - >{{url}}/index.php/rest/V1/carts/mine/payment-information
数据 - >
{
"cartId": 3,
"billingAddress": {
"region": "Trivandrum",
"region_id": 12,
"region_code": "CA",
"country_id": "IN",
"street": [
"Amstor house",
"Eramam"
],
"telephone": "5656565454",
"postcode": "670390",
"city": "Kazhakuttam",
"firstname": "Peter",
"lastname": "K"
},
"paymentMethod": {
"method": "paypal_express"
}
}
但是这个API将返回
{
"message": "PayPal gateway has rejected request. Invalid token (#10410: Invalid token)."
}
是否有任何API中捕获payments.Please帮我上述流程失踪。
肯定的是,我有同样的问题。 – Manish
贝宝将在收到付款后发送IPN。您应该使用它来下订单...否则,您的客户可能会尝试通过逆向工程来欺骗付款。 –