165 - Splitting Payments with Stripe

This commit is contained in:
Adam Wathan
2018-01-26 13:40:58 -05:00
parent 7442baa5c5
commit def3e0b6b2
3 changed files with 32 additions and 9 deletions

View File

@@ -16,4 +16,22 @@ class StripePaymentGatewayTest extends TestCase
{
return new StripePaymentGateway(config('services.stripe.secret'));
}
/** @test */
function ninety_percent_of_the_payment_is_transferred_to_the_destination_account()
{
$paymentGateway = new StripePaymentGateway(config('services.stripe.secret'));
$paymentGateway->charge(5000, $paymentGateway->getValidTestToken(), env('STRIPE_TEST_PROMOTER_ID'));
$lastStripeCharge = array_first(\Stripe\Charge::all([
'limit' => 1
], ['api_key' => config('services.stripe.secret')])['data']);
$this->assertEquals(5000, $lastStripeCharge['amount']);
$this->assertEquals(env('STRIPE_TEST_PROMOTER_ID'), $lastStripeCharge['destination']);
$transfer = \Stripe\Transfer::retrieve($lastStripeCharge['transfer'], ['api_key' => config('services.stripe.secret')]);
$this->assertEquals(4500, $transfer['amount']);
}
}