I have the following array for paypal plus. This works great for (iframe) 'Paypal' and 'Credit Card' payments. But does not work for 'Direct Debit'.
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[intent] => sale
[experience_profile_id] => TXP-2UP57256T6655231G
[payer] => PayPal\Api\Payer Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[payment_method] => paypal
)
)
[redirect_urls] => PayPal\Api\RedirectUrls Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[return_url] => http://test.localhost/paypal/payment.php?success=true
[cancel_url] => http://test.localhost/paypal/payment.php?success=false
)
)
[transactions] => Array
(
[0] => PayPal\Api\Transaction Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[amount] => PayPal\Api\Amount Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[total] => 10.50
[currency] => USD
[details] => PayPal\Api\Details Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[subtotal] => 7.50
[tax] => 1.50
[shipping] => 1.50
)
)
)
)
[description] => Payment description
[invoice_number] => 5936611845485
[item_list] => PayPal\Api\ItemList Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[items] => Array
(
[0] => PayPal\Api\Item Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[name] => Ground Coffee 40 oz
[description] => Ground Coffee 40 oz
[price] => 7.50
[currency] => USD
[quantity] => 1
)
)
)
)
)
[related_resources] => Array
(
)
)
)
)
[id] => PAY-9X212986B0791962DLE3GCGI
[state] => created
[create_time] => 2017-06-06T08:00:25Z
[links] => Array
(
[0] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-9X212986B0791962DLE3GCGI
[rel] => self
[method] => GET
)
)
[1] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-41B117362N517473Y
[rel] => approval_url
[method] => REDIRECT
)
)
[2] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-9X212986B0791962DLE3GCGI/execute
[rel] => execute
[method] => POST
)
)
)
)
Once i put all of my dummy bank details it says: We can not complete your purchase at the time
Please go back to the dealer and choose another payment method.
Here is the link (I am testing it in sandbox):
Can any one help?
Related
I want to implement pagination using "Flight Offers Search" of Amadeus API. There is no parameter to passing limit and offset using "Flight Offers Search" of Amadeus API.
I have bellow API URL with filter parameter to get flight list
https://api.amadeus.com/v2/shopping/flight-offers?originLocationCode=JFK&destinationLocationCode=LHR&departureDate=2021-09-02&returnDate=2021-09-05&adults=1&travelClass=ECONOMY¤cyCode=USD&max=10
And I got response from API like this
stdClass Object
(
[meta] => stdClass Object
(
[count] => 10
[links] => stdClass Object
(
[self] => https://api.amadeus.com/v2/shopping/flight-offers?originLocationCode=JFK&destinationLocationCode=LHR&departureDate=2021-09-02&returnDate=2021-09-05&adults=1&travelClass=ECONOMY¤cyCode=USD&max=10
)
)
[data] => Array
(
[0] => stdClass Object
(
[type] => flight-offer
[id] => 1
[source] => GDS
[instantTicketingRequired] =>
[nonHomogeneous] =>
[oneWay] =>
[lastTicketingDate] => 2021-08-28
[numberOfBookableSeats] => 9
[itineraries] => Array
(
[0] => stdClass Object
(
[duration] => PT6H50M
[segments] => Array
(
[0] => stdClass Object
(
[departure] => stdClass Object
(
[iataCode] => JFK
[terminal] => 4
[at] => 2021-09-02T08:15:00
)
[arrival] => stdClass Object
(
[iataCode] => LHR
[terminal] => 3
[at] => 2021-09-02T20:05:00
)
[carrierCode] => VS
[number] => 26
[aircraft] => stdClass Object
(
[code] => 789
)
[operating] => stdClass Object
(
[carrierCode] => VS
)
[duration] => PT6H50M
[id] => 3
[numberOfStops] => 0
[blacklistedInEU] =>
)
)
)
[1] => stdClass Object
(
[duration] => PT8H15M
[segments] => Array
(
[0] => stdClass Object
(
[departure] => stdClass Object
(
[iataCode] => LHR
[terminal] => 3
[at] => 2021-09-05T10:10:00
)
[arrival] => stdClass Object
(
[iataCode] => JFK
[terminal] => 4
[at] => 2021-09-05T13:25:00
)
[carrierCode] => VS
[number] => 4007
[aircraft] => stdClass Object
(
[code] => 764
)
[operating] => stdClass Object
(
[carrierCode] => DL
)
[duration] => PT8H15M
[id] => 8
[numberOfStops] => 0
[blacklistedInEU] =>
)
)
)
)
[price] => stdClass Object
(
[currency] => USD
[total] => 709.86
[base] => 122.00
[fees] => Array
(
[0] => stdClass Object
(
[amount] => 0.00
[type] => SUPPLIER
)
[1] => stdClass Object
(
[amount] => 0.00
[type] => TICKETING
)
)
[grandTotal] => 709.86
)
[pricingOptions] => stdClass Object
(
[fareType] => Array
(
[0] => PUBLISHED
)
[includedCheckedBagsOnly] =>
)
[validatingAirlineCodes] => Array
(
[0] => VS
)
[travelerPricings] => Array
(
[0] => stdClass Object
(
[travelerId] => 1
[fareOption] => STANDARD
[travelerType] => ADULT
[price] => stdClass Object
(
[currency] => USD
[total] => 709.86
[base] => 122.00
)
[fareDetailsBySegment] => Array
(
[0] => stdClass Object
(
[segmentId] => 3
[cabin] => ECONOMY
[fareBasis] => NH3X36B1
[brandedFare] => LIGHT
[class] => T
[includedCheckedBags] => stdClass Object
(
[quantity] => 0
)
)
[1] => stdClass Object
(
[segmentId] => 8
[cabin] => ECONOMY
[fareBasis] => NH3X36B1
[brandedFare] => LIGHT
[class] => T
[includedCheckedBags] => stdClass Object
(
[quantity] => 0
)
)
)
)
)
)
)
[dictionaries] => stdClass Object
(
[locations] => stdClass Object
(
[LHR] => stdClass Object
(
[cityCode] => LON
[countryCode] => GB
)
[JFK] => stdClass Object
(
[cityCode] => NYC
[countryCode] => US
)
)
[aircraft] => stdClass Object
(
[772] => BOEING 777-200/200ER
[764] => BOEING 767-400
[77W] => BOEING 777-300ER
[777] => BOEING 777-200/300
[789] => BOEING 787-9
)
[currencies] => stdClass Object
(
[USD] => US DOLLAR
)
[carriers] => stdClass Object
(
[AA] => AMERICAN AIRLINES
[KL] => KLM ROYAL DUTCH AIRLINES
[AF] => AIR FRANCE
[DL] => DELTA AIR LINES
[AY] => FINNAIR
[VS] => VIRGIN ATLANTIC
[BA] => BRITISH AIRWAYS
)
)
)
There is no limit and offset parameter in this API.
Please guide me how to implement pagination using "Flight Offers Search" of Amadeus API.
Thank You
The Flight Offers Search API doesn't support pagination, that's why there are not parameters available to pass the limit and offset in the API reference. Checkout the pagination guide for more information.
I want to show flight's logo images in a flight list using flight offer price API:
https://developers.amadeus.com/self-service/category/air/api-doc/flight-offers-search/api-reference.
I search for flights using origin and destination, one way or round trip, etc. But the flight logo image is not available in the result. Is there a way I can get the flight logo image using the "flight-offers-search" API?
I have used bellow API URL to get flight offer price
This is my request URL
https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAN&destinationLocationCode=LAX&departureDate=2021-07-29&adults=1&travelClass=ECONOMY¤cyCode=USD&max=100
This is my API response. there is no flight logo image available in the response.
stdClass Object
(
[meta] => stdClass Object
(
[count] => 93
[links] => stdClass Object
(
[self] => https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAN&destinationLocationCode=LAX&departureDate=2021-07-29&adults=1&travelClass=ECONOMY¤cyCode=USD&max=100
)
)
[data] => Array
(
[0] => stdClass Object
(
[type] => flight-offer
[id] => 1
[source] => GDS
[instantTicketingRequired] =>
[nonHomogeneous] =>
[oneWay] =>
[lastTicketingDate] => 2021-07-29
[numberOfBookableSeats] => 4
[itineraries] => Array
(
[0] => stdClass Object
(
[duration] => PT29H42M
[segments] => Array
(
[0] => stdClass Object
(
[departure] => stdClass Object
(
[iataCode] => MAN
[terminal] => 1
[at] => 2021-07-29T10:40:00
)
[arrival] => stdClass Object
(
[iataCode] => LIS
[terminal] => 1
[at] => 2021-07-29T13:30:00
)
[carrierCode] => TP
[number] => 1317
[aircraft] => stdClass Object
(
[code] => 32N
)
[operating] => stdClass Object
(
[carrierCode] => TP
)
[duration] => PT2H50M
[id] => 152
[numberOfStops] => 0
[blacklistedInEU] =>
)
[1] => stdClass Object
(
[departure] => stdClass Object
(
[iataCode] => LIS
[terminal] => 1
[at] => 2021-07-29T18:30:00
)
[arrival] => stdClass Object
(
[iataCode] => EWR
[terminal] => B
[at] => 2021-07-29T21:30:00
)
[carrierCode] => TP
[number] => 207
[aircraft] => stdClass Object
(
[code] => 32Q
)
[operating] => stdClass Object
(
[carrierCode] => TP
)
[duration] => PT8H
[id] => 153
[numberOfStops] => 0
[blacklistedInEU] =>
)
[2] => stdClass Object
(
[departure] => stdClass Object
(
[iataCode] => JFK
[terminal] => 5
[at] => 2021-07-30T05:30:00
)
[arrival] => stdClass Object
(
[iataCode] => LAX
[terminal] => 3
[at] => 2021-07-30T08:22:00
)
[carrierCode] => TP
[number] => 4325
[aircraft] => stdClass Object
(
[code] => 32S
)
[operating] => stdClass Object
(
[carrierCode] => B6
)
[duration] => PT5H52M
[id] => 154
[numberOfStops] => 0
[blacklistedInEU] =>
)
)
)
)
[price] => stdClass Object
(
[currency] => USD
[total] => 845.85
[base] => 581.00
[fees] => Array
(
[0] => stdClass Object
(
[amount] => 0.00
[type] => SUPPLIER
)
[1] => stdClass Object
(
[amount] => 0.00
[type] => TICKETING
)
)
[grandTotal] => 845.85
)
[pricingOptions] => stdClass Object
(
[fareType] => Array
(
[0] => PUBLISHED
)
[includedCheckedBagsOnly] => 1
)
[validatingAirlineCodes] => Array
(
[0] => TP
)
[travelerPricings] => Array
(
[0] => stdClass Object
(
[travelerId] => 1
[fareOption] => STANDARD
[travelerType] => ADULT
[price] => stdClass Object
(
[currency] => USD
[total] => 845.85
[base] => 581.00
)
[fareDetailsBySegment] => Array
(
[0] => stdClass Object
(
[segmentId] => 152
[cabin] => ECONOMY
[fareBasis] => LUKBSI0D
[class] => L
[includedCheckedBags] => stdClass Object
(
[quantity] => 1
)
)
[1] => stdClass Object
(
[segmentId] => 153
[cabin] => ECONOMY
[fareBasis] => LUKBSI0D
[class] => L
[includedCheckedBags] => stdClass Object
(
[quantity] => 1
)
)
[2] => stdClass Object
(
[segmentId] => 154
[cabin] => ECONOMY
[fareBasis] => LUKBSI0D
[brandedFare] => BASIC
[class] => L
[includedCheckedBags] => stdClass Object
(
[quantity] => 1
)
)
)
)
)
)
Or anyone know if there are any other api's that I can use to get the logos?
Please help to get flight logo using Amadeus API
I have used Amadeus test API
Thank you
Paypal Commerce platform in php order capture partner is not getting paid and seller is getting full amount. What should I send in order capture?
Below is the array I am sending in 'https://api.paypal.com/v2/checkout/orders'
Array
(
[intent] => CAPTURE
[purchase_units] => Array
(
[0] => Array
(
[reference_id] =>
[description] => Darshan Shah 70099
[custom_id] => 10541
[soft_descriptor] =>
[invoice_id] => SELLERINV-70099
[amount] => Array
(
[currency_code] => USD
[value] => 105
[breakdown] => Array
(
[item_total] => Array
(
[currency_code] => USD
[value] => 100
)
[shipping] => Array
(
[currency_code] => USD
[value] => 5
)
[tax_total] => Array
(
[currency_code] => USD
[value] => 0
)
)
)
[items] => Array
(
[0] => Array
(
[name] => Test Product K
[description] => Test Product K
[unit_amount] => Array
(
[currency_code] => USD
[value] => 50
)
[tax] => Array
(
[currency_code] => USD
[value] => 0
)
[quantity] => 2
[category] => DIGITAL_GOODS
)
)
[payee] => Array
(
[merchant_id] =>
)
[shipping] => Array
(
[name] => Array
(
[full_name] => Darshan Shah
)
[address] => Array
(
[address_line_1] => 5/11 G1 Rajalakshmi Enclave
[address_line_2] =>
[admin_area_2] => Middleton Grange
[admin_area_1] => CON
[postal_code] => 111111
[country_code] => GB
)
)
[payment_instruction] => Array
(
[disbursement_mode] => INSTANT
[platform_fees] => Array
(
[0] => Array
(
[amount] => Array
(
[currency_code] => USD
[value] => 5
)
[payee] => Array
(
[merchant_id] =>
)
)
)
)
)
)
[application_context] => Array
(
[brand_name] =>
[locale] => en-US
[landing_page] => BILLING
[shipping_preference] => GET_FROM_FILE
[user_action] => PAY_NOW
[return_url] =>
[cancel_url] =>
)
)
What data should I send in order capture? 'https://api.paypal.com/v2/checkout/orders//capture'. As currently, I am not sending any data in order capture.
I am using above 2 apis to do checkout and pay both seller and parter. But Only seller is getting full amount, partner is not getting anything!
If have hoped on this kind of issue, please suggest me a solution.
I get an error saying some of my items name are missing, but they are not. I got 2 different cases, but I can't find the explanation. Can anybody help?
Case 1
Is it because of the hyphen?
Request:
PayPalApiPayment Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[intent] => sale
[payer] => PayPalApiPayer Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[payment_method] => credit_card
[funding_instruments] => Array
(
[0] => PayPalApiFundingInstrument Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[credit_card] => PayPalApiCreditCard Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[type] => visa
[number] => 4200000000000000
[expire_month] => 05
[expire_year] => 2018
[cvv2] => 456
[first_name] => Jean-Sébastien
[last_name] => Proulx
)
)
)
)
)
)
)
[transactions] => Array
(
[0] => PayPalApiTransaction Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[amount] => PayPalApiAmount Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[currency] => CAD
[total] => 47.55
[details] => PayPalApiDetails Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[shipping] => 0
[tax] => 1.64
[subtotal] => 45.91
)
)
)
)
[item_list] => PayPalApiItemList Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[items] => Array
(
[0] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => Homme (12 ans et plus) 300m/10km/2,5km
[currency] => CAD
[quantity] => 1
[price] => 35.00
)
)
[1] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => Frais TQ Découverte, Dépasse-toi et U11 et moins
[currency] => CAD
[quantity] => 1
[price] => 2.00
)
)
[2] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => Frais TQ non membre Découverte, Dépasse-toi et U11 et moins
[currency] => CAD
[quantity] => 1
[price] => 5.00
)
)
[3] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => Frais de service MS1
[currency] => CAD
[quantity] => 1
[price] => 3.91
)
)
)
)
)
[description] => Triathlon Nitek Laser de Nicolet 2016 - 9e édition
[invoice_number] => trx_56d07478755d4
)
)
)
)
)
Response
Array
(
[code] => 400
[Message] => Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
[data] => {"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].item_list.items[1].name","issue":"Required field missing"},{"field":"transactions[0].item_list.items[2].name","issue":"Required field missing"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"6da4a541e4d25"}
)
Case 2
Is it because the name begin by a number?
Request
PayPalApiPayment Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[intent] => sale
[payer] => PayPalApiPayer Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[payment_method] => credit_card
[funding_instruments] => Array
(
[0] => PayPalApiFundingInstrument Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[credit_card] => PayPalApiCreditCard Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[type] => visa
[number] => 4222222222222222
[expire_month] => 05
[expire_year] => 2018
[cvv2] => 123
[first_name] => Jean-Sébastien
[last_name] => Proulx
)
)
)
)
)
)
)
[transactions] => Array
(
[0] => PayPalApiTransaction Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[amount] => PayPalApiAmount Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[currency] => CAD
[total] => 92.74
[details] => PayPalApiDetails Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[shipping] => 0
[tax] => 9.22
[subtotal] => 83.52
)
)
)
)
[item_list] => PayPalApiItemList Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[items] => Array
(
[0] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => TRAIL 11 KM
[currency] => CAD
[quantity] => 1
[price] => 55.00
)
)
[1] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => 1 billet invité pour le souper spaghetti
[currency] => CAD
[quantity] => 1
[price] => 7.00
)
)
[2] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => 1 Billet Invité BBQ
[currency] => CAD
[quantity] => 1
[price] => 15.00
)
)
[3] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => T-shirt
[currency] => CAD
[quantity] => 1
[price] => 0.00
)
)
[4] => PayPalApiItem Object
(
[_propMap:PayPalCommonPayPalModel:private] => Array
(
[name] => Frais de service MS1
[currency] => CAD
[quantity] => 1
[price] => 6.52
)
)
)
)
)
[description] => Festival Ultimate Xc Kmag 2016
[invoice_number] => trx_56cf5aed4ba51
)
)
)
)
)
Response
Array
(
[code] => 400
[Message] => Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
[data] => {"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].item_list.items[1].name","issue":"Required field missing"},{"field":"payer.funding_instruments[0].credit_card.number","issue":"Value is invalid"},{"field":"transactions[0].item_list.items[2].name","issue":"Required field missing"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"bf092633bbc19"}
)
Now this is embarrassing.
Typical case of French accents here. UTF-8 FTW.
SOLUTION:
Each of the keys ending :private had a __get() and toJSON() method which is needed to get the data from them as _propMap is private.
I'm using PayPal's PHP API to take payments from PayPal, and the data I get after a payment has been completed, comes back as this
Array
(
[PayPal\Common\PPModel_propMap] => Array
(
[id] => PAY-THEID
[create_time] => 2013-12-03T15:47:15Z
[update_time] => 2013-12-03T15:47:34Z
[state] => approved
[intent] => sale
[payer] => PayPal\Api\Payer Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[payment_method] => paypal
[payer_info] => PayPal\Api\PayerInfo Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[email] => my#email.com
[first_name] => Tom
[last_name] => Hart
[payer_id] => thePayerId
[shipping_address] => PayPal\Api\Address Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[line1] => 1 Main Terrace
[city] => Wolverhampton
[state] => West Midlands
[postal_code] => W12 4LQ
[country_code] => GB
)
)
)
)
)
)
[transactions] => Array
(
[0] => PayPal\Api\Transaction Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[amount] => PayPal\Api\Amount Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[total] => 0.33
[currency] => GBP
[details] => PayPal\Api\Details Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[subtotal] => 0.11
[tax] => 0.11
[shipping] => 0.11
)
)
)
)
[description] => Payment description
[item_list] => PayPal\Api\ItemList Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[items] => Array
(
[0] => PayPal\Api\Item Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[name] => Flowers
[price] => 0.11
[currency] => GBP
[quantity] => 1
)
)
)
)
)
[related_resources] => Array
(
[0] => PayPal\Api\RelatedResources Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[sale] => PayPal\Api\Sale Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[id] => 9L998852HN614082X
[create_time] => 2013-12-03T15:47:15Z
[update_time] => 2013-12-03T15:47:34Z
[state] => completed
[amount] => PayPal\Api\Amount Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[total] => 0.33
[currency] => GBP
)
)
[parent_payment] => PAY-4S184757A49956741KKO72AY
[links] => Array
(
[0] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/sale/9L998852HN614082X
[rel] => self
[method] => GET
)
)
[1] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/sale/abc/refund
[rel] => refund
[method] => POST
)
)
[2] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-abc
[rel] => parent_payment
[method] => GET
)
)
)
)
)
)
)
)
)
)
)
[links] => Array
(
[0] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/abc
[rel] => self
[method] => GET
)
)
)
)
)
I want to convert parts of that (shipping_address being one of them) to a json object (using json_encode/decode(), and store it in my database so in the admin section I can view the address so I know where to send things, however, I can't convert that to a json object, it just returns {}. How can I store these details in my database to view them later?
EDIT:
Json_encode code
$db['address'] = json_encode((array) $dets->payer->payer_info->shipping_address);
var_dump(json_last_error());
$db['payerId'] = $dets->payer->payer_info->payer_id;
$db['prices'] = json_encode((array) $dets->transations[0]->amount);
var_dump(json_last_error());
$db['description'] = $dets->transations[0]->description;
$db['items'] = json_encode((array) $dets->transations[0]->item_list->items);
var_dump(json_last_error());
$db['links'] = json_encode((array) $dets->related_resources[0]->sale->links);
var_dump(json_last_error());
The output of the $db array is
Array
(
[userId] => 10
[paymentId] => PAY-4VC71851RJ180032AKKPAB3Y
[state] => approved
[address] => {"\u0000PayPal\\Common\\PPModel\u0000_propMap":{"line1":"1 Main Terrace","city":"Wolverhampton","state":"West Midlands","postal_code":"W12 4LQ","country_code":"GB"}}
[payerId] => P77LD9M7MUQN2
[prices] => []
[description] =>
[items] => []
[links] => []
)
So some are getting encoded, some arnt.
This was also bothering me for a while and I struggled to find a straightforward answer. I'm using the current PHP REST STK and in the sample ExecutePayment.php file saw something like this:
// Execute the payment
// (See bootstrap.php for more on `ApiContext`)
$result = $payment->execute($execution, $apiContext);
echo "<html><body><pre>";
var_dump($result);
echo "</pre><a href='../index.html'>Back</a></body></html>";
As noted, the $result object is not very helpful to navigate. You can't directly encode the object as PayPal is doing some crazy stuff on their own in the SDK. As noted, the solution is to use the toJSON() method from the PPModal class to convert that object into JSON directly:
$result = $payment->execute($execution, $apiContext);
$array = $result->toJSON();
echo '<pre>';
print_r($array);
echo '</pre>';
I hope that's a little clearer to somebody.
I think the problem you are having with some values "not being encoded" is that some of your variable references are wrong.
For example, you are trying to encode:
$dets->transations[0]->amount
Whereas, I think you need to get that value from:
$dets->transactions[0]['_propMap:PayPal\Common\PPModel:private']['amount']
You have similar issue for most of your variable references.