PHP paypal commerce platform(api v2) partner is not getting paid? - php

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.

Related

Get inner part of Array PHP

How do I get inner part of a long array in PHP :
Example:
print_r($array) gives:
Razorpay\Api\Collection Object
(
[attributes:protected] => Array
(
[entity] => collection
[count] => 1
[items] => Array
(
[0] => Razorpay\Api\Payment Object
(
[attributes:protected] => Array
(
[id] => payid
[entity] => payment
[amount] => 1000
[currency] => INR
[status] => captured
[order_id] => orderid
[invoice_id] =>
[international] =>
[method] => card
[amount_refunded] => 0
[refund_status] =>
[captured] => 1
[description] => D.
[card_id] => id
[bank] =>
[wallet] =>
[vpa] =>
[email] => example#example.com
[contact] => +91
[notes] => Razorpay\Api\Payment Object
(
[attributes:protected] => Array
(
[address] => add
[merchant_order_id] => orid
)
)
[fee] => 20
[tax] => 0
[error_code] =>
[error_description] =>
[created_at] => 1580641472
)
)
)
)
)
This is Razorpay Payment details returned.
How do I get id and other innermost items from this array
I want to get id and status and check if status is captured or failed to verify the payment, but, I can't get it anyway. Please help
Finally Got:
$payment = $api->order->fetch($_POST["razorpayorderid"])->payments();
$payid = $payment["items"][0]["id"];

How to retrieve object from xml

I am trying to get the value of bank_name in php. Can't get it to display.
stdClass Object ( [account_id] => 43726384 [name] => Account Name [state] => action_required [description] => [owner_user_id] =>[type] => personal [create_time] => 1477684534 [disablement_time] => [country] => US [currencies] => Array ( [0] => USD ) [action_reasons] => Array ( [0] => kyc [1] => bank_account ) [disabled_reasons] => Array ( ) [image_uri] => [supported_card_types] => Array ( [0] => visa [1] => mastercard [2] => american_express [3] => discover [4] => jcb [5] => diners_club ) [gaq_domains] => Array ( [0] => ) [balances] => Array ( [0] => stdClass Object ( [balance] => 0 [currency] => USD [disputed_amount] => 0 [incoming_pending_amount] => 0 [outgoing_pending_amount] => 0 [reserved_amount] => 0 [bank_name] => Bank Of America [withdrawal_next_time] => [withdrawal_period] => [withdrawal_type] => ) ) [statuses] => Array ( [0] => stdClass Object ( [currency] => USD [incoming_payments_status] => ok [outgoing_payments_status] => paused [account_review_status] => not_requested ) ) )
It's not very clear if you display data that way, but I think this would be the way to access to bank_name:
$bankName = $object->balances[0]->bank_name;
(If it doesn't work, please show the XML before parsing it to an object)

Paypal REST API item_list required field missing

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.

UPS Shipping API Integration Error (PHP)

I download the ShippingGroundFreightWebService PHP examples from UPS.com. I got following error message:
SoapFault Object
(
[message:protected] => An exception has been raised as a result of client data.
[string:private] =>
[code:protected] => 0
[file:protected] => /home5/vizparts/public_html/PHP/SoapGroundFreightShipClient.php
[line:protected] => 193
[trace:private] => Array
(
[0] => Array
(
[file] => /home5/vizparts/public_html/PHP/SoapGroundFreightShipClient.php
[line] => 193
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => ProcessShipment
[1] => Array
(
[0] => Array
(
[Request] => Array
(
[RequestOption] => Array
(
[0] => 1
[1] => Shipping
)
)
[Shipment] => Array
(
[ShipFrom] => Array
(
[Name] => Pat Stewart
[TaxIdentification] => 1234567890
[Address] => Array
(
[AddressLine] => 2311 York Road
[City] => Timonium
[StateProvinceCode] => MD
[PostalCode] => 21093
[CountryCode] => US
)
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
[Extension] => 123
)
)
[ShipperNumber] => 222006
[ShipTo] => Array
(
[Name] => Superman
[Address] => Array
(
[AddressLine] => 2010 Warsaw Road
[StateProvinceCode] => GA
[PostalCode] => 30076
[CountryCode] => US
[City] => Roswell
)
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
[Extention] => 111
)
)
[PaymentInformation] => Array
(
[Payer] => Array
(
[Name] => Superman
[Address] => Array
(
[AddressLine] => 2010 Warsaw Road
[City] => Roswell
[StateProvinceCode] => GA
[PostalCode] => 30075
[CountryCode] => US
)
[ShipperNumber] => 00613270
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
)
)
[ShipmentBillingOption] => Array
(
[Code] => 10
[Description] => String
)
)
[Service] => Array
(
[Code] => 308
[Description] => String
)
[HandlingUnitOne] => Array
(
[Quantity] => 16
[Type] => Array
(
[Code] => PLT
[Description] => String
)
)
[Commodity] => Array
(
[CommodityID] => 22
[Description] => BUGS
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => String
)
[Value] => 511.25
)
[Dimensions] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => IN
[Description] => String
)
[Length] => 1.25
[Width] => 1.2
[Height] => 5
)
[NumberOfPieces] => 1
[PackagingType] => Array
(
[Code] => PLT
[Description] => String
)
[CommodityValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 265.2
)
[FreightClass] => 60
[NMFCCommodityCode] => 566
)
[Reference] => Array
(
[Number] => Array
(
[Code] => PM
[Value] => 1651651616
)
[BarCodeIndicator] => Array
(
[NumberOfCartons] => 5
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => String
)
[Value] => 2
)
)
)
)
)
)
)
)
)
[faultstring] => An exception has been raised as a result of client data.
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
[detail] => stdClass Object
(
[Errors] => stdClass Object
(
[ErrorDetail] => stdClass Object
(
[Severity] => Hard
[PrimaryErrorCode] => stdClass Object
(
[Code] => 9121000
[Description] => Invalid Ship Request Document
)
)
)
)
)
I want to integrate the UPS API into my own website. I want to print the shipping label. How to fix this problem?
you should set the request xsd file,find it in other folder in the package you download.then set the request file with it.

