PHP insert mysql array from paypal response - php

I'm trying to get transaction details of a PayPal account, which I was successfully in doing so, but I get this long (what i assume is an array) and I need to insert the details into a MySQL database. I've tried several foreach methods but apparently I am doing something wrong.
This is the reponse from PayPal after successful request (stored as $httpParsedResponse)
TransactionSearch Completed Successfully: Array (
[L_TIMESTAMP0] => 2012%2d08%2d14T18%3a46%3a00Z
[L_TIMESTAMP1] => 2012%2d08%2d14T18%3a45%3a32Z
[L_TIMESTAMP2] => 2012%2d08%2d13T01%3a45%3a48Z
[L_TIMESTAMP3] => 2012%2d08%2d13T01%3a34%3a12Z
[L_TIMEZONE0] => GMT
[L_TIMEZONE1] => GMT
[L_TIMEZONE2] => GMT
[L_TIMEZONE3] => GMT
[L_TYPE0] => Payment
[L_TYPE1] => Payment
[L_TYPE2] => Payment
[L_TYPE3] => Transfer
[L_EMAIL0] => pmd_1333866_per%40yahoo%2ecom
[L_EMAIL1] => pmd_1333866_per%40yahoo%2ecom
[L_EMAIL2] => pmd_1333866_per%40yahoo%2ecom
[L_NAME0] => Joshua%20O
[L_NAME1] => Joshua%20O
[L_NAME2] => Joshua%20O
[L_NAME3] => PayPal
[L_TRANSACTIONID0] => 58289472YK615973G
[L_TRANSACTIONID1] => 4U113116FL1819900
[L_TRANSACTIONID2] => 2X978155KR373471P
[L_TRANSACTIONID3] => 3TH38971MF599302V
[L_STATUS0] => Completed
[L_STATUS1] => Completed
[L_STATUS2] => Completed
[L_STATUS3] => Completed
[L_AMT0] => %2d100%2e00
[L_AMT1] => %2d50%2e00
[L_AMT2] => %2d200%2e00
[L_AMT3] => 2000%2e00
[L_CURRENCYCODE0] => USD
[L_CURRENCYCODE1] => USD
[L_CURRENCYCODE2] => USD
[L_CURRENCYCODE3] => USD
[L_FEEAMT0] => 0%2e00
[L_FEEAMT1] => 0%2e00
[L_FEEAMT2] => 0%2e00
[L_FEEAMT3] => 0%2e00
[L_NETAMT0] => %2d100%2e00
[L_NETAMT1] => %2d50%2e00
[L_NETAMT2] => %2d200%2e00
[L_NETAMT3] => 2000%2e00
[TIMESTAMP] => 2012%2d08%2d25T17%3a59%3a01Z
[CORRELATIONID] => bf5b1a824d937
[ACK] => Success
[VERSION] => 51%2e0
[BUILD] => 3435050
)
Obviously enough I guess the array is structured as
[L_TIMESTAMP0]
[L_TIMESTAMP1]
[L_TIMESTAMP2]
and this continues for how ever many sets of transaction details there are for each set, ie timestamp, timezone, type, email, ect...
In this case there are 3 sets of transaction details but whatever solution needs to be able to loop through it wheither there is only 1 transaction pulled or 100.
Like I said the only goal here is to take this returned array from PayPal and insert into a MySQL database.
I hope this makes sense, any help at all would be greatly appreciated! Thanks!
Im sorry I had to edit my old question because im a newbie I guess - At any rate I think your code helped organize it a bit better, this is now the response I get... still confused on how to insert it into a mysql database tho...
Array ( [0] => Array ( [timestamp] => 2012%2d08%2d14T18%3a46%3a00Z
[timezone] => GMT
[type] => Payment
[email] => pmd_1333866_per%40yahoo%2ecom
[name] => Joshua%20O
[transactionid] => 58289472YK615973G
[status] => Completed
[amt] => %2d100%2e00
[feeamt] => 0%2e00
[netamt] => %2d100%2e00 )
[1] => Array ( [timestamp] => 2012%2d08%2d14T18%3a45%3a32Z
[timezone] => GMT
[type] => Payment
[email] => pmd_1333866_per%40yahoo%2ecom
[name] => Joshua%20O
[transactionid] => 4U113116FL1819900
[status] => Completed
[amt] => %2d50%2e00
[feeamt] => 0%2e00
[netamt] => %2d50%2e00 )
[2] => Array ( [timestamp] => 2012%2d08%2d13T01%3a45%3a48Z
[timezone] => GMT
[type] => Payment
[email] => pmd_1333866_per%40yahoo%2ecom
[name] => Joshua%20O
[transactionid] => 2X978155KR373471P
[status] => Completed
[amt] => %2d200%2e00
[feeamt] => 0%2e00
[netamt] => %2d200%2e00 )
[3] => Array ( [timestamp] => 2012%2d08%2d13T01%3a34%3a12Z
[timezone] => GMT
[type] => Transfer
[email] =>
[name] => PayPal
[transactionid] => 3TH38971MF599302V
[status] => Completed
[amt] => 2000%2e00
[feeamt] => 0%2e00
[netamt] => 2000%2e00 ) )

