Created
March 12, 2020 05:24
-
-
Save BHare1985/7fc719ba3a86c5c499ccdf55d5645e8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example closure for https://github.com/BHare1985/PaypalAccountTransactionProcessor | |
function($data){ | |
switch($data["txn_type"]){ | |
//=========== STANDARD PAYMENTS | |
case "web_accept": //Direct Credit Card (Pro) transaction, Buy Now, Donation or Smart Logo for eBay auctions button | |
case "pro_hosted": //Payment received; source is Website Payments Pro Hosted Solution. | |
case "virtual_terminal": //Payment received; source is Virtual Terminal | |
case "send_money": //Payment received; source is the Send Money tab on the PayPal website | |
case "cart": //Payment received for multiple items; source is Express Checkout or the PayPal Shopping Cart. | |
case "express_checkout": //Payment received for a single item; source is Express Checkout | |
case "masspay": //Payment sent using Mass Pay | |
return array(Action::create, Category::payments); | |
//=========== SUBSCRIPTIONS | |
case "subscr_signup": //Subscription started | |
return array(Action::create, Category::subscription); | |
case "subscr_payment": //Subscription payment received | |
return array(Action::activate, Category::subscription); | |
case "subscr_cancel": //Subscription canceled | |
case "subscr_eot": //Subscription expired | |
case "subscr_failed": //Subscription payment failed | |
return array(Action::deactivate, Category::subscription); | |
case "subscr_modify": //Subscription modified | |
return array(Action::nop, Category::subscription); | |
//=========== RECURRING PAYMENTS | |
case "recurring_payment_profile_created": //Recurring payment profile created | |
return array(Action::create, Category::recurring); | |
case "recurring_payment": //Recurring payment received | |
return array(Action::activate, Category::recurring); | |
case "recurring_payment_failed": //The attempt to collect a recurring payment fails | |
case "recurring_payment_profile_cancel": //Recurring payment profile canceled | |
case "recurring_payment_expired": //Recurring payment expired | |
case "recurring_payment_skipped": //Recurring payment skipped; it will be retried up to 3 times, 5 days apart | |
case "recurring_payment_suspended": //This transaction type is sent if PayPal tried to collect a recurring payment, but the related recurring payments profile has been suspended. | |
case "recurring_payment_suspended_due_to_max_failed_payment": //Recurring payment failed and the related recurring payment profile has been suspended | |
return array(Action::deactivate, Category::recurring); | |
//=========== DISPUTES | |
case "adjustment": //A dispute has been resolved and closed | |
return array(Action::nop, Category::disputes); | |
case "new_case": //A new dispute was filed | |
switch($data["case_type"]){ | |
case "chargeback": | |
switch($data["reason_code"]){ | |
case "unauthorized": //Buyer claims that he did not authorize payment. | |
case "non_receipt": //Buyer claims that he did not receive goods or service. | |
case "duplicate": //Buyer claims that a possible duplicate payment was made to the merchant. | |
case "merchandise": //Buyer claims that the received merchandise is unsatisfactory, defective, or damaged. | |
case "special": //Some other reason. Usually, special indicates a credit card processing error for which the merchant is not responsible and for which no debit to the merchant will result. PayPal must review the documentation from the credit card company to determine the nature of the dispute and possibly contact the merchant to resolve it. | |
return array(Action::deactivate, Category::dispute); | |
default: | |
throw new Exception("Unexpected case_type: {$data["case_type"]} reason_code: {$data["reason_code"]}"); | |
} | |
case "dispute": | |
case "complaint": | |
switch($data["reason_code"]){ | |
case "non_receipt": //Buyer claims that he did not receive goods or service. | |
case "not_as_described": //Buyer claims that the goods or service received differ from merchant's description of the goods or service. | |
case "unauthorized_claim": //Buyer claims that an unauthorized payment was made for this particular transaction. | |
return array(Action::deactivate, Category::dispute); | |
default: | |
throw new Exception("Unexpected case_type: {$data["case_type"]} reason_code: {$data["reason_code"]}"); | |
} | |
default: | |
throw new Exception("Unexpected case_type: {$data["case_type"]}"); | |
} | |
//=========== UNHANDLED | |
case "merch_pmt": //Monthly subscription paid for Website Payments Pro, Reference transactions, or Billing Agreements | |
case "mp_cancel": //Billing agreement cancelled | |
case "payout": //A payout related to a global shipping transaction was completed. | |
throw new Exception("Unhandled transaction type $type"); | |
default: | |
throw new Exception("Unexpected transaction type $type"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment