Skip to content

Commit

Permalink
1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Mar 19, 2017
1 parent 82a0dd1 commit c9aabd2
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 180 deletions.
192 changes: 84 additions & 108 deletions Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
];}

Expand All @@ -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
];}

Expand Down
1 change: 0 additions & 1 deletion Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});}
}
31 changes: 31 additions & 0 deletions W/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace Dfe\Stripe\W;
/**
* 2017-03-15
* @see \Dfe\Stripe\W\Event\Charge\Captured
* @see \Dfe\Stripe\W\Event\Charge\Refunded
*/
abstract class Event extends \Df\StripeClone\W\Event {
/**
* 2017-01-04
* 2017-01-06
* Сообщение от платёжной системы — это иерархический JSON.
* На верхнем уровне иерархии расположены метаданные:
* *) тип сообщения (например: «charge.captured»).
* *) идентификатор платежа в платёжной системе
* *) тестовый ли платёж или промышленный
* *) версия API
* *) и.т.п.
* Конкретные данные сообщения расположены внутри иерархии по некоему пути.
* Этот путь и возвращает наш метод.
* 2017-02-14
* [Stripe] An example of the «charge.captured» event (being sent to a webhook)
* https://mage2.pro/t/2745
* @override
* @see \Df\StripeClone\W\Event::roPath()
* @used-by \Df\StripeClone\W\Event::k_pid()
* @used-by \Df\StripeClone\W\Event::ro()
* @return string
*/
protected function roPath() {return 'data/object';}
}
24 changes: 24 additions & 0 deletions W/Event/Charge/Captured.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace Dfe\Stripe\W\Event\Charge;
use Dfe\Stripe\Method as M;
// 2017-03-15
final class Captured extends \Dfe\Stripe\W\Event {
/**
* 2017-01-06
* @override
* @see \Df\StripeClone\W\Event::ttCurrent()
* @used-by \Df\StripeClone\W\Event::id()
* @used-by \Df\StripeClone\W\Strategy\Charge::action()
* @return string
*/
function ttCurrent() {return M::T_CAPTURE;}

/**
* 2017-01-06
* @override
* @see \Df\StripeClone\W\Event::ttParent()
* @used-by \Df\StripeClone\W\Nav::pidAdapt()
* @return string
*/
function ttParent() {return M::T_AUTHORIZE;}
}
24 changes: 24 additions & 0 deletions W/Event/Charge/Refunded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace Dfe\Stripe\W\Event\Charge;
use Dfe\Stripe\Method as M;
// 2017-03-15
final class Refunded extends \Dfe\Stripe\W\Event {
/**
* 2017-01-06
* @override
* @see \Df\StripeClone\W\Event::ttCurrent()
* @used-by \Df\StripeClone\W\Event::id()
* @used-by \Df\StripeClone\W\Strategy\Charge::action()
* @return string
*/
function ttCurrent() {return M::T_REFUND;}

/**
* 2016-12-16
* @override
* @see \Df\StripeClone\W\Event::ttParent()
* @used-by \Df\StripeClone\W\Nav::pidAdapt()
* @return string
*/
function ttParent() {return M::T_CAPTURE;}
}
24 changes: 1 addition & 23 deletions W/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,4 @@
* @see \Dfe\Stripe\W\Handler\Charge\Captured
* @see \Dfe\Stripe\W\Handler\Charge\Refunded
*/
abstract class Handler extends \Df\StripeClone\W\Handler {
/**
* 2017-01-04
* 2017-01-06
* Сообщение от платёжной системы — это иерархический JSON.
* На верхнем уровне иерархии расположены метаданные:
* *) тип сообщения (например: «charge.captured»).
* *) идентификатор платежа в платёжной системе
* *) тестовый ли платёж или промышленный
* *) версия API
* *) и.т.п.
* Конкретные данные сообщения расположены внутри иерархии по некоему пути.
* Этот путь и возвращает наш метод.
* 2017-02-14
* [Stripe] An example of the «charge.captured» event (being sent to a webhook)
* https://mage2.pro/t/2745
* @override
* @see \Df\StripeClone\W\Handler::roPath()
* @used-by \Df\StripeClone\W\Handler::ro()
* @return string
*/
final protected function roPath() {return 'data/object';}
}
abstract class Handler extends \Df\StripeClone\W\Handler {}
20 changes: 0 additions & 20 deletions W/Handler/Charge/Captured.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,7 @@
// 2017-01-04
namespace Dfe\Stripe\W\Handler\Charge;
use Df\StripeClone\W\Strategy\Charge\Captured as Strategy;
use Dfe\Stripe\Method as M;
final class Captured extends \Dfe\Stripe\W\Handler {
/**
* 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_CAPTURE;}

/**
* 2017-01-06
* @override
* @see \Df\StripeClone\W\Handler::parentTransactionType()
* @used-by \Df\StripeClone\W\Handler::adaptParentId()
* @return string
*/
protected function parentTransactionType() {return M::T_AUTHORIZE;}

/**
* 2017-03-13
* @override
Expand Down
Loading

0 comments on commit c9aabd2

Please sign in to comment.