Two ideas are:
$numOfTransactions=intval((count($response)-5)/11);
where 5 is the number of values not duplicated for each transaction and 11 is the number of values for each transaction. This depends on the structure being reliable.
OR
$numOfTransactions=0;
foreach ($response as $key=>$value){
$check=strpos($key,'L_TIMESTAMP');
if ($check===false) break;
$numOfTransactions++;
}
Then you can loop through the response to structure your data
for ($i=0;$i<$numOfTransactions;$i++){
$data[$i]=array("timestamp"=>$response['L_TIMESTAMP'.$i],"timezone"=>$response['L_TIMEZONE'.$i]...);
}

Related

Get invoice data with Xero API - Private App

I am trying to build an online form that a user can enter their invoice number, the webserver will then interface with the Xero API to GET the invoice details and populate some additional fields for payment.
I have already got the form logic built and in place however I have no clue of how to start with the Xero API.
I've created a private app and have the required keys but I cannot find any documentation on how to actually go about setting up the API call in PHP.
Any help would be much appreciated.
**** UPDATE ****
I was able to get the API working using the following:
function GetInvData ($InvNumber) {
try {
$config = [
'oauth' => [
'consumer_key' => 'REDACTED',
'rsa_private_key' => 'REDACTED',
],
];
$xero = new PrivateApplication($config);
//$invoice = $xero->load(\XeroPHP\Models\Accounting\Invoice::class)->where('InvoiceNumber',$InvNumber)->execute();
$invoice = $xero->load('Accounting\Invoice')
->where('InvoiceNumber',$InvNumber)
->execute();
}
catch(\Exception $ex) {
var_dump($ex);
}
return ($invoice);
}
However what is returned is the most complex piece of JSON I have ever laid eyes on.... Probably not saying much.
All I need to be able to extract is the the Invoice Amount, The Customer name and Their email address, can anybody assist with this?
XeroPHP\Remote\Collection Object
(
[_associated_objects:protected] =>
[storage:ArrayObject:private] => Array
(
[0] => XeroPHP\Models\Accounting\Invoice Object
(
[_data:protected] => Array
(
[Type] => ACCREC
[Contact] => XeroPHP\Models\Accounting\Contact Object
(
[_data:protected] => Array
(
[ContactID] => cf6eef48-cda3-4862-8518-4d631ea54c1c
[ContactNumber] =>
[AccountNumber] =>
[ContactStatus] =>
[Name] => REDACTED
[FirstName] =>
[LastName] =>
[EmailAddress] =>
[SkypeUserName] =>
[ContactPersons] =>
[BankAccountDetails] =>
[TaxNumber] =>
[AccountsReceivableTaxType] =>
[AccountsPayableTaxType] =>
[Addresses] =>
[Phones] =>
[IsSupplier] =>
[IsCustomer] =>
[DefaultCurrency] =>
[XeroNetworkKey] =>
[SalesDefaultAccountCode] =>
[PurchasesDefaultAccountCode] =>
[SalesTrackingCategories] =>
[PurchasesTrackingCategories] =>
[TrackingCategoryName] =>
[TrackingCategoryOption] =>
[PaymentTerms] =>
[UpdatedDateUTC] =>
[ContactGroups] =>
[Website] =>
[BrandingTheme] =>
[BatchPayments] =>
[Discount] =>
[Balances] =>
[HasAttachments] =>
)
[_dirty:protected] => Array
(
)
[_associated_objects:protected] => Array
(
[Contact] => XeroPHP\Models\Accounting\Invoice Object
*RECURSION*
)
[_application:protected] =>
)
[LineItems] =>
[Date] => DateTime Object
(
[date] => 2019-03-05 00:00:00.000000
[timezone_type] => 3
[timezone] => Australia/Melbourne
)
[DueDate] => DateTime Object
(
[date] => 2019-03-12 00:00:00.000000
[timezone_type] => 3
[timezone] => Australia/Melbourne
)
[LineAmountTypes] => Exclusive
[InvoiceNumber] => Inv-1521
[Reference] => Feb 2019
[BrandingThemeID] => c560d364-0331-4677-a529-8ce702559165
[Url] =>
[CurrencyCode] => AUD
[CurrencyRate] => 1
[Status] => AUTHORISED
[SentToContact] => 1
[ExpectedPaymentDate] =>
[PlannedPaymentDate] =>
[SubTotal] => 2150
[TotalTax] => 215
[Total] => 2365
[TotalDiscount] =>
[InvoiceID] => f5cfaed4-db9b-41f3-94e5-a025c2bc898a
[HasAttachments] =>
[Payments] =>
[Prepayments] =>
[Overpayments] =>
[AmountDue] => 2365
[AmountPaid] => 0
[FullyPaidOnDate] =>
[AmountCredited] => 0
[UpdatedDateUTC] => DateTime Object
(
[date] => 2019-03-05 00:32:01.813000
[timezone_type] => 3
[timezone] => UTC
)
[CreditNotes] =>
)
[_dirty:protected] => Array
(
)
[_associated_objects:protected] => Array
(
)
[_application:protected] => XeroPHP\Application\PrivateApplication Object
(
[config:protected] => Array
(
[xero] => Array
(
[site] => https://api.xero.com
[base_url] => https://api.xero.com
[core_version] => 2.0
[payroll_version] => 1.0
[file_version] => 1.0
[model_namespace] => \XeroPHP\Models
)
[oauth] => Array
(
[signature_method] => RSA-SHA1
[signature_location] => header
[authorize_url] => https://api.xero.com/oauth/Authorize
[request_token_path] => oauth/RequestToken
[access_token_path] => oauth/AccessToken
[consumer_key] => REDACTED
[rsa_private_key] => REDACTED
[token] => REDACTED
)
[curl] => Array
(
[10018] => XeroPHP
[78] => 30
[13] => 20
[64] => 2
[81] => 2
[52] =>
[10004] =>
[10006] =>
[10102] =>
)
)
[oauth_client:protected] => XeroPHP\Remote\OAuth\Client Object
(
[config:XeroPHP\Remote\OAuth\Client:private] => Array
(
[signature_method] => RSA-SHA1
[signature_location] => header
[authorize_url] => https://api.xero.com/oauth/Authorize
[request_token_path] => oauth/RequestToken
[access_token_path] => oauth/AccessToken
[consumer_key] => REDACTED
[rsa_private_key] => REDACTED
[token] => REDACTED
)
[token_secret:XeroPHP\Remote\OAuth\Client:private] =>
[verifier:XeroPHP\Remote\OAuth\Client:private] =>
)
)
)
)
)
You're pretty much asking how to do the whole thing which people don't take kindly to here. Good job getting the API call done, it might take a while before you completely understand what goes on with each line but it's not required.
Now that you've got that part done you just need to work with the data that Xero gives you back, well rather what xero-php (which is the library you're using) gives you back. What you've posted is not JSON, it's just a dump (text representation) of the data as it exists as an object in your code.
That object is a Collection of Invoices, but it's just a singular invoice in your case. It will always return a Collection even if you have really specific search queries, but you can always make yourself a little check to make sure the Collection only has one invoice if you're only expecting one.
So, for what you actually want (Invoice Amount, The Customer name and Their email address), here's the next lines of code.
Invoice Amount:
$invoice->Invoices[0]->Total;
Customer Name:
$invoice->Invoices[0]->Contact->Name;
Email Address:
$invoice->Invoices[0]->Contact->EmailAddress;
Invoices[0] is used to grab the first Invoice in the Collection, so it assumes there's only one. Hopefully that points you in the right direction.
Ended up Getting it working with the following:
function GetInvData ($InvNumber) {
global $xero;
$return = array('AmountDue' => null, 'Customer' => null, 'EmailAddress' => null);
try {
//throw new Exception("Test");
$invoices = $xero->load(Accounting\Invoice::class)
->where('InvoiceNumber',$InvNumber)
->where('Status', 'AUTHORISED')
->execute();
$invoice = $invoices->first();
if(empty($invoice)){
$return = '';
}
else {
$invoiceCount = count($invoice);
if($invoiceCount > 1) {
throw new \Exception("Managed to find [" . $invoiceCount . "] with Invoice ID [" . $InvNumber . "]. Expected this to be unique.");
}
$contact = $invoice->getContact();
$return['AmountDue'] = $invoice->getAmountDue();
$return['Customer'] = $contact->getName();
$return['EmailAddress'] = $contact->getEmailAddress();
}
}
catch(\Exception $ex) {
$return = LogException($ex);
}
return $return;
}
Thanks everyone for the assistance.

