-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponse.php
150 lines (141 loc) · 5.03 KB
/
Response.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
namespace CanadaSatellite\Bambora;
/**
* 2021-07-17
* 1) A response:
* {
* "authCode": "TEST",
* "avsAddrMatch": "0",
* "avsId": "N",
* "avsMessage": "Street address and Postal/ZIP do not match.",
* "avsPostalMatch": "0",
* "avsProcessed": "1",
* "avsResult": "0",
* "cardType": "VI",
* "cvdId": "1",
* "errorFields": "",
* "errorType": "N",
* "hashValue": "5961d1ce5492e25403c2d27bdd83ebb02d83c19f",
* "messageId": "1",
* "messageText": "Approved",
* "paymentMethod": "CC",
* "ref1": "",
* "ref2": "",
* "ref3": "",
* "ref4": "",
* "ref5": "",
* "responseType": "T",
* "trnAmount": "32.69",
* "trnApproved": "1",
* "trnDate": "7/16/2021 8:15:28 PM",
* "trnId": "10000025",
* "trnOrderNumber": "190630",
* "trnType": "PA"
* }
* 2) «Bambora response variables»: https://support.na.bambora.com/bic/w/docs/response-variables.htm
*/
final class Response extends \Df\Core\O {
/**
* 2021-07-17
* «0-32 alphanumeric characters»
* «If the transaction is approved this parameter contains a unique bank-issued code.»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @used-by \CanadaSatellite\Bambora\Method::authorize()
* @return string
*/
function authCode() {return df_prop($this);}
/**
* 2021-07-17
* «1 digit»
* «1 – if AVS was validated with both a match against address, and a match against postal/ZIP code»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @used-by \CanadaSatellite\Bambora\Method::authorize()
* @return bool
*/
function avsResult() {return 1 === (int)df_prop($this);}
/**
* 2021-07-20
* 1) «List of fields»
* «For a user generated error, this variable includes a list of fields that failed form validation.
* Notify the customer that they must correct these fields before the transaction can be completed.»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* 2) «The `errorFields` variable will contain a list of fields that failed validation.»
* https://mage2.pro/t/6280, Page 11.
* @used-by reason()
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @return string
*/
function errorFields() {return df_prop($this);}
/**
* 2021-07-17
* 1) «1 character»
* «Returns the value: N, S, or U.»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* 2) «The `errorType` response variable will indicate “U” if a form field error occurs.»: https://mage2.pro/t/6280, Page 11.
* 3) «System generated errors can be identified in a Server to Server integration
* by a response message “errorType=S” in the Beanstream response string.
* If a system generated error occurs, validate your integration and website setup.»: https://mage2.pro/t/6280, Page 12.
* @used-by valid()
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @return string
*/
function errorType() {return df_prop($this);}
/**
* 2021-07-17
* «1-3 digits»
* «References a detailed approved/declined transaction response message.
* Review our gateway response message table for a full description of each message.»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @return int
*/
function messageId() {return (int)df_prop($this);}
/**
* 2021-07-17
* «Returns a basic approved/declined message that can be displayed to the customer on a confirmation page.
* Review our gateway response message table for details.»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* @used-by reason()
* @used-by \CanadaSatellite\Bambora\Action::check()
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @return string
*/
function messageText() {return strtolower(df_prop($this));}
/**
* 2021-07-20
* @used-by \CanadaSatellite\Bambora\Action::check()
* @return string
*/
function reason() {return $this->trnApproved() ? '' : "The transaction has been declined: «{$this->messageText()}».";}
/**
* 2021-07-17
* «0 – Transaction refused, 1 – Transaction approved»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* @used-by reason()
* @used-by \CanadaSatellite\Bambora\Action::check()
* @return bool
*/
function trnApproved() {return !!df_prop($this);}
/**
* 2021-07-17
* «8 digits»
* «Unique id number identifying an individual transaction.»
* https://support.na.bambora.com/bic/w/docs/response-variables.htm
* @used-by \CanadaSatellite\Bambora\Action::check()
* @used-by \CanadaSatellite\Bambora\Facade::p()
* @used-by \CanadaSatellite\Bambora\Method::authorize()
* @used-by \CanadaSatellite\Bambora\Method::capture()
* @used-by \CanadaSatellite\Bambora\Method::refund()
* @used-by \CanadaSatellite\Bambora\Method::void()
* @return int
*/
function trnId() {return (int)df_prop($this);}
/**
* 2021-07-17
* @used-by \CanadaSatellite\Bambora\Facade::api()
* @return bool
*/
function valid() {return 'N' === $this->errorType();}
}