2017-12-10 15 views
0

내가 페이팔로 배송 정보를 보내면 사용자가 페이팔로 리디렉션 될 때 사용자가 배송 정보를 다시 기입하지 않아도되는지 궁금합니다. 사용자가 이미 운송 정보를 기입했으며 데이터가 제 데이터베이스에 저장되었습니다. 문제는 데이터베이스에 저장된 배송 정보가 주문을 한 사람과 동일한 주소가 아닐 가능성이 높습니다. 사용자는 자신의 주소가 아닌 다른 배송 주소를 사용하고있을 가능성이 큽니다. 이제는 이런 식으로 잘 작동 할 수는 있지만 생각하고있었습니다. Paypal의 기록에 올바른 배송 주소가 저장되어 있지 않으면 고객이 제품을 배송하지 않고 환불을 요구할 수 있다고 쉽게 말할 수 있습니다. 이 시점에서 필자는 페이팔 기록이 아닌 내 데이터베이스에 저장된 주소에만 추적 번호를 부여하여 이러한 유형의 페이팔 사기에 취약하게 만듭니다. 누군가를 잘못한 경우에 나를 정정하십시오. 다음은paypal-rest-sdk 모듈을 사용하여 Node.js를 통해 배송 정보를 Paypal로 보내려면 어떻게해야합니까?

데이터가 주문 과정에서 그들에게 보낸 내용에 Paypals 예입니다 https://github.com/paypal/PayPal-node-SDK/blob/master/samples/order/create.js

var create_payment_json = { 
    "intent": "order", 
    "payer": { 
     "payment_method": "paypal" 
    }, 
    "redirect_urls": { 
     "return_url": "http://return.url", 
     "cancel_url": "http://cancel.url" 
    }, 
    "transactions": [{ 
     "item_list": { 
      "items": [{ 
       "name": "item", 
       "sku": "item", 
       "price": "1.00", 
       "currency": "USD", 
       "quantity": 1 
      }] 
     }, 
     "amount": { 
      "currency": "USD", 
      "total": "1.00" 
     }, 
     "description": "This is the payment description." 
    }] 
}; 

I added a shipping object, see the sample below.

var create_payment_json = { 
     "intent": "sale", 
     "payer": { 
      "payment_method": "paypal" 
     }, 
     "redirect_urls": { 
      "return_url": "https://website.com/thankyou", 
      "cancel_url": "https://website.com" 
     }, 
     "transactions": [{ 
      "item_list": { 
       "items": [{ 
        "name": name, 
        "sku": "item", 
        "price": total_price, 
        "currency": "USD", 
        "quantity": 1 
       }] 
      }, 
      "shipping_address": { 
      "recipient_name":recipient_name, 
      "line1":line_1, 
      "city": city, 
      "state":state, 
      "postal_code":zipcode, 
      "country_code":"US" 
      }, 
      "amount": { 
       "currency": "USD", 
       "total": total_price 
      }, 
      "description": description 
     }] 
     }; 

그러나 나는이 오류를 얻을 :

"response": { 
    "name":"MALFORMED REQUEST", 
    "message":"Incoming JSON request", 
    "information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST", 
    "debug_id":"cb2ecc213218b", 
    "httpStatusCode":400 
}, 
"httpStatusCode":400 
} 

난 그냥 이것을하지 않았다을 선적 물. Paypal 지불을 성공적으로 수행하면 PayPal은 운송 주소 오브젝트를 포함하는 트랜잭션 오브젝트를 리턴합니다. 나는 페이팔에 배송 정보를 보낼 수 있다고 가정하고 내가 본 것을 정확히 복사했습니다.

Paypal 주문을 생성 할 때 어떻게 REST API/node.js를 통해 배송 정보를 Paypal로 보낼 수 있습니까? 기억하십시오. 상점에서 결제를하고 Paypal에 로그인하면 배송 주소가 자동으로 Paypal로 설정 한 배송 주소가됩니다. API를 통해 어떻게 변경합니까? 만약 당신이 기울이지 않는다면, 상점들이 이런 종류의 상황을 어떻게 다루는가? 예를 들어, 친구에게 선물을 사주세요. 시간 내 주셔서 감사합니다. 도움을 많이 받으실 수 있습니다.

답변

0

올바른 접근 방법이 있습니다. shipping_address 개체는 items 배열 옆에 item_list 안에 속합니다. 여기

예 :

var create_payment_json = { 
    "intent": "sale", 
    "payer": { 
     "payment_method": "paypal" 
    }, 
    "redirect_urls": { 
     "return_url": "https://website.com/thankyou", 
     "cancel_url": "https://website.com" 
    }, 
    "transactions": [{ 
     "item_list": { 
      "shipping_address": { 
       "recipient_name":recipient_name, 
       "line1":line_1, 
       "city": city, 
       "state":state, 
       "postal_code":zipcode, 
       "country_code":"US" 
      }, 
      "items": [{ 
       "name": name, 
       "sku": "item", 
       "price": total_price, 
       "currency": "USD", 
       "quantity": 1 
      }] 
     }, 
     "amount": { 
      "currency": "USD", 
      "total": total_price 
     }, 
     "description": description 
    }] 
    };