summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/travelsample-1.0/contributions/payment-bpel-process/src/main/resources/payment.bpel
blob: e304d3a3493e661900b3908a55feb2e99868b26f (plain)
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
151
152
153
154
155
156
157
158
159
160
161
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->
<process name="Payment"
    targetNamespace="http://www.tuscanyscatours.com/Payment"
    xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:pp="http://www.tuscanyscatours.com/Payment/"
    xmlns:ccp="http://www.tuscanyscatours.com/CreditCardPayment/"
    xmlns:eg="http://www.tuscanyscatours.com/EmailGateway/"
    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">

  <import location="Payment.wsdl" 
          importType="http://schemas.xmlsoap.org/wsdl/"
          namespace="http://www.tuscanyscatours.com/Payment/"/>     

  <import location="CreditCardPayment.wsdl" 
          importType="http://schemas.xmlsoap.org/wsdl/"
          namespace="http://www.tuscanyscatours.com/CreditCardPayment/"/>
          
  <import location="EmailGateway.wsdl" 
          importType="http://schemas.xmlsoap.org/wsdl/"
          namespace="http://www.tuscanyscatours.com/EmailGateway/"/>          
          
   <partnerLinks>
      <partnerLink name="paymentPartnerLink" partnerLinkType="pp:PaymentLinkType" myRole="forward" />
      <partnerLink name="creditCardPaymentPartnerLink" partnerLinkType="ccp:CreditCardPaymentLinkType" partnerRole="forward" initializePartnerRole="yes" />
      <partnerLink name="emailGatewayPartnerLink" partnerLinkType="eg:EmailGatewayLinkType" partnerRole="forward" initializePartnerRole="yes" />
   </partnerLinks>
    
   <variables>
     <variable name="makePaymentMemberRequestMessage" messageType="pp:MakePaymentMemberRequest"/>
     <variable name="makePaymentMemberResponseMessage" messageType="pp:MakePaymentMemberResponse"/>
     <variable name="authorizeRequestMessage" messageType="ccp:AuthorizeRequest"/>
     <variable name="authorizeResponseMessage" messageType="ccp:AuthorizeResponse"/>
     <variable name="sendEmailRequestMessage" messageType="eg:SendEmailRequest"/>
     <variable name="sendEmailResponseMessage" messageType="eg:SendEmailResponse"/>
   </variables>

   <sequence>
       <receive name="start"
                partnerLink="paymentPartnerLink"
                portType="pp:Payment"
           	    operation="makePaymentMember"
                variable="makePaymentMemberRequestMessage"
                createInstance="yes"/>

       <!-- set up call to payments service -->
       <assign name="assign1">
          <copy>
              <from>
                  <literal>
                  <authorize xmlns="http://www.tuscanyscatours.com/CreditCardPayment/">
                    <CreditCard xmlns="">
                      <CreditCardType>Visa</CreditCardType>
                      <CreditCardNumber>12345678</CreditCardNumber>
                      <ExpMonth>2</ExpMonth>
                      <ExpYear>2010</ExpYear>
                      <CardOwner>
                        <Name>Empty</Name>
                        <Address>
                           <Street>1 The Road</Street>
                           <City>Winchester</City>
                           <State>Hampshire</State>
                           <ZipCode>AB1 2CD</ZipCode>
                           <HomePhone>12345678</HomePhone>
                        </Address>
                      </CardOwner>                      
                    </CreditCard>
                    <Amount xmlns="">0.0</Amount>
                  </authorize>
                  </literal>
              </from>
              <to>$authorizeRequestMessage.parameters</to>
          </copy>
          <copy>
              <from>$makePaymentMemberRequestMessage.parameters/CustomerId/text()</from>
              <to>$authorizeRequestMessage.parameters/CreditCard/CardOwner/Name</to>
          </copy>
          <copy>
              <from>$makePaymentMemberRequestMessage.parameters/Amount/text()</from>
              <to>$authorizeRequestMessage.parameters/Amount</to>
          </copy>                    
       </assign>
       
       <invoke name="invokeCreditCardPayment"
               operation="authorize"
               inputVariable="authorizeRequestMessage"
               outputVariable="authorizeResponseMessage"
               partnerLink="creditCardPaymentPartnerLink"
               portType="ccp:CreditCardPayment" />
       
       <!-- set up call to email gateway service -->
       <assign name="assign2">
          <copy>
              <from>
                  <literal>
                  <sendEmail xmlns="http://www.tuscanyscatours.com/EmailGateway/">
                    <Email xmlns="">
                      <To>Default</To>
                      <Title>Payment Confirmation</Title>
                      <Body>Your payment has been confirmed</Body>
                    </Email>
                  </sendEmail>
                  </literal>
              </from>
              <to>$sendEmailRequestMessage.parameters</to>
          </copy>
          <copy>
              <from>$makePaymentMemberRequestMessage.parameters/CustomerId/text()</from>
              <to>$sendEmailRequestMessage.parameters/Email/To</to>
          </copy>                   
       </assign>                  
       
       <!-- call the email gateway to send a confirmation -->
       <invoke name="invokeEmailGateway"
               operation="sendEmail"
               inputVariable="sendEmailRequestMessage"
               outputVariable="sendEmailResponseMessage"
               partnerLink="emailGatewayPartnerLink"
               portType="eg:EmailGateway" />
       
       <!-- set up the response -->
       <assign name="assign3">
          <copy keepSrcElementName="yes">
              <from>
                  <literal> 
                    <Status xmlns="">OK</Status>
                  </literal>
              </from>
              <to>$makePaymentMemberResponseMessage.parameters</to>
          </copy>
       </assign>
       
       
       <reply name="end"  
              partnerLink="paymentPartnerLink"
              portType="pp:Payment" 
              operation="makePaymentMember"
              variable="makePaymentMemberResponseMessage">
       </reply>
   </sequence>
</process>