get specific data in array php

i have this array:
Array
(
[0] => stdClass Object
(
[MarketCurrency] => LTC
[BaseCurrency] => BTC
[MarketCurrencyLong] => Litecoin
[BaseCurrencyLong] => Bitcoin
[MinTradeSize] => 0.03039514
[MarketName] => BTC-LTC
[IsActive] => 1
[IsRestricted] =>
[Created] => 2014-02-13T00:00:00
[Notice] =>
[IsSponsored] =>
[LogoUrl] => https://bittrexblobstorage.blob.core.windows.net/public/6defbc41-582d-47a6-bb2e-d0fa88663524.png
)
[1] => stdClass Object
(
[MarketCurrency] => DOGE
[BaseCurrency] => BTC
[MarketCurrencyLong] => Dogecoin
[BaseCurrencyLong] => Bitcoin
[MinTradeSize] => 462.96296296
[MarketName] => BTC-DOGE
[IsActive] => 1
[IsRestricted] =>
[Created] => 2014-02-13T00:00:00
[Notice] =>
[IsSponsored] =>
[LogoUrl] => https://bittrexblobstorage.blob.core.windows.net/public/a2b8eaee-2905-4478-a7a0-246f212c64c6.png
)
}
I would get the "MarketCurrency" data and "BaseCurrency" data. But I don't know how to do.
How can I do this?
I need your help.
You can do it with simple foreach() to grab the objects.
foreach($data as $obj){
echo "MarketCurrency = $obj->MarketCurrency and BaseCurrency = $obj->BaseCurrency".PHP_EOL;
}

