Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110822469
PhortuneStripePaymentProvider.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Apr 28, 07:13
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Apr 30, 07:13 (2 d)
Engine
blob
Format
Raw Data
Handle
25854153
Attached To
rPH Phabricator
PhortuneStripePaymentProvider.php
View Options
<?php
final
class
PhortuneStripePaymentProvider
extends
PhortunePaymentProvider
{
public
function
canHandlePaymentMethod
(
PhortunePaymentMethod
$method
)
{
$type
=
$method
->
getMetadataValue
(
'type'
);
return
(
$type
===
'stripe.customer'
);
}
/**
* @phutil-external-symbol class Stripe_Charge
*/
protected
function
executeCharge
(
PhortunePaymentMethod
$method
,
PhortuneCharge
$charge
)
{
$secret_key
=
$this
->
getSecretKey
();
$params
=
array
(
'amount'
=>
$charge
->
getAmountInCents
(),
'currency'
=>
'usd'
,
'customer'
=>
$method
->
getMetadataValue
(
'stripe.customerID'
),
'description'
=>
$charge
->
getPHID
(),
'capture'
=>
true
,
);
$stripe_charge
=
Stripe_Charge
::
create
(
$params
,
$secret_key
);
$id
=
$stripe_charge
->
id
;
if
(!
$id
)
{
throw
new
Exception
(
"Stripe charge call did not return an ID!"
);
}
$charge
->
setMetadataValue
(
'stripe.chargeID'
,
$id
);
}
private
function
getSecretKey
()
{
return
PhabricatorEnv
::
getEnvConfig
(
'stripe.secret-key'
);
}
}
Event Timeline
Log In to Comment