UPS API Error: Invalid Ship Request Document

I'm trying to run the PHP test for the UPS Freight Shipping API that came with the official UPS SDK. I finally got it to connect to the SOAP service with a correct username, password, and API key, but now I'm getting an error that I don't know how to solve. The error coming back from the server is
Invalid Ship Request Document
The full response from the server looks like this:
SoapFault Object
(
[message:protected] => An exception has been raised as a result of client data.
[string:private] =>
[code:protected] => 0
[file:protected] => /my_home_dir/UPS_API/test.php
[line:protected] => 224
[trace:private] => Array
(
[0] => Array
(
[file] => /my_home_dir/UPS_API/test.php
[line] => 224
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => ProcessFreightRate
[1] => Array
(
[0] => Array
(
[Request] => Array
(
[RequestOption] => RateChecking Option
)
[ShipFrom] => Array
(
[Name] => Good Incorporation
[Address] => Array
(
[AddressLine] => 2010 WARSAW ROAD
[City] => Roswell
[StateProvinceCode] => GA
[PostalCode] => 30076
[CountryCode] => US
)
)
[ShipTo] => Array
(
[Name] => Sony Company Incorporation
[Address] => Array
(
[AddressLine] => 2311 YORK ROAD
[City] => TIMONIUM
[StateProvinceCode] => MD
[PostalCode] => 21093
[CountryCode] => US
)
)
[PaymentInformation] => Array
(
[Payer] => Array
(
[Name] => Payer inc
[Address] => Array
(
[AddressLine] => 435 SOUTH STREET
[City] => RIS TOWNSHIP
[StateProvinceCode] => NJ
[PostalCode] => 07960
[CountryCode] => US
)
)
[ShipmentBillingOption] => Array
(
[Code] => 10
[Description] => PREPAID
)
)
[Service] => Array
(
[Code] => 308
[Description] => UPS Freight LTL
)
[HandlingUnitOne] => Array
(
[Quantity] => 20
[Type] => Array
(
[Code] => PLT
[Description] => PALLET
)
)
[Commodity] => Array
(
[CommodityID] =>
[Description] => No Description
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => Pounds
)
[Value] => 750
)
[Dimensions] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => IN
[Description] => Inches
)
[Length] => 23
[Width] => 17
[Height] => 45
)
[NumberOfPieces] => 45
[PackagingType] => Array
(
[Code] => BAG
[Description] => BAG
)
[DangerousGoodsIndicator] =>
[CommodityValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 5670
)
[FreightClass] => 60
[NMFCCommodityCode] =>
)
[ShipmentServiceOptions] => Array
(
[PickupOptions] => Array
(
[HolidayPickupIndicator] =>
[InsidePickupIndicator] =>
[ResidentialPickupIndicator] =>
[WeekendPickupIndicator] =>
[LiftGateRequiredIndicator] =>
)
[OverSeasLeg] => Array
(
[Dimensions] => Array
(
[Volume] => 20
[UnitOfMeasurement] => Array
(
[Code] => CF
[Description] => String
)
)
[Value] => Array
(
[Cube] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 5670
)
)
[COD] => Array
(
[CODValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 363
)
[CODPaymentMethod] => Array
(
[Code] => M
[Description] => For Company Check
)
[CODBillingOption] => Array
(
[Code] => 01
[Description] => Prepaid
)
[RemitTo] => Array
(
[Name] => RemitToSomebody
[Address] => Array
(
[AddressLine] => 640 WINTERS AVE
[City] => PARAMUS
[StateProvinceCode] => NJ
[PostalCode] => 07652
[CountryCode] => US
)
[AttentionName] => C J Parker
)
)
[DangerousGoods] => Array
(
[Name] => Very Safe
[Phone] => Array
(
[Number] => 453563321
[Extension] => 1111
)
[TransportationMode] => Array
(
[Code] => CARGO
[Description] => Cargo Mode
)
)
[SortingAndSegregating] => Array
(
[Quantity] => 23452
)
[CustomsValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 23457923
)
[HandlingCharge] => Array
(
[Amount] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 450
)
)
)
)
)
)
)
)
)
[faultstring] => An exception has been raised as a result of client data.
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
[detail] => stdClass Object
(
[Errors] => stdClass Object
(
[ErrorDetail] => stdClass Object
(
[Severity] => Hard
[PrimaryErrorCode] => stdClass Object
(
[Code] => 9121000
[Description] => Invalid Ship Request Document
)
)
)
)
)
The code that I am using to make the request can be found here (credentials have been removed for security): http://pastebin.com/Yw7sPQdg
Turns out that I was pointing to the wrong end point. The endpoint url for freight rates should be: https://wwwcie.ups.com/webservices/FreightRate

Categories