|
21 | 21 | * 'testMode' => true, // Or false for live transactions.
|
22 | 22 | * ));
|
23 | 23 | *
|
| 24 | + * // Next, there are two ways to conduct a sale with Payflow: |
| 25 | + * // 1. a reference sale in which an authorization transaction reference is passed |
| 26 | + * // 2. a sale in which card data is directly passed |
| 27 | + * // |
| 28 | + * // #1 should be used any time multiple charges must be committed against an authorization |
| 29 | + * // either because parts of an order shipped at different times or because authorization is |
| 30 | + * // being used to "tokenize" a card and store it on the gateway (a Paypal prescribed process). |
| 31 | + * // Capture can only be called once against an authorization but sale does not have this limitation. |
| 32 | + * |
| 33 | + * // @see developer.paypal.com/docs/classic/payflow/integration-guide/#submitting-reference-transactions---tokenization |
| 34 | + * |
| 35 | + * // 1. Reference (tokenized card) Sale example: |
| 36 | + * // $reference_id can be the transaction reference from a previous authorization, credit, capture, sale, voice auth, |
| 37 | + * // or void. |
| 38 | + * $transaction = $gateway->purchase(array( |
| 39 | + * 'amount' => '10.00', |
| 40 | + * 'transactionReference' => $reference_id, |
| 41 | + * )); |
| 42 | + * |
| 43 | + * // 2. Sale (with card data) example: |
24 | 44 | * // Create a credit card object
|
25 | 45 | * // This card can be used for testing.
|
26 | 46 | * $card = new CreditCard(array(
|
|
49 | 69 | class PurchaseRequest extends AuthorizeRequest
|
50 | 70 | {
|
51 | 71 | protected $action = 'S';
|
| 72 | + |
| 73 | + public function getData() |
| 74 | + { |
| 75 | + if ($this->parameters->get('transactionReference')) { |
| 76 | + return $this->getReferenceSaleData(); |
| 77 | + } |
| 78 | + |
| 79 | + return parent::getData(); |
| 80 | + } |
| 81 | + |
| 82 | + public function getReferenceSaleData() |
| 83 | + { |
| 84 | + $this->validate('transactionReference', 'amount'); |
| 85 | + |
| 86 | + $data = $this->getBaseData(); |
| 87 | + $data['AMT'] = $this->getAmount(); |
| 88 | + $data['ORIGID'] = $this->getTransactionReference(); |
| 89 | + $data['TENDER'] = 'C'; |
| 90 | + |
| 91 | + return $data; |
| 92 | + } |
52 | 93 | }
|
0 commit comments