MediaWiki fundraising/REL1_35
AmountInCents.php
Go to the documentation of this file.
1<?php
2
13 public function stage( GatewayType $adapter, $normalized, &$stagedData ) {
14 if (
15 empty( $normalized['amount'] ) ||
16 empty( $normalized['currency'] ) ||
17 !is_numeric( $normalized['amount'] )
18 ) {
19 // can't do anything with amounts at all. Just go home.
20 unset( $stagedData['amount'] );
21 return;
22 }
23
24 $amount = Amount::round( $normalized['amount'], $normalized['currency'] );
25
26 $stagedData['amount'] = round( $amount * 100 );
27 }
28
29 public function unstage( GatewayType $adapter, $stagedData, &$unstagedData ) {
30 $unstagedData['amount'] = $stagedData['amount'] / 100;
31 }
32}
Stage: amount.
unstage(GatewayType $adapter, $stagedData, &$unstagedData)
stage(GatewayType $adapter, $normalized, &$stagedData)
Transform a subset of normalized data into the "staged" data expected by a payment processor.
static round( $amount, $currencyCode)
Some currencies, like JPY, don't exist in fractional amounts.
Definition Amount.php:133
GatewayType Interface.
Used to mark any class which implements an staging method, for transforming data into the form expect...
Used to mark any class which implements an unstaging method, for transforming data returned by a paym...