From c9aabd201caa2f2c5951424272e970cc259dc8ef Mon Sep 17 00:00:00 2001 From: Dmitry Fedyuk Date: Sun, 19 Mar 2017 12:22:45 +0300 Subject: [PATCH] 1.9.0 --- Charge.php | 192 +++++++++++++++------------------- Method.php | 1 - Settings.php | 3 +- W/Event.php | 31 ++++++ W/Event/Charge/Captured.php | 24 +++++ W/Event/Charge/Refunded.php | 24 +++++ W/Handler.php | 24 +---- W/Handler/Charge/Captured.php | 20 ---- W/Handler/Charge/Refunded.php | 28 +---- composer.json | 4 +- 10 files changed, 171 insertions(+), 180 deletions(-) create mode 100644 W/Event.php create mode 100644 W/Event/Charge/Captured.php create mode 100644 W/Event/Charge/Refunded.php diff --git a/Charge.php b/Charge.php index 98cf599..29aee99 100644 --- a/Charge.php +++ b/Charge.php @@ -26,41 +26,35 @@ protected function cardIdPrefix() {return 'card';} * @return array(string => mixed) */ protected function pCharge() {return [ - /** - * 2016-03-07 - * https://stripe.com/docs/api/php#create_charge-metadata - * «A set of key/value pairs that you can attach to a charge object. - * It can be useful for storing additional information about the customer - * in a structured format. - * It's often a good idea to store an email address in metadata for tracking later.» - * - * https://stripe.com/docs/api/php#metadata - * «You can have up to 20 keys, with key names up to 40 characters long - * and values up to 500 characters long.» - * - * 2016-03-08 - * https://stripe.com/blog/adding-context-with-metadata - * «Adding context with metadata» - */ + // 2016-03-07 + // https://stripe.com/docs/api/php#create_charge-metadata + // «A set of key/value pairs that you can attach to a charge object. + // It can be useful for storing additional information about the customer + // in a structured format. + // It's often a good idea to store an email address in metadata for tracking later.» + // + // https://stripe.com/docs/api/php#metadata + // «You can have up to 20 keys, with key names up to 40 characters long + // and values up to 500 characters long.» + // + // 2016-03-08 + // https://stripe.com/blog/adding-context-with-metadata + // «Adding context with metadata» 'metadata' => $this->metadata(40, 500) - /** - * 2016-03-07 - * https://stripe.com/docs/api/php#create_charge-receipt_email - * «The email address to send this charge's receipt to. - * The receipt will not be sent until the charge is paid. - * If this charge is for a customer, - * the email address specified here will override the customer's email address. - * Receipts will not be sent for test mode charges. - * If receipt_email is specified for a charge in live mode, - * a receipt will be sent regardless of your email settings.» - */ + // 2016-03-07 + // «The email address to send this charge's receipt to. + // The receipt will not be sent until the charge is paid. + // If this charge is for a customer, + // the email address specified here will override the customer's email address. + // Receipts will not be sent for test mode charges. + // If receipt_email is specified for a charge in live mode, + // a receipt will be sent regardless of your email settings.» + // https://stripe.com/docs/api/php#create_charge-receipt_email ,'receipt_email' => null - /** - * 2016-03-07 - * «Shipping information for the charge. - * Helps prevent fraud on charges for physical goods.» - * https://stripe.com/docs/api/php#charge_object-shipping - */ + // 2016-03-07 + // «Shipping information for the charge. + // Helps prevent fraud on charges for physical goods.» + // https://stripe.com/docs/api/php#charge_object-shipping ,'shipping' => $this->pShipping($forCharge = true) ];} @@ -72,89 +66,71 @@ protected function pCharge() {return [ * @return array(string => mixed) */ protected function pCustomer() {return [ - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-account_balance - * «An integer amount in cents - * that is the starting account balance for your customer. - * A negative amount represents a credit - * that will be used before attempting any charges to the customer’s card; - * a positive amount will be added to the next invoice.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-account_balance + // «An integer amount in cents + // that is the starting account balance for your customer. + // A negative amount represents a credit + // that will be used before attempting any charges to the customer’s card; + // a positive amount will be added to the next invoice.» 'account_balance' => 0 - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-business_vat_id - * «The customer’s VAT identification number. - * If you are using Relay, this field gets passed to tax provider - * you are using for your orders. - * This will be unset if you POST an empty value. - * This can be unset by updating the value to null and then saving.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-business_vat_id + // «The customer’s VAT identification number. + // If you are using Relay, this field gets passed to tax provider + // you are using for your orders. + // This will be unset if you POST an empty value. + // This can be unset by updating the value to null and then saving.» ,'business_vat_id' => null - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-coupon - * «If you provide a coupon code, - * the customer will have a discount applied on all recurring charges. - * Charges you create through the API will not have the discount.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-coupon + // «If you provide a coupon code, + // the customer will have a discount applied on all recurring charges. + // Charges you create through the API will not have the discount.» ,'coupon' => null - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-metadata - * «A set of key/value pairs that you can attach to a customer object. - * It can be useful for storing additional information about the customer - * in a structured format. This will be unset if you POST an empty value. - * This can be unset by updating the value to null and then saving.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-metadata + // «A set of key/value pairs that you can attach to a customer object. + // It can be useful for storing additional information about the customer + // in a structured format. This will be unset if you POST an empty value. + // This can be unset by updating the value to null and then saving.» ,'metadata' => df_clean(['URL' => df_customer_backend_url($this->c())]) - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-plan - * «The identifier of the plan to subscribe the customer to. - * If provided, the returned customer object will have a list of subscriptions - * that the customer is currently subscribed to. - * If you subscribe a customer to a plan without a free trial, - * the customer must have a valid card as well.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-plan + // «The identifier of the plan to subscribe the customer to. + // If provided, the returned customer object will have a list of subscriptions + // that the customer is currently subscribed to. + // If you subscribe a customer to a plan without a free trial, + // the customer must have a valid card as well.» ,'plan' => null - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-quantity - * «The quantity you’d like to apply to the subscription you’re creating - * (if you pass in a plan). For example, if your plan is 10 cents/user/month, - * and your customer has 5 users, you could pass 5 as the quantity - * to have the customer charged 50 cents (5 x 10 cents) monthly. - * Defaults to 1 if not set. Only applies when the plan parameter is also provided.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-quantity + // «The quantity you’d like to apply to the subscription you’re creating + // (if you pass in a plan). For example, if your plan is 10 cents/user/month, + // and your customer has 5 users, you could pass 5 as the quantity + // to have the customer charged 50 cents (5 x 10 cents) monthly. + // Defaults to 1 if not set. Only applies when the plan parameter is also provided.» ,'quantity' => null - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-shipping - * «optional associative array» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-shipping + // «optional associative array» ,'shipping' => $this->pShipping() - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-tax_percent - * «A positive decimal (with at most two decimal places) between 1 and 100. - * This represents the percentage of the subscription invoice subtotal - * that will be calculated and added as tax to the final amount each billing period. - * For example, a plan which charges $10/month with a tax_percent of 20.0 - * will charge $12 per invoice. Can only be used if a plan is provided.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-tax_percent + // «A positive decimal (with at most two decimal places) between 1 and 100. + // This represents the percentage of the subscription invoice subtotal + // that will be calculated and added as tax to the final amount each billing period. + // For example, a plan which charges $10/month with a tax_percent of 20.0 + // will charge $12 per invoice. Can only be used if a plan is provided.» ,'tax_percent' => null - /** - * 2016-08-22 - * https://stripe.com/docs/api/php#create_customer-trial_end - * «Unix timestamp representing the end of the trial period - * the customer will get before being charged. - * If set, trial_end will override the default trial period of the plan - * the customer is being subscribed to. - * The special value now can be provided to end the customer’s trial immediately. - * Only applies when the plan parameter is also provided.» - */ + // 2016-08-22 + // https://stripe.com/docs/api/php#create_customer-trial_end + // «Unix timestamp representing the end of the trial period + // the customer will get before being charged. + // If set, trial_end will override the default trial period of the plan + // the customer is being subscribed to. + // The special value now can be provided to end the customer’s trial immediately. + // Only applies when the plan parameter is also provided.» ,'trial_end' => null ];} diff --git a/Method.php b/Method.php index c790a61..9e5320b 100644 --- a/Method.php +++ b/Method.php @@ -3,7 +3,6 @@ use Df\Core\Exception as DFE; use Magento\Sales\Model\Order as O; use Magento\Sales\Model\Order\Creditmemo as CM; -use Magento\Sales\Model\Order\Invoice; use Magento\Sales\Model\Order\Payment as OP; use Magento\Sales\Model\Order\Payment\Transaction as T; use Stripe\Error\Base as lException; diff --git a/Settings.php b/Settings.php index 911b876..1937773 100644 --- a/Settings.php +++ b/Settings.php @@ -20,7 +20,6 @@ function isMerchantInUS() {return 'US' === $this->account()->{'country'};} * @return \Stripe\Account */ private function account() {return dfc($this, function() { - $this->init(); - return \Stripe\Account::retrieve(); + $this->init(); return \Stripe\Account::retrieve(); });} } \ No newline at end of file diff --git a/W/Event.php b/W/Event.php new file mode 100644 index 0000000..aefa5fb --- /dev/null +++ b/W/Event.php @@ -0,0 +1,31 @@ +ro('refunds/data'))['amount'];} - - /** - * 2017-01-06 - * @override - * @see \Df\StripeClone\W\Handler::currentTransactionType() - * @used-by \Df\StripeClone\W\Handler::id() - * @used-by \Df\StripeClone\W\Strategy::currentTransactionType() - * @return string - */ - function currentTransactionType() {return M::T_REFUND;} + function amount() {return df_last($this->e()->ro('refunds/data'))['amount'];} /** * 2017-01-19 @@ -34,19 +23,10 @@ function currentTransactionType() {return M::T_REFUND;} * который возвращает @see \Dfe\Stripe\Facade\Refund::transId() * @override * @see \Df\StripeClone\W\IRefund::eTransId() - * @used-by \Df\StripeClone\W\Strategy\Charge\Refunded::handle() - * @return string - */ - function eTransId() {return df_last($this->ro('refunds/data'))['balance_transaction'];} - - /** - * 2016-12-16 - * @override - * @see \Dfe\Stripe\W\Handler::parentTransactionType() - * @used-by \Dfe\Stripe\W\Handler::adaptParentId() + * @used-by \Df\StripeClone\W\Strategy\Charge\Refunded::_handle() * @return string */ - protected function parentTransactionType() {return M::T_CAPTURE;} + function eTransId() {return df_last($this->e()->ro('refunds/data'))['balance_transaction'];} /** * 2017-03-13 diff --git a/composer.json b/composer.json index 7a4b224..42d4caa 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mage2pro/stripe" - ,"version": "1.8.0" + ,"version": "1.9.0" ,"description": "The «Stripe» payment extension for Magento 2." ,"type": "magento2-module" ,"homepage": "https://mage2.pro/c/extensions/stripe" @@ -11,7 +11,7 @@ "homepage": "https://mage2.pro/users/dmitry_fedyuk", "role": "Developer" }] - ,"require": {"mage2pro/core": ">=2.2.0", "stripe/stripe-php": "3.*"} + ,"require": {"mage2pro/core": ">=2.3.0", "stripe/stripe-php": "3.*"} ,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\Stripe\\": ""}} ,"keywords": [ "API"