How to know when a customer charged for his subscription in Chargify

I am using Chargify API (https://github.com/jforrest/Chargify-PHP-Client/), we have customers in thousands with monthly subscription, so they charged on their specific dates, i am using a cron which checks subscriptions on daily basis
Problem is we miss a subscription if it could not charged on date which suppose to be charged. Some time customer card could not charged due to no funds in their account or any reason happened with their cards which causes few days delay.
I want to know when a customer card charged in chargify so i can generate a new order that time, i have used above PHP Library but could not found a function which get me info.
Can any one help for this or any other solution to fix this ?
Thanks
Chargify has a feature specifically this called "Webhooks" (just like Paypal, Stripe, etc). Whenever there is activity on a customer's subscription (like a monthly renewal), Chargify will send a POST request directly to your server to alert you to it.
The specific documentation is here: https://docs.chargify.io/webhooks
No cron job necessary!
You can setup by webhook and get all the information immediately once customer charged and for that you need to setup webhook url on your server and then add it to chargify account, after login go to Settings -> Webhooks -> Add url for example:
http://www.domain.com/webhooks/
Create index.php file under "webhooks" directory and you will be getting an array from chargify like this:
Array
(
[id] => 29660474
[event] => renewal_success
[payload] => Array
(
[subscription] => Array
(
[activated_at] => 2014-12-12 06:11:51 -0500
[balance_in_cents] => 1900
[cancel_at_end_of_period] => false
[canceled_at] =>
[cancellation_message] =>
[created_at] => 2014-12-12 06:11:40 -0500
[current_period_ends_at] => 2015-02-12 06:11:40 -0500
[expires_at] =>
[id] => 7231335
[next_assessment_at] => 2015-02-12 06:11:40 -0500
[payment_collection_method] => automatic
[snap_day] =>
[state] => active
[trial_ended_at] =>
[trial_started_at] =>
[updated_at] => 2015-01-12 06:22:21 -0500
[current_period_started_at] => 2015-01-12 06:11:40 -0500
[previous_state] => active
[signup_payment_id] => 78110242
[signup_revenue] => 19.00
[delayed_cancel_at] =>
[coupon_code] =>
[total_revenue_in_cents] => 1900
[product_price_in_cents] => 1900
[product_version_number] => 6
[payment_type] => credit_card
[customer] => Array
(
[address] => xx xxxx place Success
[address_2] =>
[city] => Perth
[country] => AU
[created_at] => 2014-12-12 06:11:39 -0500
[email] => xxxxxxx#hotmail.com
[first_name] => Jay
[id] => 7093037
[last_name] => Gable
[organization] => Large
[phone] => xxxxxxxx
[portal_customer_created_at] => 2014-12-12 06:11:52 -0500
[portal_invite_last_accepted_at] =>
[portal_invite_last_sent_at] =>
[reference] => 548acd6a8ef3a
[state] => WA
[updated_at] => 2014-12-12 06:11:52 -0500
[verified] => false
[zip] => 6164
)
[product] => Array
(
[accounting_code] =>
[archived_at] =>
[created_at] => 2014-08-11 03:27:20 -0400
[description] => xxxx
[expiration_interval] =>
[expiration_interval_unit] => never
[handle] => monthly-subscription
[id] => 3493985
[initial_charge_in_cents] =>
[interval] => 1
[interval_unit] => month
[name] => 1 Pair Monthly
[price_in_cents] => 1900
[request_credit_card] => true
[require_credit_card] => true
[return_params] =>
[return_url] =>
[taxable] => false
[trial_interval] =>
[trial_interval_unit] => month
[trial_price_in_cents] =>
[update_return_url] =>
[updated_at] => 2014-12-11 17:09:41 -0500
[product_family] => Array
(
[accounting_code] =>
[description] => Standard Monthly Subscriptions
[handle] => monthly-subscription
[id] => 421701
[name] => Australia
)
[public_signup_pages] => Array
(
[id] => 100806
[url] => xx
)
)
[credit_card] => Array
(
[billing_address] => xxxxx Success
[billing_address_2] =>
[billing_city] => Perth
[billing_country] => AU
[billing_state] => WA
[billing_zip] => 6164
[card_type] => master
[current_vault] => braintree_blue
[customer_id] => 7093037
[customer_vault_token] =>
[expiration_month] => 2
[expiration_year] => 2015
[first_name] => XXXX
[id] => 4693476
[last_name] => Gable
[masked_card_number] => XXXX-XXXX-XXXX-xxxx
[vault_token] => xxxxxx
[payment_type] => credit_card
)
)
[site] => Array
(
[id] => xxxxx
[subdomain] => xxxxx
)
)
)
I hope this helps.
Easiest way would be to store last successful transaction date in DB and check frequently if a month has passed since last update with cron or mysql events scheduler, never used chargify but paypal api can communicate with your server and return status of transaction, which you can use on your site to update DB

Why do I get 2 hits with different data from PayPal's IPN?

After I make a simple web transaction on my site, my IPN handler recieves not just the one expected 'completed' hit, but 2 hits. Each with different data. The first looks like this:
stdClass Object
(
[transaction] => Array
(
[0] => stdClass Object
(
[invoiceId] => PVIFmMOZTm2xkjbs
[id_for_sender_txn] => 3M760109N8943254L
[receiver] => me#gmail.com
[is_primary_receiver] => false
[id] => 08B29244UF9480324
[status] => Completed
[paymentType] => GOODS
[status_for_sender_txn] => Completed
[pending_reason] => NONE
[amount] => GBP 50.00
)
)
[payment_request_date] => Wed Sep 18 12:55:36 PDT 2013
[return_url] => http://mysite.com/checkout/paypal-overlay-state/complete
[fees_payer] => EACHRECEIVER
[ipn_notification_url] => http://mysite.com/ipn
[sender_email] => buyer#gmail.co.uk
[verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31ASUp2KT0F-R3d2QqGIzfWpkS.gWz
[test_ipn] => 1
[cancel_url] => http://mysite.com/checkout/paypal-overlay-state/cancel
[pay_key] => AP-4V279017Y7501703X
[action_type] => PAY
[memo] => SOMETHING
[transaction_type] => Adaptive Payment PAY
[tracking_id] => PVIFmMOZTm2xkjbs
[status] => COMPLETED
[log_default_shipping_address_in_transaction] => false
[charset] => windows-1252
[notify_version] => UNVERSIONED
[reverse_all_parallel_payments_on_error] => false
)
the second looks like this:
stdClass Object
(
[mc_gross] => 50.00
[invoice] => PVIFmMOZTm2xkjbs
[protection_eligibility] => Ineligible
[payer_id] => NRQL7RKB54XWY
[tax] => 0.00
[payment_date] => 12:57:41 Sep 18, 2013 PDT
[payment_status] => Completed
[charset] => windows-1252
[first_name] => Ashley
[mc_fee] => 1.90
[notify_version] => 3.7
[custom] =>
[payer_status] => unverified
[business] => me#gmail.com
[quantity] => 0
[verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31AJGmBkDrCSx-mp-dKf5.Wc6co3ra
[payer_email] => payer#gmail.co.uk
[memo] => SOMETHING
[txn_id] => 08B29244UF9480324
[payment_type] => instant
[last_name] => Ward
[receiver_email] => me#gmail.com
[payment_fee] =>
[receiver_id] => XSSCKHZJZRBDQ
[txn_type] => web_accept
[item_name] =>
[mc_currency] => GBP
[item_number] =>
[residence_country] => GB
[test_ipn] => 1
[receipt_id] => 2722-5250-1650-6726
[transaction_subject] =>
[payment_gross] =>
[ipn_track_id] => a503d9ea64b1e
)
How do I make sense of this data? Why are there 2 hits? and which is the one I need to look out for?
The array shown is a direct print out of the PHP $_POST array for each request. You can see from the timestamps that the one IPN arrives slightly before the second.
EDIT:
I have come to the understanding that the first array (first IPN hit), is an additional reciept you get when you are using the Adaptive Payments API.
For most use cases, I believe this can be ignored, as the second IPN hit contains all the useful data you will need.
Although one caveat is that the second, more useful,IPN array comes 2 mins after the first. The first IPN hit arrives immediately after the payment is processed, while the second does not come until 2 mins after this... not sure why this is...
Thanks!
The problem is with your initial definition of an hit I believe. Or you may defined a variable incorrectly which is why you are getting 2 hits

PayPal Adaptive Payments refund Issue

I'm trying to refund an adaptive payment chained payment totally to the sender, but I'm stuck. I'm using CodeIgniter and Andrew Angell's awesome library for adaptive payments.
The refund I want to make has details like this: (you can see the raw xml requests and responds below)
Array
(
[Errors] => Array
(
)
[Ack] => Success
[Build] => 5472483
[CorrelationID] => 4d31bf900a109
[Timestamp] => 2013-03-20T09:45:02.585-07:00
[ActionType] => PAY_PRIMARY
[CancelURL] => http://my-cancel-url.com
[CurrencyCode] => TRY
[FeesPayer] => PRIMARYRECEIVER
[FundingTypes] => Array
(
)
[IPNNotificationURL] =>
[Memo] =>
[PayKey] => my-paykey
[PaymentInfo] => Array
(
[PendingRefund] => false
[RefundAmount] => 0.00
[SenderTransactionID] =>
[SenderTransactionStatus] => COMPLETED
[TransactionID] => my-transaction-id
[TransactionStatus] => COMPLETED
)
[PreapprovalKey] =>
[ReturnURL] => http://success-url-area.com
[ReverseAllParallelPaymentsOnError] => false
[SenderEmail] => sender#email.com
[Status] => INCOMPLETE
[TrackingID] =>
[Receiver] => Array
(
[Amount] => 5.00
[Email] => receiver#email.com
[InvoiceID] =>
[PaymentType] => SERVICE
[Primary] => true
)
[XMLRequest] => <?xml version="1.0" encoding="utf-8"?><PaymentDetailsRequest xmlns="http://svcs.paypal.com/types/ap"><requestEnvelope xmlns=""><detailLevel>ReturnAll</detailLevel><errorLanguage>en_US</errorLanguage></requestEnvelope><payKey xmlns="">my-paykey</payKey></PaymentDetailsRequest>
[XMLResponse] => <?xml version='1.0' encoding='UTF-8'?><ns2:PaymentDetailsResponse xmlns:ns2="http://svcs.paypal.com/types/ap"><responseEnvelope><timestamp>2013-03-20T09:45:02.585-07:00</timestamp><ack>Success</ack><correlationId>4d31bf900a109</correlationId><build>5472483</build></responseEnvelope><cancelUrl>http://my-cancel-url.com</cancelUrl><currencyCode>TRY</currencyCode><paymentInfoList><paymentInfo><transactionId>my-transaction-id</transactionId><transactionStatus>COMPLETED</transactionStatus><receiver><amount>5.00</amount><email>receiver#email.com</email><primary>true</primary><paymentType>SERVICE</paymentType><accountId>7VYWTSCQKWPAL</accountId></receiver><refundedAmount>0.00</refundedAmount><pendingRefund>false</pendingRefund><senderTransactionId>7P642947V2872150G</senderTransactionId><senderTransactionStatus>COMPLETED</senderTransactionStatus></paymentInfo><paymentInfo><receiver><amount>4.60</amount><email>soulsmasher#gmail.com</email><primary>false</primary><paymentType>SERVICE</paymentType><accountId>7UZSWUVKCU4UW</accountId></receiver><refundedAmount>0.00</refundedAmount><pendingRefund>false</pendingRefund></paymentInfo></paymentInfoList><returnUrl>http://success-url-area.com</returnUrl><senderEmail>sender#email.com</senderEmail><status>INCOMPLETE</status><payKey>my-paykey</payKey><actionType>PAY_PRIMARY</actionType><feesPayer>PRIMARYRECEIVER</feesPayer><reverseAllParallelPaymentsOnError>false</reverseAllParallelPaymentsOnError><sender><email>sender#email.com</email><accountId>Y2BSLXZ8DQYY2</accountId><useCredentials>false</useCredentials></sender></ns2:PaymentDetailsResponse>
)
When I try to execute refund, providing paykey, transaction ID (which I got from the request above), and sender email (which will get refund) this error comes up (you can see the raw request and responses below):
Array
(
[Errors] => Array
(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 589061
[ExceptionID] =>
[Message] => The receiver sender#email.com is invalid for this refund
[Parameter] => sender#email.com
[Severity] => Error
[Subdomain] => Application
)
)
[Ack] => Failure
[Build] => 5472483
[CorrelationID] => 2a1630b772ee0
[Timestamp] => 2013-03-20T09:52:10.986-07:00
[EncryptedTransactionID] =>
[RefundFeeAmount] =>
[RefundGrossAmount] =>
[RefundHasBecomeFull] =>
[RefundNetAmount] =>
[RefundStatus] =>
[RefundTransactionStatus] =>
[TotalOfAllRefunds] =>
[Receiver] => Array
(
[Amount] =>
[Email] =>
[InvoiceID] =>
[PaymentType] =>
[Primary] =>
)
[RawRequest] => <?xml version="1.0" encoding="utf-8"?><RefundRequest xmlns="http://svcs.paypal.com/types/ap"><requestEnvelope xmlns=""><detailLevel>ReturnAll</detailLevel><errorLanguage>en_US</errorLanguage></requestEnvelope><currencyCode>TRY</currencyCode><payKey xmlns="">my-paykey</payKey><receiverList xmlns=""><receiver xmlns=""><amount xmlns="">1.00</amount><email xmlns="">sender#email.com</email><paymentType xmlns="">SERVICE</paymentType></receiver></receiverList><transactionId xmlns="">1VL98806A27476639</transactionId></RefundRequest>
[RawResponse] => <?xml version='1.0' encoding='UTF-8'?><ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap"><responseEnvelope><timestamp>2013-03-20T09:52:10.986-07:00</timestamp><ack>Failure</ack><correlationId>2a1630b772ee0</correlationId><build>5472483</build></responseEnvelope><error><errorId>589061</errorId><domain>PLATFORM</domain><subdomain>Application</subdomain><severity>Error</severity><category>Application</category><message>The receiver sender#email.com is invalid for this refund</message><parameter>sender#email.com</parameter></error></ns3:FaultMessage>
)
1
Also when I don't provide transaction ID and leave the rest to PayPal, the issue changes to this (raw XML request are below the array):
Array
(
[Errors] => Array
(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 589036
[ExceptionID] =>
[Message] => The currency code is missing or doesn't match the code in the payment request
[Parameter] =>
[Severity] => Error
[Subdomain] => Application
)
)
[Ack] => Failure
[Build] => 5472483
[CorrelationID] => e3fc5e41040f3
[Timestamp] => 2013-03-20T10:02:29.233-07:00
[EncryptedTransactionID] =>
[RefundFeeAmount] =>
[RefundGrossAmount] =>
[RefundHasBecomeFull] =>
[RefundNetAmount] =>
[RefundStatus] =>
[RefundTransactionStatus] =>
[TotalOfAllRefunds] =>
[Receiver] => Array
(
[Amount] =>
[Email] =>
[InvoiceID] =>
[PaymentType] =>
[Primary] =>
)
[RawRequest] => <?xml version="1.0" encoding="utf-8"?><RefundRequest xmlns="http://svcs.paypal.com/types/ap"><requestEnvelope xmlns=""><detailLevel>ReturnAll</detailLevel><errorLanguage>en_US</errorLanguage></requestEnvelope><currencyCode>TRY</currencyCode><payKey xmlns="">AP-52A99028X8685964M</payKey><receiverList xmlns=""><receiver xmlns=""><amount xmlns="">1.00</amount><email xmlns="">sender#email.com</email><paymentType xmlns="">SERVICE</paymentType></receiver></receiverList></RefundRequest>
[RawResponse] => <?xml version='1.0' encoding='UTF-8'?><ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap"><responseEnvelope><timestamp>2013-03-20T10:02:29.233-07:00</timestamp><ack>Failure</ack><correlationId>e3fc5e41040f3</correlationId><build>5472483</build></responseEnvelope><error><errorId>589036</errorId><domain>PLATFORM</domain><subdomain>Application</subdomain><severity>Error</severity><category>Application</category><message>The currency code is missing or doesn't match the code in the payment request</message></error></ns3:FaultMessage>
)
1
As you can see, I've already provided the CurrencyCode, also the sender's email adress is taken from the request itself to prevent typos. Even if I hardcode it doesn't change the situation.
Can you help me, what am I missing?
Thanks,
check the documentation say by paypal here
Turkish Lira TRY
NOTE:This currency is supported as a payment currency and a currency balance for in-country PayPal accounts only.

Categories