amzn / amazon-pay-sdk-php

Amazon Pay PHP SDK
https://pay.amazon.com/documentation
Apache License 2.0
208 stars 92 forks source link

Full address and Name is not showing in the response of getOrderReferenceDetails #55

Open rohitpatil-tudip opened 7 years ago

rohitpatil-tudip commented 7 years ago

I want full selected address when the user selects any address from the address book. Following is the response what I got when "getOrderReferenceDetails" is executed.

{
    "GetOrderReferenceDetailsResult": {
        "OrderReferenceDetails": {
            "OrderReferenceStatus": {
                "State": "Draft"
            },
            "Destination": {
                "DestinationType": "Physical",
                "PhysicalDestination": {
                    "StateOrRegion": "Maharashtra",
                    "City": "Pune",
                    "CountryCode": "IN",
                    "PostalCode": "411057"
                }
            },
            "ExpirationTimestamp": "2018-01-03T11:27:29.805Z",
            "IdList": {

            },
            "SellerOrderAttributes": {
                "StoreName": "ZACK ACADEMY"
            },
            "OrderTotal": {
                "CurrencyCode": "USD",
                "Amount": "253.98"
            },
            "ReleaseEnvironment": "Sandbox",
            "SellerNote": "12-31-2020 - LEED Green Associate Exam Prep Online Anytime - Online, Live",
            "AmazonOrderReferenceId": "S01-4810502-0586824",
            "CreationTimestamp": "2017-07-07T11:27:29.805Z",
            "RequestPaymentAuthorization": "false"
        }
    },
    "ResponseMetadata": {
        "RequestId": "86c8e015-a182-4eca-b86f-b6c799ad6115"
    },
    "ResponseStatus": "200"
}
pdbreen commented 7 years ago

Two thoughts

1) make sure you're including payments:shipping_address in your scope

...
authorization: function () {
   loginOptions = {scope: 'profile payments:widget payments:shipping_address', popup: true};
   authRequest = amazon.Login.authorize(loginOptions, '{{route('amazon_login')}}');
},
...

2) it's possible that's all the information that Amazon has in the wallet for that address.

rohitpatil-tudip commented 7 years ago

@pdbreen, Thanks for the quick reply,

Yes, It is already there in my code but still, it is not giving the address1, address2, name etc details.

rohitpatil-tudip commented 7 years ago

Here is the expected response that I want,


<GetOrderReferenceDetailsResponse 
   xmlns="http://mws.amazonservices.com/schema/OffAmazonPayments/2013-01-01">
  <GetOrderReferenceDetailsResult>
    <OrderReferenceDetails>
    <AmazonOrderReferenceId>S01-8474066-EXAMPLE</AmazonOrderReferenceId>
    <ExpirationTimestamp>2015-08-31T17:27:35.053Z</ExpirationTimestamp>
    <SellerNote>Thank you for your order.</SellerNote>
    <OrderTotal>
      <Amount>15.00</Amount>
      <CurrencyCode>USD</CurrencyCode>
    </OrderTotal>
    <IdList>
      <member>S01-8474066-2115738-EXAMPLE</member>
    </IdList>
    <OrderReferenceStatus>
      <LastUpdateTimestamp>
        2015-03-04T17:27:43.851Z
      </LastUpdateTimestamp>
      <State>Open</State>
    </OrderReferenceStatus>
    <Destination>
      <DestinationType>Physical</DestinationType>
      <PhysicalDestination>
        <Phone>800-000-0000</Phone>
        <PostalCode>60602</PostalCode>
        <Name>Susie Smith</Name>
        <CountryCode>US</CountryCode>
        <StateOrRegion>IL</StateOrRegion>
        <AddressLine2>Suite 2500</AddressLine2>
        <AddressLine1>10 Ditka Ave</AddressLine1>
        <City>Chicago</City>
      </PhysicalDestination>
    </Destination>
    <ReleaseEnvironment>Sandbox</ReleaseEnvironment>
    <Buyer>
      <Email>address@domain.com</Email>
      <Name>Sandbox_tester</Name>
    </Buyer>
    <SellerOrderAttributes>
      <StoreName>Sandbox_test_app</StoreName>
    </SellerOrderAttributes>
    <CreationTimestamp>2015-03-04T17:27:35.053Z</CreationTimestamp>
    </OrderReferenceDetails>
  </GetOrderReferenceDetailsResult>
  <ResponseMetadata>
    <RequestId>181efc0d-a90b-429f-837e-1209bfe4da0e</RequestId>
  </ResponseMetadata>
</GetOrderReferenceDetailsResponse>
pdbreen commented 7 years ago

Are you including the token passed to your logon handler as the address_consent_token in the call to getOrderReferenceDetails?

        $this->result = $this->client->getOrderReferenceDetails([
            'amazon_order_reference_id' => $orderReferenceId,
            'address_consent_token' => $token,
        ]);
rohitpatil-tudip commented 7 years ago

Yes! On the GUI widget it is showing address properly but in the API response, it is not showing all the details.

I want to access these address related details. Is there any other way to do this?

rohitpatil-tudip commented 7 years ago

Please check details. details

pdbreen commented 7 years ago

I'd double check to make sure that address_consent_token being passed in is correct and the scope is being set properly. When its not supplied, you get partial shipping detail like you have.

https://pay.amazon.com/us/developer/documentation/apireference/201751970

rohitpatil-tudip commented 7 years ago

Here is my code, code

pdbreen commented 7 years ago

Debug your $_POST values and I think you'll find the addressConsentToken is not set/missing. So, you'll need to go back to the amazon integration doc and figure out what step was missed. Anyway, it doesn't sound like there's any issue with this library.

islandskater43 commented 7 years ago

It looks like you are trying to pass the address consent token into a SetOrderReferenceDetails API call. Instead, make the GetOrderReferenceDetails API call with the same inputs.

Otherwise, everything that @pdbreen mentioned above is correct and should work.