Server-side Implementation
Create payment method
Once the customer has successfully authenticated with PayPal, you can use one of the following calls
to create a payment method. You will be using this payment method for processing transactions
against the PayPal Order.
Create a new customer with a payment method
If you do not already have a record for this customer in your Vault, you can create a new customer
with a payment method using
Customer: Create
with the
PaymentMethodNonce
parameter.
- C#
var request = new CustomerRequest {
FirstName = "Fred",
LastName = "Jones",
PaymentMethodNonce = nonceFromTheClient
};
Result<customer> result = gateway.Customer.Create(request);
bool success = result.IsSuccess(); // true
Customer customer = result.Target;
string customerId = <a href="http://customer.Id">customer.Id</a>; // e.g. 160923
string cardToken = customer.PaymentMethods[0].Token; // e.g. f28w
Update an existing customer with a payment method
If the customer already exists in your Vault, you can add a new payment method to that customer
using Customer: Update
with the
PaymentMethodNonce
parameter.
- C#
var request = new CustomerRequest {
PaymentMethodNonce = NonceFromTheClient
};
Result<customer> updateResult = gateway.Customer.Update("the_customer_id", request);
updateResult.IsSuccess(); // true
NotFoundException
. Alternatively, you can use
Payment Method: Create
to accomplish the
same thing as above.
Process transactions
Use the transaction API to process customer payments against the PayPal Order:
- Create a transaction using payment information
- Submit a transaction for settlement to get paid
- Find a transaction
- Search for transactions that match specific criteria
- Void a transaction to cancel it before it settles
- Refund a settled transaction to return funds to the customer
Currency support
The customer will be charged in the currency associated with the
MerchantAccountId passed in the
Transaction: Sale
call. We support
all currencies that PayPal REST APIs support. For details on accepting foreign currencies with PayPal, see our
PayPal account setup guide.
Seller Protection
By passing a shipping address, you may also be eligible for
PayPal Seller Protection. You can check the status of Seller Protection as follows:
- C#
Transaction transaction = gateway.Transaction.Find("the_transaction_id");
transaction.PayPalDetails.SellerProtectionStatus; // "ELIGIBLE"
Void an order
As the PayPal Order is represented by a customer's payment method, to void an order you need to
delete the payment method by calling
Payment Method: Delete
.